How to adjust external clock in STM32?

123 views Asked by At

I want to trigger STM32 using an external clock. That is, I want data to be output from STM32 at every clock pulse. How to configure external clock in STM32 CubeIDE? Information: The card I use is the STM32F401RE card. This card already has an external crystal oscillator feature. But I want to design it using an external clock generator without using this feature.

STM32CubeIDE Proteus Design

2

There are 2 answers

0
CShark On

That's not how clocks work. Clocks set the processing speed for your mcu, not the rate at which you push data. And the sysclock has to be several times faster than the rate at which you want to push data to accomodate for calculation time.

The proper way to do this is to configure your clock like you would any normal clock (either external or internal) and set the "external clock" as an interrupt on one of the interrupt-enabled I/Os. Now your CPU can sleep and do nothing while waiting for your trigger and instantly jump into action sending your data as soon as the trigger hits.

0
mcagriaksoy On

First you need to open your external clock (I assume, you have physically connected your clock to the MCU) There are two types of clocks High Speed and Low Speed.

In the menu, pinout&cofiguration > system core > rcc open the high speed or low speed clock. HSE -> "E" refers for external clock. You need to take of it in clock configuration.

pinout&cofiguration > system core > rcc

please select:

enter image description here

After opening your clock, you need to select HSE and configure it on your clock configuration page:

HSE

Then, you can test the external clock with your oscilloscope and you can verify the MHz you set before.