PWM as a clock devider

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

cross mob
Anonymous
Not applicable

how to use PWM as a clock divider?

   

i tried to use it for changing clock frequency in run time. to achieve 921600 clock frequency i used the configuration as shown below but its not getting. I have given 48 MHz to clock input. What can be the problem?

   

0 Likes
6 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

48 Mhz / .9216 Mhz = 52.083333333333333333333333333333 as a divisor,

   

but you have 25 as a divisor, but that does not create the 1.083 uS shown

   

in configurator, which tells me your clock is set to 24 Mhz, which would result

   

in .9216 Mhz = 1.083 uS.

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

But why don't you use a normal clock block? You can change it during runtime too (via the Clock_SetDivider method).

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

As hli pointed out sometimes we (I) miss the obvious

   

 

   

   

 

   

0 Likes
Anonymous
Not applicable

Actually I tried changing runtime clock by using function

   

Clock_SetDivider(11);

   

and I have set source clock for 115200 [ 115200 * 8 = 921600 ]. Acording to datasheet by using above function my Uart should work on 9600 isnt it?

   

but its not working so.

   

In which sequence functions of clock should I use for changing freq runtime?

0 Likes
Anonymous
Not applicable

The clock to the UART should be 8X( or 16X )of the baud rate, so for 9600 baud, you clock to the UART should be 76800( or 153600).

0 Likes
Anonymous
Not applicable

Hi Nilesh,

   

 

   

When using the Clock_SetDivider( ) API, please ensure that the clock "Source" in the configuration tab is chosen appropriately. When left as "Auto", Creator might select the source which you might not have expected. Hence, setting the divider might result in unexpected output frequency.

   

 

   

Did you check the clock output on an oscilloscope? What frequency did you observe it to be?

   

 

   

Thanks,

   

Gautam Das

0 Likes