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.
Hi,
I tried to use user manual example (above picture)
And run it via CCS using this code:
periodVal = EPWM_getTimeBasePeriod(EPWM1_BASE); regValCMPA = (int)(PWMDuty * periodVal); _temp = (PWMDuty * (float)(periodVal)); _temp = (__fracf32(_temp)) ; regValCMPAHR =( _temp * MEP_ScaleFactor + 0.5); regValCMPAHR = (regValCMPAHR ) << 8U; HWREG(EPWM1_BASE + HRPWM_O_CMPA) = (((long)regValCMPA) << 16U) | regValCMPAHR;
While debugging I got the following values that go to CMPA CMPAHR registers:
But when measuring D.C. with scope I got only 12.06% instead of 12.32% as shown on debug picture under PWMDuty expression.
And when I try manually increase CMPHR so D.C. will achieve 12.32% the max expression (0xff00) I got the above PWMDuty.
Maybe the code isnt implemeted well? attaching example from datasheet
I'll Apricate your help.
Michael
Hello Michael,
Apologies for the delayed response. Were you using the SFO library? If not, I would highly recommend doing so, it greatly simplifies the overall process of working with the HRPWM.
For the specific issue, take a look at the following code snippet from section 17.15.2.1 of the device TRM (which assumes the SFO library is being used):
At a glance, I'd note that you convert to long instead of uint32_t. What happens if you adjust your calculations to result in an unsigned int output?
Regards,
Jason Osborn