2017-10-22 10:16 PM
Hi ST experts!
I have worked on phase shift full-bridge converter projects.
Recently, I get a trouble with synchronous rectifier PWM. The PWM duty, frequency, and deadtime parts work well, but they can't not shift properly.
There is my code to configure PWM.
- PWM0 is configured by Timer 3 channel 0
ETIMER_3.CH[0].CNTR.R = pwmA.deadTime1;
ETIMER_3.CH[0].LOAD.R = 0U;//tung addedETIMER_3.CH[0].CTRL1.B.CNTMODE = 1U; /* count rising edge of primary source */
ETIMER_3.CH[0].CTRL1.B.PRISRC = 0x18U; /* primary count source = IP bus clock/2 */ETIMER_3.CH[0].CTRL1.B.ONCE = 0U; /* count repeatedly */ETIMER_3.CH[0].CTRL1.B.LENGTH = 1U; /* count until compare and reinitialize */ETIMER_3.CH[0].CTRL1.B.DIR = 0U; /* count up */ETIMER_3.CH[0].CTRL2.B.OEN = 1U; /* output enable */ETIMER_3.CH[0].CTRL2.B.RDNT = 0U; /* disable redundant channel */ETIMER_3.CH[0].CTRL2.B.OPS = 0U; /* Inverted polarity */ETIMER_3.CH[0].CTRL2.B.OUTMODE = 4U; /* Set on COMP1, clear on COMP2 */
ETIMER_3.CH[0].CTRL3.B.STPEN = 1U; /* output disabled in stop mode */ETIMER_3.CH[0].CTRL3.B.DBGEN = 1U;ETIMER_3.CH[0].CCCTRL.B.CMPMODE = 0U;ETIMER_3.CH[0].CCCTRL.B.CLC2 = 5U; /* load CNTR with CMPLD2 on COMP2 match */ETIMER_3.CH[0].CMPLD2.R = (pwmA.duty-pwmA.deadTime1);ETIMER_3.CH[0].COMP1.R = (pwmA.period - (pwmA.duty-pwmA.deadTime1));ETIMER_3.CH[0].COMP2.R = (pwmA.duty-pwmA.deadTime1);ETIMER_3.CH[0].CCCTRL.B.CLC1 = 2U; /* load COMP1 with CMPLD1 on COMP2 match */ETIMER_3.CH[0].CMPLD1.R = (pwmA.period - (pwmA.duty-pwmA.deadTime1));- PWM2 (rectifier pwm)is configured by Timer 3 channel 2
ETIMER_3.CH[2].CNTR.R = pwmA.deadTime1;
ETIMER_3.CH[2].LOAD.R = 0U;//tung addedETIMER_3.CH[2].CTRL1.B.CNTMODE = 1U; /* count rising edge of primary source */
ETIMER_3.CH[2].CTRL1.B.PRISRC = 0x18U; /* primary count source = IP bus clock/2 */ETIMER_3.CH[2].CTRL1.B.ONCE = 0U; /* count repeatedly */ETIMER_3.CH[2].CTRL1.B.LENGTH = 1U; /* count until compare and reinitialize */ETIMER_3.CH[2].CTRL1.B.DIR = 0U; /* count up */ETIMER_3.CH[2].CTRL2.B.OEN = 1U; /* output enable */ETIMER_3.CH[2].CTRL2.B.RDNT = 0U; /* disable redundant channel */ETIMER_3.CH[2].CTRL2.B.OPS = 0U; /* Inverted polarity */ETIMER_3.CH[2].CTRL2.B.OUTMODE = 4U; /* Set on COMP1, clear on COMP2 */
ETIMER_3.CH[2].CTRL3.B.STPEN = 1U; /* output disabled in stop mode */ETIMER_3.CH[2].CTRL3.B.DBGEN = 1U;ETIMER_3.CH[2].CCCTRL.B.CMPMODE = 0U;ETIMER_3.CH[2].CCCTRL.B.CLC2 = 5U; /* load CNTR with CMPLD2 on COMP2 match */ETIMER_3.CH[2].CMPLD2.R = (pwmA.duty-pwmA.deadTime1);ETIMER_3.CH[2].COMP1.R = (pwmA.period - (pwmA.duty-pwmA.deadTime1));ETIMER_3.CH[2].COMP2.R = (pwmA.duty-pwmA.deadTime1);ETIMER_3.CH[2].CCCTRL.B.CLC1 = 2U; /* load COMP1 with CMPLD1 on COMP2 match */ETIMER_3.CH[2].CMPLD1.R = (pwmA.period - (pwmA.duty-pwmA.deadTime1));- To shift PWM 2 from PWM 0, I use a Timer interrupt. The shift value is updated in interrupt function like this
void SPC5_ETIMER3_TC2IR_HANDLER(void)
{shift = pwmB.phaseShift - pwmB.phaseShiftActive;pwmB.phaseShiftActive = pwmB.phaseShift;ETIMER_3.CH[2].CMPLD1.R = (pwmB.period-1) + shift;
ETIMER_3.CH[2].STS.R = 0x3FFU; /* clear interrupt flag */
}
=> How I can configure PWM to create phase shift for 1 or multiple channels by SPC570S-DISP?
Thank you so much.
https://drive.google.com/open?id=0B3tbtuzuEA6Ia3dJaXMwR28wZ1k
#automotive #spc570s2017-10-24 01:13 AM
Yvin.Erwan
: Hi Erwan Can you suggest me some ideas for this problem?2017-10-24 02:02 AM
Hello Tran ,
I am checking with experts.
Often , there are some examples on the Reference manual
Best regards
Erwan
2017-10-25 01:15 AM
Hello Tran ,
Did you try to disable the timer before shifting the phase ?
Best regards
Erwan
2017-10-25 08:03 PM
Hello
Yvin.Erwan
Thank you so much for quick reply!
In my program, I haven't used ENBL register before shifting the phase.
Is it require whenever we want to update the counting number in COMP1 or COMP2 registers?
Best regards;
Tran Hung.
2017-10-26 03:14 AM
No Tran , in fact it is not required.
i will give you a feedback from our experts as soon as possible
Best Regards
Erwan
2017-10-27 12:54 AM
Hello Tran ,
Check the answer in
https://community.st.com/0D50X00009XkXL6SAN
i will give you some example from Autosar guys
Best Regards
Erwan