cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronous rectifier using SPC570S-DISP board

Tran Hung
Associate II
Posted on October 23, 2017 at 07:16

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 added

ETIMER_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 added

ETIMER_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 #spc570s
This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
6 REPLIES 6
Tran Hung
Associate II
Posted on October 24, 2017 at 10:13

Yvin.Erwan

‌: Hi Erwan Can you suggest me some ideas for this problem?

Erwan YVIN
ST Employee
Posted on October 24, 2017 at 11:02

Hello Tran ,

I am checking with experts.

Often , there are some examples on the Reference manual

           Best regards

                      Erwan

Erwan YVIN
ST Employee
Posted on October 25, 2017 at 10:15

Hello Tran ,

Did you try to disable the timer before shifting the phase ?

0690X00000608gRQAQ.png

      Best regards

                  Erwan

Posted on October 26, 2017 at 03:03

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.

Posted on October 26, 2017 at 10:14

No Tran ,  in fact it is not required.

i will give you a feedback from our experts as soon as possible

             Best Regards

                         Erwan

Erwan YVIN
ST Employee
Posted on October 27, 2017 at 09:54

Hello Tran ,

Check the answer in

https://community.st.com/0D50X00009XkXL6SAN

i will give you some example from Autosar guys

Best Regards

Erwan