cancel
Showing results for 
Search instead for 
Did you mean: 

How do I generate a clock for other devices using STM32's GPIO

CWang.12
Associate II

I 'd like to use a GPIO of STM32 to generate a clock for other peripherals. This clock should have the same precision as HSE.Also, the clock should be stable.Also, once set successfully, its stability is not disturbed by running code/interrupts.And it does not consume the MCU's computing resources.For example, I want to output a stable 12MHz MLCK for Audio Codec on any GPIO on a 72MHz general purpose STM32.

Do you have any suggestions?With timers, PWM, Memory to GPIO DMA, ?

Br

3 REPLIES 3

TiM​ or MCO

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

MCO is best option if pin available

Timer in pwm mode enablee programmable duty cycle at lower frequencies

Some STM32 clock tree have multiple pll especially for audio, use them to outptu on a pin like mco as frequency is programmable and independent of core.

In extreme limited choice situations, SPI master with cycling dma a byte out with only SCK pin enabled can sometime work around limitations. Similar way on few other peripherals. Depends on situation and final goals.

CWang.12
Associate II

Thanks . Maybe MCO is the best option. Can I expect a more general solution?Using HSE as clock source, route to a GPIO through PLL to generate the required clock.😀