Hi TI experts,
I have a below requirement to synchronize the ePWMs for one of my application.I am using MCU - TMS320F28069.
ePWM 4 (master) // act as Sync down-stream module
ePWM 6 (slave) // act as sync flow-through module
ePWM 1 (slave) // act as sync flow-through module
The code segment for initialization is shown below.I just followed Time-Base Counter Synchronization
Scheme 1 as per application note for TMS320F28069 MCU.
void InitEPwm4(void)
{
EALLOW;
EPwm4Regs.TBPRD = 3600; // Set timer period
EPwm4Regs.CMPA.half.CMPA =1800;
EPwm4Regs.CMPB =400;
EPwm4Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm4Regs.TBCTR = 0x0000; // Clear counter
EPwm4Regs.TBCTL.bit.PHSEN = 0 ;
// Setup TBCLK
EPwm4Regs.TBCTL.bit.CTRMODE = 0; // Count up
EPwm4Regs.TBCTL.bit.PRDLD = 0;
EPwm4Regs.TBCTL.bit.SYNCOSEL = 1; // setup Sync down-stream module
EPwm4Regs.TBCTL.bit.HSPCLKDIV = 0; // Clock ratio to SYSCLKOUT
EPwm4Regs.TBCTL.bit.CLKDIV = 0;
EPwm4Regs.CMPCTL.bit.SHDWAMODE = 0; // Load registers every ZERO
EPwm4Regs.CMPCTL.bit.SHDWBMODE = 0;
EPwm4Regs.CMPCTL.bit.LOADAMODE = 0;
EPwm4Regs.CMPCTL.bit.LOADBMODE = 0;
// Set actions
EPwm4Regs.AQCTLA.bit.ZRO = 1; // set actions for EPWM1A
EPwm4Regs.AQCTLA.bit.CAU = 2;
EPwm4Regs.AQCTLB.bit.PRD = 1; // set actions for EPWM1B
EPwm4Regs.AQCTLB.bit.CBD = 2;
EDIS;
}
void InitEPwm6(void)
{
EALLOW;
EPwm6Regs.TBPRD = 1800; // Set timer period
EPwm6Regs.CMPA.half.CMPA =400;
EPwm6Regs.CMPB =400;
EPwm6Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm6Regs.TBCTR = 0x0000; // Clear counter
EPwm6Regs.TBCTL.bit.PHSEN = 1 ;
// Setup TBCLK
EPwm6Regs.TBCTL.bit.CTRMODE = 0; // Count up
EPwm6Regs.TBCTL.bit.PRDLD = 0;
EPwm6Regs.TBCTL.bit.SYNCOSEL = 0; // setup sync flow-through
EPwm6Regs.TBCTL.bit.HSPCLKDIV = 0; // Clock ratio to SYSCLKOUT
EPwm6Regs.TBCTL.bit.CLKDIV = 0;
EPwm6Regs.CMPCTL.bit.SHDWAMODE = 0; // Load registers every ZERO
EPwm6Regs.CMPCTL.bit.SHDWBMODE = 0;
EPwm6Regs.CMPCTL.bit.LOADAMODE = 0;
EPwm6Regs.CMPCTL.bit.LOADBMODE = 0;
// Set actions
EPwm6Regs.AQCTLA.bit.ZRO = 1; // set actions for EPWM1A
EPwm6Regs.AQCTLA.bit.CAU = 2;
EPwm6Regs.AQCTLB.bit.PRD = 1; // set actions for EPWM1B
EPwm6Regs.AQCTLB.bit.CBD = 2;
EDIS;
}
void InitEPwm1(void)
{
EALLOW;
// Enter Period value
EPwm1Regs.TBPRD = 1800; // Set timer period
EPwm1Regs.CMPA.half.CMPA =400;
EPwm1Regs.CMPB =400;
EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm1Regs.TBCTR = 0x0000; // Clear counter
EPwm1Regs.TBCTL.bit.PHSEN = 1 ;
// Setup TBCLK
EPwm1Regs.TBCTL.bit.CTRMODE = 0; // Count up
EPwm1Regs.TBCTL.bit.PRDLD = 0;
EPwm1Regs.TBCTL.bit.SYNCOSEL = 0; // setup sync flow-through
EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = 0;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0; // Load registers every ZERO
EPwm1Regs.CMPCTL.bit.SHDWBMODE = 0;
EPwm1Regs.CMPCTL.bit.LOADAMODE = 0;
EPwm1Regs.CMPCTL.bit.LOADBMODE = 0;
// Set actions
EPwm1Regs.AQCTLA.bit.ZRO = 1; // set actions for EPWM1A
EPwm1Regs.AQCTLA.bit.CAU = 2;
EPwm1Regs.AQCTLB.bit.PRD = 1; // set actions for EPWM1B
EPwm1Regs.AQCTLB.bit.CBD = 2;
EDIS;
}
//*******************//
The ePWM modules 4 & 6 are perfectly synchronized with two different frequencies whereas 4 & 1 is not working.It is noticed that both PWMs are starting at the same edges.
But ePWM 1 module is not synchronised with ePWM 4.The PWM frequencies of modules ePWM6 & ePWM1 are same & different from ePWM4(master).
Is it due to the fact that the ePWM 1 module can not be set as sync flow-through
while ePWM 4 acts as Sync down-stream module as per above code ?
Pls suggest any corrections so as to sync ePWM 4 & ePWM 1 modules.
Thanks & regards,
Ramesh P