Part Number: TMS320F28335
I experienced a strange issue with the TMS320F28335.
When I perform a simple 'greater than' comparison with floating-point numbers, the comparison sometimes seem to give the wrong result.
In an effort to pin-point the problem I tested the following code:
if (test_variable > 100.0)
{
pjump++;
asm(" MOV32 @_pregvalue, R0H");
pjumpvalue = test_variable;
test_variable = 100.0;
}
if (test_variable < 0.0)
{
njump++;
asm(" MOV32 @_nregvalue, R0H");
njumpvalue = test_variable;
test_variable = 0.0;
}
The asm() commands place the value of the R0H register, which is the register in which test_variable is moved to perform the floating-point comparison in the output .asm file, into the pregvalue or nregvalue variable (just in case)
I regularly monitored the value of these variables by outputting their values through a serial port. The data clearly shows that at some (seemingly random) times the code block after if (test_variable > 100.0) was executed even though the value of the test_variable was lower than 100.0. This occurred at a frequency of, say, once every few hours. However, the same was never observed for the second (<) comparison.
Is this a known issue? It seems possible to get around it using the __fmin() and __fmax() functions instead of if() tests, but I still find it slightly disturbing.
Thanks in advance,
Laurent Badel
For info, the relevant part of the generated assembly is as follows - I couldn't see anything wrong with it:
MOV32 R0H,@_test_variable
CMPF32 R0H,#17096
MOVST0 ZF, NF
BF $C$L16,GT
...
$C$L16:
INC @_pjump
MOV32 @_pregvalue, R0H
MOVL ACC,@_test_variable
MOVL @_pjumpvalue,ACC
MOVIZ R0H,#17096
MOV32 @_test_variable,R0H





