The documentation on the ePWM and HRPWM modules indicate that it is, but I can't get it to go.
The digital power library does not use high-resolution phase control in its example.
The first sign of trouble is that the SFO() call in my initialization routine leaves the HRMSTEP register zeroed and the variable MEP_ScaleFactor set to 0x7FFF. That's definitely not right.
My init routine looks like this:
#define PWMPERIOD (Uint16)((60000000UL + 100000UL / 2) / 100000UL)
#define DEADBAND 14
void InitializePWM(void)
{
// Initialize ePWM 1 and 2 as above.
EPwm1Regs.TBCTL.all = 0x801B;
EPwm1Regs.TBPRDM.all = (Uint32)(PWMPERIOD - 1) << 16;
EPwm1Regs.TBCTL.bit.PRDLD = 0;
EPwm1Regs.TBPRDM.all = (Uint32)(PWMPERIOD - 1) << 16;
EPwm1Regs.CMPCTL.all = 0x0010;
EPwm1Regs.CMPA.all = (Uint32)(PWMPERIOD / 2) << 16;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0;
EPwm1Regs.CMPA.all = (Uint32)(PWMPERIOD / 2) << 16;
EPwm1Regs.AQCTLA.all = 0x0012;
EPwm1Regs.DBRED = DEADBAND;
EPwm1Regs.DBFED = DEADBAND;
EPwm1Regs.DBCTL.all = 0x800B;
EPwm1Regs.ETSEL.all = 0x0009;
EPwm1Regs.ETPS.all = 0x0001;
EPwm2Regs.TBCTL.all = 0x800F;
EPwm2Regs.TBPRDM.all = (Uint32)(PWMPERIOD - 1) << 16;
EPwm2Regs.TBCTL.bit.PRDLD = 0;
EPwm2Regs.TBPRDM.all = (Uint32)(PWMPERIOD - 1) << 16;
EPwm2Regs.TBPHS.all = (Uint32)(PWMPERIOD - 1) << 16;
EPwm2Regs.CMPCTL.all = 0x0010;
EPwm2Regs.CMPA.all = (Uint32)(PWMPERIOD / 2) << 16;
EPwm2Regs.CMPCTL.bit.SHDWAMODE = 0;
EPwm2Regs.CMPA.all = (Uint32)(PWMPERIOD / 2) << 16;
EPwm2Regs.AQCTLA.all = 0x0012;
EPwm2Regs.DBRED = DEADBAND;
EPwm2Regs.DBFED = DEADBAND;
EPwm2Regs.DBCTL.all = 0x800B;
EPwm2Regs.TBCTL.all = 0x8004;
EPwm1Regs.TBCTL.all = 0x8010;
// Apply high-resolution control to the ePWM 2 phase.
EALLOW;
EPwm1Regs.HRCNFG.all = 0x0047;
EPwm1Regs.HRPCTL.all = 0x0001;
EPwm2Regs.HRCNFG.all = 0x0047;
EPwm2Regs.HRPCTL.all = 0x0005;
// Give ePWM 1 and 2 their A and B output pins.
GpioCtrlRegs.GPAMUX1.all =
GpioCtrlRegs.GPAMUX1.all & 0xFFFFFF00UL | 0x00000055UL;
// Set up our 'scope trigger pulse output.
GpioDataRegs.GPBSET.bit.GPIO34 = 1;
GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
GpioCtrlRegs.GPBPUD.bit.GPIO34 = 1;
// Start the ePWM system timebase.
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
EDIS;
// Do the initial calibration on the HRPWM system.
while (SFO() == SFO_INCOMPLETE);
}
After that, the fractional part of the ePWM 2 phase is completely inoperative.
Am I doing something wrong? If so, what? Or do I have to settle for 300-step resolution in the phase here?
Thanks in advance for the help.