Thanks for looking at this...
I have working hw and sw, and want to add 4 new PWMs to the existing one. ePWM1B is currently configured and working. I'm trying to add ePWM2A and others.
Using the 80 pin part, ePWM1 is configured to use pin 68. It's setup by a call to the following function from main():
void InitEPwm1BGpio(void)
{
EALLOW;
/* Disable internal pull-up for the selected output pins
for reduced power consumption */
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1;
/* Configure EPWM-1 pins using GPIO regs*/
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1;
EDIS;
}
So, I have duplicated this function (shown below) along with an appropriate call from main():
void InitEPwm2AGpio(void)
{
EALLOW;
/* Disable internal pull-up for the selected output pins
for reduced power consumption */
GpioCtrlRegs.GPAPUD.bit.GPIO2 = 1;
/* Configure EPwm-2 pins using GPIO regs*/
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1;
EDIS;
}
I can see in the memory browser that the above are working as expected. The settings are finding there way into the correct memory locations.
The problem I'm having is with the next step of the setup process.
ePWM1B is being setup in the following function called from main() after the above functions have completed their jobs:
void InitEPwm(Uint16 period)
{
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_HSP_DIV1;
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
EPwm1Regs.TBPHS.all = 0;
EPwm1Regs.TBCTR = 0;
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;
/*
* PWM Frequency = TBCLK / (1 + TBPRD)
*/
EPwm1Regs.TBPRD = period;
EPwm1Regs.CMPB = period/2;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.AQCTLB.bit.ZRO = AQ_SET;
EPwm1Regs.AQCTLB.bit.CBU = AQ_CLEAR;
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_HSP_DIV1;
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
EPwm2Regs.TBPHS.all = 0;
EPwm2Regs.TBCTR = 0;
EPwm2Regs.TBCTL.bit.PHSEN = TB_DISABLE;
EPwm2Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm2Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE;
/*
* PWM Frequency = TBCLK / (1 + TBPRD)
*/
EPwm2Regs.TBPRD = period;
EPwm2Regs.CMPB = period/2;
EPwm2Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm2Regs.AQCTLB.bit.ZRO = AQ_SET;
EPwm2Regs.AQCTLB.bit.CBU = AQ_CLEAR;
}
By single stepping through this function, I confirmed that the values being inserted in the ePWM1B structure are making it where they belong, as expected.
Here's where I'm getting lost; as I single step through the lines that should be updating the ePWM2A structure, the values remain unchanged. They seem to begin life with all zeros, and when a line of code asserts a change from zero to '3', as is the case with "EPwm2Regs.TBCTL.bit.SYNCOSEL= TB_SYNC_DISABLE;", the change is ignored. The value of "EPwm2Regs.TBCTL.bit.SYNCOSEL" remains zero. (The constant 'TB_SYNC_DISABLE" is defined as 3.)
I've tried using ePWM7A, and had the same results. I thought those registers might be in protected memory, but I couldn't find any documentation saying that. I tried enclosing them in EALLOW & EDIS, but it didn't help.
Is there is different way to setup an 'A' PWM versus a 'B'? I'm trying to use the 'A's, because frequency control may need the higher resolution.
I feel like I'm making an amateur mistake, but I'm just not seeing it.
Can someone help me?
Thanks,
robin