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: Problem with float math calculation

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

I'm using a TM320F28379D.
I have a problem with a float calculation on this device.

I have a variable 

float32_t Ic_inst=0.0;
float32_t Vc_prev=0.0;

float32_t rec_vS_inst_pu=0;

I am using these variables in the code block of an interrupt function at 10us;

__interrupt void ControlISR(void) {

Ic_inst = (rec_vS_inst_pu - Vc_prev)*5.0f; 
Vc_prev = rec_vS_inst_pu;

}

Ic_inst= 9.83431262e-42 (DEN) - strange value

There is an overflow, but don't I understand why this is happening? can you help me with this?

  • Hello Enes,

    What FPU configuration have you set in the Processor Options of the Project Properties? Please step through the assembly code using the Disassembly window in the debug session, this is the best wait to find out why the operation is not being set properly (i.e. if a particular register is being loaded with an incorrect value). You will need to debug the assembly code before proceeding further.

  • Hi Omer, I'm using FPU32,

    in this code ;
    "Ic_inst=((rec_vS_inst_pu - Vc_prev)*5.0f;
    Vc_prev=rec_vS_inst_pu;"
    When the previous value of the variable rec_vS_inst_pu, i.e. vc_prev, is very close to the instant value, the result turns out to be close to zero, I think that's why I'm encountering this problem, for example, when I increase the instant value by 200 times and process, I don't get an error in the code.
    "Ic_inst=(((rec_vS_inst_pu*200.0f)- Vc_prev)*5.0f;
    Vc_prev=rec_vS_inst_pu; "

    i also get an error like this when I process with float64_t on the processor "#1558-D 64-bit floating point operations are not allowed" 

  • Hello Enes,

    When the previous value of the variable rec_vS_inst_pu, i.e. vc_prev, is very close to the instant value, the result turns out to be close to zero, I think that's why I'm encountering this problem

    Yes, if you subtract two floating-point values which are very close to each other (in floating-point it's difficult to get values that are identical because of the nature of the floating-point standard), then you will get something close to zero.

    i also get an error like this when I process with float64_t on the processor "#1558-D 64-bit floating point operations are not allowed" 

    You need to verify that any libraries you using within your project (such as driverlib, FPUfastRTS, etc.) are all including the FPU32 version of the library or are libraries built with the FPU32 configuration. You can check this by opening the CCS project for the library (for driverlib, this is in C2000Ware_5_02_00_00\driverlib\f2837xd\driverlib\ccs).