I am analyzing the hrpwm_ex1_duty_sfo example code.
CMPAHR = (fraction(PWMduty * PWMperiod) * MEP Scale Factor + 0.5)<<8)
know as
When Auto-conversion Mode is enabled
Known as CMPAHR = fraction(PWMduty*PWMperiod)<<8.
So if I want to pay 40.5 duty
int(PWMDuty*PWMPeriod) to CMPA register
CMPAHR register is frac(PWMDuty*PWMPeriod)<<8
I think you should put it in.
However, in the example
float32_t count = (dutyFine * (float32_t)(EPWM_TIMER_TBPRD << 8))/100;
uint32_t compCount = (count);
HRPWM_setCounterCompareValue(ePWM[i], HRPWM_COUNTER_COMPARE_A, compCount);
float32_t count = (dutyFine * (float32_t)(EPWM_TIMER_TBPRD << 8))/100;
I don't understand this equation. I think I just need to put in the decimal value of the duty, but I don't understand how to adjust the duty with the same code.