Other Parts Discussed in Thread: TEST2
Tool/software: Code Composer Studio
I found something really weird with comparisons in the CLA co-processor (I am aware of compiler bug when the difference of the operands would overflow, which I believe is not the case here). I have done some tests, outcomes are in the comment (CurrentLimit = -1, DACOffset[1][Phase] = 501):
int16 test1 = 1>-501?1:-501; // 1
int16 test2 = -1>-501?-1:-501; // -1
int16 test3 = -CurrentLimit>-DACOffset[1][Phase]?-CurrentLimit:-DACOffset[1][Phase]; // -501
int16 test4 = -CurrentLimit>-DACOffset[1][Phase]; // 0
int16 test5 = (-CurrentLimit)>(-DACOffset[1][Phase])?-CurrentLimit:-DACOffset[1][Phase]; // -501
int16 test6 = (-CurrentLimit>-DACOffset[1][Phase])?-CurrentLimit:-DACOffset[1][Phase]; // -501
int16 test7 = -1;
int16 test8 = 501;
int16 test9 = (-test7)>-test8?(-test7):-test8; // -501
int16 test10 = -test7; // 1
int16 test11 = test10>-test8?test10:-test8; // 1
The main CPU, and the 'Expressions' window, do arrive at the correct value, it goes wrong in the CLA. Any ideas?