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.

CCS/TMS320F28377S: version 7

Part Number: TMS320F28377S

Tool/software: Code Composer Studio

I am writing a motor control code. One of the lines in the code can result in a division by zero. I never encountered any error due to this. I would like to know how this is taken care by CCS.

I encountered "division by zero" error when I did the simulation of the algorithm in simulink.

Please update me on the issue.

Thanks a lot !

  • Shyam,

    If you are using the TMU to perform division, results which under-flow or over-flow the floating-point format will set the LUF or LVF flag respectively. You should enable PIE interrupts 12.7 & 12.8 in your code to trap and handle such events in a controlled way.

    See p.393 of this UG for the DIV32 instruction description:
    www.ti.com/.../spruhs1a.pdf

    The LUF/LVF flags are described on p.17 of the FPU UG:
    www.ti.com/.../sprueo2b.pdf

    Regards,

    Richard
  • Thanks for the reply. Could you please expand TMU. I dont think i am using that. Also, I dont see any maloperation due to a division by zero as far as the motor performance is concerned.
  • Shyam,

    Sure. The device you're using has a TMU (Trigonometric Math Unit) which extends the C28x instruction set with several math operations, including floating-point division. You can instruct the compiler to generate TMU compatible code by setting the --tmu_support=tmu0 compiler switch.

    In CCS, right-click on the project in the Project Explorer window, then select "C2000 Compiler -> Processor Options". I wasn't sure if you are using fixed or floating point, or whether the TMU was enabled. My guess is you are using floating-point with the TMU enabled, in which case the LVF/LUF interrupts will trap this situation.

    Regards,

    Richard
  • I verified that i am using floating point and TMU. I am pretty sure that division by zero is happening when i run my code. But why is it that there is no abnormality in the waveforms that I see in the scope. Or is it that LVF/LUF interrupts are doing something to overcome this. Thanks for your time.
  • Shyam,

    By default, once enabled the LVF/LUF ISRs will just execute an ESTOP instruction which halts program execution. You should first edit those ISRs in the file "F2837xS_DefaultISR.c" to handle the events in an appropriate way. I guess the result could have been more serious.

    Regards,

    Richard
  • I tried the following code:

    float c1=1,c2=0,c3;
    c3=c1/c2;
    c4=atan2(1,c3);

    I see the value of c3 in the watch window as 3.38953139e+38, and c4 as 0.

    The program was not halted and it continued to run.

    Division of two AC signal quantities is common in motor control, which means that division by zero (or very close to zero) happens. But i am not sure whether they edit the file "F2837xS_DefaultISR.c" to prevent halting the program. (Of course, thats the right way to go about !).