We are using a F28069.
The compiler version is cl2000 version 6.2.5.
We experienced unexpected behavior of our application when executing this bit of code:
whatTheUnholyHellIsGoingOnHere = (testValue >= testLimit);
if ( whatTheUnholyHellIsGoingOnHere) {
/* some code that should never be executed because the condition is always false, yet it does occasionally. */
}
testValue and testLimit are float variables.
We have tracked the problem down to an interrupt service routine that apparently gets called between the assignment of the variable and the if statement check. This interrupt service routine had used the interrupt keyword to perform the context save and restore.
In the ISR, there are no floating point C variables, but the code generated does use floating point registers. In particular, it uses statements such as:
MOV32 R5H, *+XAR4[0], UNCF
Upon reading "TMS320C28x Floating Point Unit and Instruction Set Reference Guide", I have learned this instruction to affect the STF flag bits.
Looking at the context save/restore disassembly, there are no provisions to save the context of the STF register.
I have created my own context save and restore macros which do preserve this flag. I put them in a 'normal' (not interrupt keyword prefixed function), which simply calls the real ISR function (which I removed the interrupt keyword from), and now the unexpected behavior does not occur.