cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure clock at 38 Khz with some other operation

parag
Associate II
Posted on June 11, 2011 at 00:26

Hi All,

     I want to configure the clock output at 32 Khz to 38 Khz in one of the pins and at the same time I want to send the data from USART. It is like two parallel operation; one pin is continuously generating the clock ouput independant of the other operation. Can we configure the clock like that with their respective pin? I read about MCO pin but I did not understand how to code for 32 Khz to 38 Khz.

      My situation is like one pin will be continuously generating the clock and Tx of USART will be sending at the same time. I can do USART part, please help me for clock part.

Thanks in advance.

1 REPLY 1
Posted on June 11, 2011 at 03:28

The MCO pin muxing should let you get the LSI (~40 KHz) and LSE (32.768 KHz) clocks out of the part.

You might also consider using the TIMx timers to generate other frequencies, with other mark/space ratios, as you desire.

The output frequencies you can get will depend on your source (8 MHz), what you've converted that too with the PLL, and your ability to divide that with a 16-bit prescaler, and the 16-bit divider/counter of the timer itself.

Exactly how good that is for you, will depend on the range, granularity, accuracy you are looking for. I don't think divider chains are that great, but might fit your unspecified needs.

How exactly are these frequencies tied to the USARTs, I'm confused, do you want synchronous serial at these rates? You're synchronizing some part of the data transmission to these clocks, edges, seconds? The USARTs of the STM32 are rather clumsy, although they don't have FIFO's behind them. If you want fine control of the USART and clocks, edge placement, etc, you might consider a CPLD or FPGA type implementation.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..