Other Parts Discussed in Thread: CONTROLSUITE
Hello,
I'm trying to synchronize, at diferent frequencies, ePWM3 and ePWM4 modules on F28027 Piccolo without success.
I've been searching on the internet as well as on TI Forum for solutions, namely I was following an example from this post http://e2e.ti.com/support/microcontrollers/c2000/f/171/p/273846/985435.aspx
but I'm still not able to synchronize the PWM outputs.
I am running out of ideas to solve this issue.. I noticed that synchronization examples are always between ePWM1 and others, can I synchronize ePWM3 with ePWM4? (Being the ePWM3 the master, ePWM4 the slave and Switching freq3 > Switching freq4).
My code is as follows:
/************************************************************************
***** PWM Configuration *****
************************************************************************/
void InitEPwmx(){
CLK_disableTbClockSync(myClk);
// Enable PWM clocks
CLK_enablePwmClock(myClk, PWM_Number_3);
CLK_enablePwmClock(myClk, PWM_Number_4);
// Setup TBCLK
PWM_setPeriod(myPwm3, EPWM3_TIMER_TBPRD); // Set timer period PWM3
PWM_setPeriod(myPwm4, EPWM4_TIMER_TBPRD); // Set timer period PWM4
PWM_setPhase(myPwm3, 0x0000); // Phase is 0 PWM3
PWM_setPhase(myPwm4, 0x0000); // Phase is 0 PWM4
PWM_setCount(myPwm3, 0x0000); // Clear counter PWM3
PWM_setCount(myPwm4, 0x0000); // Clear counter PWM4
PWM_setCounterMode(myPwm3, PWM_CounterMode_Up); // Count up/down
PWM_setCounterMode(myPwm4, PWM_CounterMode_Up); // Count up/down
PWM_disableCounterLoad(myPwm3); // Disable phase loading
PWM_disableCounterLoad(myPwm4); // Disable phase loading
PWM_setHighSpeedClkDiv(myPwm3, PWM_HspClkDiv_by_1); // Clock ratio to SYSCLKOUT
PWM_setHighSpeedClkDiv(myPwm4, PWM_HspClkDiv_by_1); // Clock ratio to SYSCLKOUT
PWM_setClkDiv(myPwm3, PWM_ClkDiv_by_1);
PWM_setClkDiv(myPwm4, PWM_ClkDiv_by_1);
PWM_setSyncMode(myPwm3,PWM_SyncMode_CounterEqualZero); // Sets PWM3x as the Master
PWM_setSyncMode(myPwm4,PWM_SyncMode_EPWMxSYNC); // Sets PWM4x as the Slave
// Setup shadow register load on ZERO
PWM_setShadowMode_CmpA(myPwm3, PWM_ShadowMode_Shadow); // Load registers every zero
PWM_setShadowMode_CmpB(myPwm3, PWM_ShadowMode_Shadow);
PWM_setLoadMode_CmpA(myPwm3, PWM_LoadMode_Zero);
PWM_setLoadMode_CmpB(myPwm3, PWM_LoadMode_Zero);
PWM_setShadowMode_CmpA(myPwm4, PWM_ShadowMode_Shadow); // Load registers every zero
PWM_setShadowMode_CmpB(myPwm4, PWM_ShadowMode_Shadow);
PWM_setLoadMode_CmpA(myPwm4, PWM_LoadMode_Zero);
PWM_setLoadMode_CmpB(myPwm4, PWM_LoadMode_Zero);
// Set Actions
PWM_setActionQual_Zero_PwmA(myPwm3, PWM_ActionQual_Set); // Set PWM3A on period
PWM_setActionQual_CntUp_CmpA_PwmA(myPwm3, PWM_ActionQual_Clear); // Clear PWM3A on event A, up count
PWM_setActionQual_Zero_PwmB(myPwm3, PWM_ActionQual_Clear); // Clear PWM3B on period
PWM_setActionQual_CntUp_CmpA_PwmB(myPwm3, PWM_ActionQual_Set); // Set PWM3B on event B, up count
PWM_setActionQual_Zero_PwmA(myPwm4, PWM_ActionQual_Set); // Set PWM4A on period
PWM_setActionQual_CntUp_CmpA_PwmA(myPwm4, PWM_ActionQual_Clear); // Clear PWM4A on event A, up count
// Set Compare values
PWM_setCmpA(myPwm3, EPwm3MinCMPA); // Set compare A value PWM3
PWM_setCmpA(myPwm4, EPwm4CMPA); // Set compare A value PWM4
CLK_enableTbClockSync(myClk); // Re-Allow the timer clock to sync to system clock, start counting!
}
Any idea of the problem?
Thanks in advance.
Mário
