Part Number: TMS320F28377D
Hello,
I'm trying to implement HRPWM capabilities in F28337D. In order to understand it, I tried to compare Autoconversion mode results and manual conversion results, but it seems to be different. Why do I get different results for CMPA and CMPAHR registers enabling or not autoconversion mode? I tried with the example of TI (hrpwm_duty_sfo_v8.c) and I also get these different results:
DutyFine = 0x5737
EPwm1Regs.TBPRD = 9
MEP_ScaleFactor = 64 (it is calculated by SFO)
With autoconversion mode enabled I get:
EPwm1Regs.CMPA.bit.CMPA=0x6
EPwm1Regs.CMPA.bit.CMPAHR=0x2100
With manual mode enabled I get:
EPwm1Regs.CMPA.bit.CMPA=0x6
EPwm1Regs.CMPA.bit.CMPAHR=0x0800
For manual conversion, I see that the example of TI for F28379D (hrpwm_duty_sfo_v8.c) says:
COMMENTS:
** If auto-conversion is enabled, the following step is performed
automatically in hardware and can be skipped
// Add the offset and rounding
CMPAHR_reg_val += 0x0080;
However, in the TI code below I can't see this offset and rounding. In the Technical Reference Manual, in fact, it doesn't appear either, so I don't know if it's a mistake of the example or not.
CODE:
#if (AUTOCONVERT) CMPAHR_reg_val = temp<<1; // convert to Q16 CMPBHR_reg_val = temp<<1; // convert to Q16 #else CMPAHR_reg_val = ((temp*MEP_ScaleFactor)+(0x0080<<7))>>15; CMPAHR_reg_val = CMPAHR_reg_val << 8; CMPBHR_reg_val = ((temp1*MEP_ScaleFactor)+(0x0080<<7))>>15; CMPBHR_reg_val = CMPBHR_reg_val << 8; #endif
So, it is necessary to add 0x0080 for offset and rounding or not? And why do I get different results for both modes?
Thank you!
Maite