Hi team,
We are trying to demonstrate ePWM synchronization, but can not confirm it’s synch. Could you please check attached code, and tell us where to modify?
We are using EVM, CCS and one-shot function. The operation is as described below.
- Linked PWM1~PWM4, and set PWM4 as master:
- Set PWM1 (*EPWMR[i]).CMPB.all -> 500, PWM2 (*EPWMR[i]).CMPB.all -> 300, PWM3 (*EPWMR[i]).CMPB.all -> 500 and PWM4 (*EPWMR[i]).CMPB.all -> 350.
Then, the PWM1/PWM2/PWM3 value became 500/300/500, respectively. Which I believe contradicts with the the technical reference manual.
void pwm_init()
{
/* i=0�`4�A0��PWM1�A1��PWM2�A2��PWM3�A3��PWM4�A4��PWM4 */
EALLOW;
for (i = 0U; i < 4; i ++) {
(*EPWMR[i]).EPWMXLINK.bit.GLDCTL2LINK = pwm_master_no_uh[j];
(*EPWMR[i]).EPWMXLINK.bit.TBPRDLINK = pwm_master_no_uh[j];
}
for (i = 0U; i < 4; i ++) {
(*EPWMR[i]).GLDCTL.all = (1U<<5)|(1U<<1)|(1U);
(*EPWMR[i]).GLDCFG.all = (1U<<8)|(1U<<6)|(1U<<5)|(1U<<2)|(1U<<1)|(1U);
}
(*EPWMR[4U]).GLDCTL2.bit.OSHTLD = 1U; /* *set EPWMR[4U] master */
EDIS;
}
void pwm_set_param()
{
(*EPWMR[4U]).TBPRD = (UINT16)(B_PERIOD>>16);
(*EPWMR[4U]).TBPRDHR = (UINT16)(B_PERIOD & 0xffffUL);
for (i = 0U; i < 4; i ++) {
(*EPWMR[i]).CMPB.all = B_CMPB[i];
(*EPWMR[i]).CMPA.all = B_CMPA[i];
(*EPWMR[i]).DBRED.all = B_DEADT[i];
(*EPWMR[i]).DBFED.all = B_DEADT[i]);
(*EPWMR[i]).DBREDHR.all =B_DEADT[i];
(*EPWMR[i]).DBFEDHR.all =B_DEADT[i];
}
(*EPWMR[4U]).GLDCTL2.bit.OSHTLD = 1U;
}
(It might show garbled text on the browser. Please download the file to see how it actually looks like)
Best regards,
Kurumi