I'm have a strange problem.
If I run this on the CPU:
long j;
float test=0;
for (j=0;j<20587;j++) test+=0.002879994;
The result is : 59.29 (correct)
if I run the same code on the CLA the result is 59.24
So how do I fix this?
Thanks!
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.
This may not be completely related, but what are your floating point options set to? Namely fp_mode and fp_reassoc. I'm not sure if these floating point options only apply to the CPU or both CPU and CLA. This can be checked in CCS by going to your project properties, then CCS Build>C2000 Compiler>Optimization. To avoid any precission loss, fp_mode should be set to 'strict' and fp_reassoc to 'off'.
This might be related to https://e2e.ti.com/support/microcontrollers/c2000/f/171/t/487649
Try turning on the rounding mode as i've suggested in the post.
Yes this solve the problem:
__meallow();
__asm(" MSETFLG RNDF32=1") ;
__medis();
This is way more impotent then hiding it deep a way, in the reference manual. So why? Is there any reason for not using it?
I got really suspicious when really impotent information is hided away in datasheets?
evs said:So why? Is there any reason for not using it?
IEEE754 provides for 4 different rounding modes. The CLA and C28x+FPU provide two of thoe modes, truncation (RNDF=0) and round to nearest, break ties to even (RNDF=1). Now you can choose to use whichever mode you wish - on the C28x the boot code usually turns on RNDF but there is no such startup code for the CLA so its up to the user whether they should turn on rounding.