Hi,
I'm working with the TMS320F2809 microcontroller and I have some question about the HRPWM module.
First of all, I tried the Example_280xHRPWM_SFO_V5.c. It seem's to bo working.
In my case, I'm using the TBPHS instead of CMPA register.
I read the datasheet spru924f, more exactly in page 15/42. We can see how to calculate both registers.
So, if we follow this example :
1)
MEP_ScaleFactor = 55
PWMDuty = 99,1896/180 = 0,551053
PWMperiod = 715
CMPA = PWMDuty*PWMperiod = 394
CMPAHR = (frac(PWMDuty*PWMperiod)*MEP_ScaleFactor +1.5) << 8) = (frac(0,551053 * 715)*55 +1.5) *256) = (0,0031333*55 +1.5) *256) = 428 = 0x1AC (lower 8 bits will be ignored by hardware)
CMPAHR = 0x100 = 256
(*ePWM[i]).CMPA.all = ((long)CMPA_reg_val)<<16 | CMPAHR_reg_val; = 394*65536 + 256 = 25821440
2)
MEP_ScaleFactor = 55
PWMDuty = 99,1882/180 = 0,551045 (this angle is the nearest from the 1) example)
PWMperiod = 715
CMPA = PWMDuty*PWMperiod = 393
CMPAHR = (frac(PWMDuty*PWMperiod)*MEP_ScaleFactor +1.5) << 8) = (frac(0,551045 * 715)*55 +1.5) *256) = (0,9975722*55 +1.5) *256) = 14429 = 0x385D (lower 8 bits will be ignored by hardware)
CMPAHR = 0x3800 = 14336
(*ePWM[i]).CMPA.all = ((long)CMPA_reg_val)<<16 | CMPAHR_reg_val; = 393*65536 + 14436 =25770084
The difference between these two points makes me some trouble. (25821440 - 25770084= 51356).
I implemented these equation on Excel. My duty is linear but CMPA.all is not. May be it's normal.
But in my case, I can see a gap with the duty when there is a change in CMPA register.
Below an evolution of CMPA.all register in function of the angle (duty).
In red this is exactly what it's written in the datasheet.
We can see the gap I'm talking about and I can see it in my system.
Is there any explaination?
Thank you so much
| PWMDuty |