I have configured several EPWM channels for 20 kHz operation. These are being synchronized with a common PWM sync output . The setting of the synchronizing EPWM i.e. EPWM6 and one of the synchronized EPWM i.e EPWM1 are shown below:
void Device_initEPWM1(void) { EPWM_setTripZoneAction(EPWM1_BASE, EPWM_TZ_ACTION_EVENT_TZA, EPWM_TZ_ACTION_LOW); EPWM_setTripZoneAction(EPWM1_BASE, EPWM_TZ_ACTION_EVENT_TZB, EPWM_TZ_ACTION_LOW); initEPWMWithoutDB(EPWM1_BASE, complementary); setupEPWMActiveHighComplementary(EPWM1_BASE, 100, 100); EPWM_setPhaseShift(EPWM1_BASE, 2500U); //180 degree phase shift EPWM_enablePhaseShiftLoad(EPWM1_BASE); //enabling phase shift EPWM_setSyncInPulseSource(EPWM1_BASE, EPWM_SYNC_IN_PULSE_SRC_SYNCOUT_EPWM6); //PWM1 is synchronized with PWM6 }
void Device_initEPWM6(void) { EPWM_setADCTriggerSource(EPWM6_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_ZERO); EPWM_setADCTriggerEventPrescale(EPWM6_BASE, EPWM_SOC_A, 2); //Trigger on every second event EPWM_enableADCTrigger(EPWM6_BASE, EPWM_SOC_A); initEPWMWithoutDB(EPWM6_BASE, independent); EPWM_enableSyncOutPulseSource(EPWM6_BASE, EPWM_SYNC_OUT_PULSE_ON_CNTR_ZERO); }
There is a control ISR that is executing at 10 kHz. The control ISR execution is also linked to EPWM6 start of cycle. Basically EPWM6 is triggering ADC SOC and then ADC SOC triggers control ISR. The setting is such that every second ADC SOC triggers control ISR. So there should be two PWM cycles between two consecutive control ISR calls. It was expected that the duty cycle of two PWM periods should be same as the period update takes place in the control ISR that is executing at half the speed of the PWM cycle. However we are seeing that duty cycle has an intermediate transition between the two control ISR set values. For e.g. we set 10% duty cycle and 20 percent duty cycle in every consecutive ISR call. When checking on the oscilloscope we see duty cycles as 10% ,14%, 20% ,14%. So the first value is correct, there is an unexpected intermediate value of 14 % and then correct update of 20% and again another unexpected value of 14%. Ideally it should be 10%,10%,20%,20. Please let me know if more details are required and possible solutions to overcoming this issue,