This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP432P4111: Floating point comparison errors

Part Number: MSP432P4111
Other Parts Discussed in Thread: SYSBIOS

G'Day all,

FYI - SimpleLink 3.40.0.005, Compiler 18.12.7

We are having some problem with floating point operations.  In particular we notice that very occasionally floating point comparisons are plainly wrong, similar to what has been seen in some other threads (though admittedly the context of those other threads is rather different to mine).

After some digging around we've found a possible culprit.  Our code enables Lazy Stacking for floating point at the start of main() but it seems all stacking of floating point registers gets turned off when BIOS_start() runs (FPCCR.ASPEN = 0, FPCCR.LSPEN = 0).  It turns out, some floating point operations have crept into our HWI/ZLIs so, with all stacking off, maybe the floating point registers are being corrupted. 

This leads us to some questions on how best to progress

  • How can we prove that the floating point registers are being corrupted?  We are struggling to come up with an effective debug technique here.
  • Can we turn on lazy stacking once SYSBIOS is running?  I think the comment here says we can't, but I'd appreciate the clarification.
  • Can we turn on full stacking once SYSBIOS is running?
  • Is it at all possible to do floating point operations in a SYSBIOS HWI/ZLI context?   If yes, what is the right way to go about it?  If no, does that mean the we absolutely must remove all floating point operations from HWIs/ZLIs (should not be a problem)?
  • How do SWIs play into all this - what is their context as far as floating point operations go?  We have lots of floating point operations in SWIs, changing that is not really an option.
  • Are there any other microcontroller features like this that SYSBIOS turns off as it starts??

Cheers

Julian

  • Hi Julian,

    Is it convenient to provide the code of floating-point arithmetic errors you uesd, it will help us to test and verify.

    Thanks!

    Best Regards

    Johnson

  • G'Day Johnson,

    Unfortunately no.  We don't have a simple example to demonstrate the problem, and even if we could send you our code, you'd also need our custom hardware to run it on.  Our code is relatively complex with a lot of HWIs/SWIs and Tasks and tight timing of operation.

    Interestingly, the error occurs only very occasionally and only for one specific floating point greater-than comparison.  At least, this is the only place we detect any problem. 

    Also interestingly, if we repeat the exact sample floating point greater comparisons multiple times, one after the other, and if the comparison gives the wrong answer, its only ever the first comparison that is wrong.  E.g.

    bool a1, a2, a3;

    a1 = x > y;   // If an incorrect result occurs its only ever this one that is wrong.

    a2 = x > y;

    a3 = x > y;

    Removing floating point operations from HWIs seems to have made this problem go away in that its not been seen for a few days now (though we have not been able to *prove* the problem is resolved).

    I guess I'm not directly asking for your help to debug the issue here, I'm asking for clarification of how FPU operation interacts with SYSBIOS.  Hence my previous questions - What are some debugging techniques to try and prove FPU register stacking was causing our problem?  Can I turn on lazy (or full) stacking inside SYSBIOS? Is there any way to do floating point operations in HWI/ZLIs safely?   Are floating point operations safe in SWIs and Tasks?  

    Cheers

    Julian

     

     

  • Hi Julian,

    Understood, it seems that this problem is still more complicated, I will update it here after talking with the relevant team.

    Thanks!

    Best Regards

    Johnson