[PWM] - Changing the Clock Frequency during code execution

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

cross mob
Anonymous
Not applicable
        Hello fellows, I'm here to ask about some special issue that I'm having with the PWM16 Block of PSOC 1. In my application, I have to change the clock frequency of the PWM during the code execution. This is the only thing that I can do in order to reach lower levels of the "Output Frequency". In order words, with a Sysclk freq = 24 MHz the minimum value of the output frequency that I can get is 400 Hz. In my application, I need to sweep the frequency between 100 Hz and 10000 Hz. Do you guys know to do this without changing the Sysclk freq? Thanks a lot for the info!   
0 Likes
1 Solution
ETRO_SSN583
Level 9
Level 9
100 sign-ins 5 likes given 1000 replies posted

Yes, look at the API's int he datasheet, there is one for the period. There are

   

side effects related to when actual update occurs, read those comments as well.

   

 

   

Regards, Dana.

View solution in original post

0 Likes
5 Replies
ETRO_SSN583
Level 9
Level 9
100 sign-ins 5 likes given 1000 replies posted

Yes, look at the API's int he datasheet, there is one for the period. There are

   

side effects related to when actual update occurs, read those comments as well.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable
        This kind of API adjusts only the Period Value of the PWM. What I need to set is the Clock Frequency of the PWM, not the Output Clock Frequency. I have tried to find a way to configure the PWM config. Registers to set another Clock Source, but I could not find anything.   
0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You may always use a counter as a pre-scaler on a neighboured block. The output of the prescaler can be used as clock input to the PWM. Lowest Count will be divide by two, so you get 12MHz as input to your PWM. Higest count you get with a 16bit prescaler.

   

 

   

Bob

Anonymous
Not applicable
        Thanks a lot for information Bob! I'll try it.   
0 Likes
ETRO_SSN583
Level 9
Level 9
100 sign-ins 5 likes given 1000 replies posted

You can use a timer or a counter, clock it at 48 Mhz (as long as clock not derived

   

from interal global buss route), and use a period divsior of 0  to n-1. At 0 input

   

clk is output / 1, and just shifted.

   

 

   

Regards, Dana.

0 Likes