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.

TMS320F28379D: Error while performing simple division of float variable in C2000 compiler

Part Number: TMS320F28379D


Hi,

I'm performing simple division of float variable datatype, but getting different result each time while debugging. Using C2000 Compiler Version: TI v21.6.0.LTS 

Below is my simple code snippet:

float32_t reqPeriod = 0.00, Freq1= 0.00;

main()

{

reqPeriod = 1.00 / Freq1; 

}

Issue: 

Case 1: Input: Freq1 = 80010.0

reqPeriod = 0.997898 (Expected reqPeriod = 1.249844e^-5)

and goes to void __error__(const char *filename, uint32_t line);

Now, again entering different input

Case 2: Next input: Freq1 = 80000.0

reqPeriod: 1.25e^-5 

Now, again entering same previous input 

Case 3: Freq1 = 80010.0

reqPeriod: 1.249844e^-5x

Again while checking the same input, getting wrong result everytime.

Executing the above code on TMS320F28379D launchpad.

Getting random error while calculating the division, Can you pls help!

  • Hello Supriya,

    Just to verify, do you have any optimizations enabled in the CCS project? Also since you say the error is random, if you put the equation in a while loop and execute it repeatedly with the same number, do you get inconsistent results (clearing the value after each execution of the loop)?

    Best regards,

    Omer Amir

  • Hello Omer, 

    I have not enabled any optimization level in CCS project. I have now checked with keeping the watch of variable on watch window and with real time refresh on, its working fine. Previously I was putting breakpoint and checking the result in every cycle, maybe because of using breakpoint I was getting random error every time, Is my analysis right? If yes, then Why because of putting breakpoint, we get wrong values.

  • Hi Supriya,

    The best way to check is to have some conditional with an ESTOP instruction within it, so that if the value is outside a certain margin of error you know right away; I'm not sure what could have happened that stopping immediately after the operation executed did not have the right result ready. If you did not have real time refresh on previously that might explain it. If you are having further issues with this, let me know.

    Best regards,

    Omer Amir