Hello all,
I have a basic question in embedded programming, hoping to get educated from the forum :)
I am using F28035 microcontroller and I have few calculations to be made in my code. This is how I am doing and please let me know if it is not the efficient way of doing.
Uint16 PWM_TIMER_TBPRD;
Uint16 PhaseLossResolution;
Uint16 SixtyDegUS;
Uint16 OneTwentyDegUS;
Uint16 RefPulseWidth;
void main(void)
{
//Initialize
PWM_TIMER_TBPRD = 1249;
PhaseLossResolution = 350;
SixtyDegUS = 2777; OneTwentyDegUS = 5555;
for(;;)
{ CalcVarFreq();
RefPulseWidth = 8333; //I get this value from eCAP module
}}
void CalcVarFreq()
{
SixtyDegUS = 0.3333*RefPulseWidth;
OneTwentyDegUS = 0.6666*RefPulseWidth;
PWM_TIMER_TBPRD = (0.15625*RefPulseWidth);
PhaseLossResolution = 0.04*RefPulseWidth;
}
Thanks in advance
Sandhya