Need help regarding implementation of 2 PWM blocks using PSOC 5LP

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello

   

 

   

I had some questions regarding the implementation of two PWM blocks in parallel.. It’s a simple implementation.This my first time with PSOC 5LP.

   

I know how to enable a PWM block using “PWM_1_Start();” in the “main.h” file but when I’m using the second PWM block then its giving an error with the “PWM_2_Start();” command. I read somewhere that I have to enable a control register somewhere but cant figure out where to do it.

   

 

   

I just need to enable two PWM block synchronously at a fixed frequency and 50% duty cycle.

   

 

   

Regards,

   

Sid

0 Likes
1 Reply
Anonymous
Not applicable

Hi, 

   

There are (at least) two ways to synchronize the PWM signals with the PSoC 5LP.

   

1. In case same resolution and clock may be used, then you can select the "PWM MODE: Two Outputs" in the PWM block configuration. By doing this you will get a single PWM timer (and two independent PWM signals), which is started with a single PWM_1_Start(), I am not quite sure though why you would need two PWM blocks, if the PWM signals are equal.

   

2. In case the two PWM signals are completely different (e. g. different frequency for 50%), but you want initial synchronization of counters, then you can use the UDB implementation of the each of two PWM blocks, and select the "Trigger Mode" at the Advanced options. For the SW synchronizaton for instance select the single bit Control Register and connect to the PWM trigger signals. You also need to select the "Enable mode: SW only" for the PWM blocks under Advanced options. The PWM counters will fire off once you set the Controller Register bit (and not after you previously called the PWM_1_Start() & PWM_2_Start()).

   

 

   

All mentioned SW calls for this simple implementation should be done before the for(;;) loop inside the main.c.

   

 

   

Regards,

   

Matija

0 Likes