Hello,
I have a solution which uses 3 ePWM modules to generate 3 PWM signals with same frequency and same duty cycle. The ePWM modules are configured to be phase-shifted to each other in the following way:
- ePWM8 has no phase shift relative to main synchronization
- ePWM6 has 8 sysclocks phase shift relative to ePWM8
- ePWM4 has 16 sysclocks phase shift relative to ePWM6
ePWM8 is configured has high-resolution.
Rest of the configuration for all 3 ePWM modules is the same. The only difference is the phase as described above.
EPwmxRegs.TBPRD = 224U;
EPwmxRegs.CMPB = 112U;
EPwmxRegs.TBPHS.half.TBPHS = phase;
EPwmxRegs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
EPwmxRegs.TBCTL.bit.PHSEN = TB_ENABLE;
EPwmxRegs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwmxRegs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN;
EPwmxRegs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwmxRegs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwmxRegs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwmxRegs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwmxRegs.CMPCTL.bit.LOADAMODE = CC_CTR_PRD;
EPwmxRegs.CMPCTL.bit.LOADBMODE = CC_CTR_PRD;
EPwmxRegs.AQCTLB.bit.ZRO = AQ_SET;
EPwmxRegs.AQCTLB.bit.CBU = AQ_CLEAR;
EPwmxRegs.AQCTLB.bit.PRD = AQ_NO_ACTION;
During normal operation, everything is working excellent. However, my intention is to change the frequency and duty-cycle during runtime. For this I am using an ISR triggered when ePWM4 TBCTR == 0. Within the ISR, I am changing values of TBPRD and CMPB of all ePWM modules. With the phase-shift disabled, the functionality is working well - I can see the frequency changing for all 3 signals. However, if I enable the phase-shift, then I see 100% duty cycle on ePWM8, for ePWM4 and ePWM6 the frequency remains constant at ~401kHz as defined with the initial configuration.
As far as I understood from the initial reply, changing the frequency should be as simple as changing TBPRD value within the period also when the phase shift is enabled.
I also tried different triggers for the ISR, such as TBCTR == 0, TBCTR == PRD with both ePWM6 and ePWM8.
Do you have any idea what might be wrong? Any kind of support would be appreciated.
Looking forward to your reply and thanks in advance!
Regards,
Lev