cancel
Showing results for 
Search instead for 
Did you mean: 

sync PWMA0 and PWMA1

raghu tumati
Associate II
Posted on September 22, 2017 at 22:50

I have an application where I need to enable two PWM outputs. They need to have the same frequency but different duty cycles 

I have got PWMA0 and PWMA1 working but I am not able to get them synced together. There is a 9.2us difference in switching between A0 and A1. 

I tried playing around with the FORCE_EN register and but was unsuccessful. Is there any easy way to get this done?

6 REPLIES 6
Erwan YVIN
ST Employee
Posted on September 25, 2017 at 11:35

Hello Raghu ,

Could you confirmed the device / microcontrollers used ? 

Anyway , i am checking the FORCE_SEL register.

  Best regards

         Erwan

Posted on September 25, 2017 at 17:07

Hi Erwan 

Thank you for replying. The micro is SPC560P50L5. Im using the SPC560P-DISP eval board. 

I have used the following setting without much success. 

For submodule0 

INIT_SEL = 0

RELOAD_SEL=0

FORCE_SEL = 0

FRCEN=1U

For submodule1 

INIT_SEL = 1U

RELOAD_SEL =1U

FORCE_SEL=1U

FRCEN=1U

And after that in the main.c file, I call 

FORCE = 1 for submodule 0. I was hoping that a force on submodule 0 would cause the same in submodule 1 also from the register description in the data sheet. 

But I think I'm missing something.

raghu tumati
Associate II
Posted on September 25, 2017 at 22:08

Hi Erwan 

I was able to get it working partially. 

I commented the INIT_SEL and RELOAD_SEL and had just the FORCE_SEL and it worked. The two submodules are now synchronously switching only if their duty cycles are same.

If their duty cycles are different, it does not work. Please see attached pictures. I have one of the submodules polarity inverted for the application. 

0690X00000603yQQAQ.jpg0690X0000060470QAA.jpg
Posted on September 26, 2017 at 00:11

Never mind. I figured this one out too. 

The PWM was set to Align_Center and it should have been Align_Edge. 

Sorry for the constant bombardment of replies in this thread. 

Although Im still not done  

 I would like to switch a GPIO on and off multiple times from the rising edge of only one of the PWM submodules? What is the easiest way to do this? Timer or CTU or ICU? 

-Raghu

Erwan YVIN
ST Employee
Posted on September 26, 2017 at 10:31

Hello Raghu ,

you are not far from the solution

There is an example in the reference manual RM022

Coudl you try to update INIT = VAL2 = VAL4 ?

Chapter 26.7.2 Edge-aligned PWMs (INIT = VAL2 = VAL4)

0690X00000608KZQAY.png

   Best Regards

                        Erwan

Posted on October 02, 2017 at 21:23

Hi Erwan

I have this working now .Thanks for your help.