Hi There,
I am a new comer here. I just want to know few things those are really hard to track down.I am trying to debug a existing F/W code mostly written in c or c++. This IDE and compiler is from a particular DSP/MCU company. This code is a complex one and F/W and S/W mixed together. Some codes are not even understandable because I have very limited knowledge in syntax, pointer datatype and flags etc.Manuals and examples can give some ideas.
Now lets talk a specific problem, .c file includes some dependencies like those are customized,made for particular reason
Code:
#include "DSP28x_Project.h"
#include "Register.h"
#include "CLA.h"
#include "LED.h"
From CLA (Control Law Accelerator? library of TI external VOID function with macro has called to compare some reference value of particular parameter. here we go,
Code:
__interrupt void Cla1Task2 ( void )
{
float Err;
Register[ADC_7] = AdcResult.ADCRESULT7;// this is from instructional manual that specified the ADC result location
Bf7();// this is a function works for some float variables
Current_T_ch2 = ADC_VAL(Register[ADC_FILT_7], Register[ADC_ZERO_7], Register[ADC_SCALE_7]);// ADC_VAL is defined somewhere
Current_T_ch2 = Current_T_ch2 < 0 ? 0 : Current_T_ch2;
if(Tartget_B2 > 0)
{
Err = Tartget_B2 - Current_T_ch2;// target B2 is also a register.
B_Ref2 += PKP2 * (Err - Err_B_P2) + PKI2 * Err;// PKI2 is defined in a register file
Err_B_P2 = Err;
B_Ref2 = B_Ref2 > 0.35 ? 0.35 : (B_Ref2 < 0 ? 0 : B_Ref2);// this one is not understandable
}
}
Let me know the mathematical reasoning like, x= x>0.35 ? 0.35 : ( x<0 ? 0 : x);
How ?, : is meaning full? How does compiler read and think? if x> 0.35 then how the condition applies for x<0