We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi bro,I am wondering which clock sources can be closed by software within stm32?thanks for helps.
Hi galileo1991 and welcome to the community.
The short answer is: Many,
Choosing a clock frequency on the STM32Fxxx depends on many things.
The STM32Fxxx microcontrollers have an internal clock oscillator (Resistor/Capacitor frequency generator), which can be chosen as clock-source. This internal clock source usually runs at 16MHz.
But you can feed the clock source into something called a PLL, which can multiply and divide the clock source, to generate for instance a clock frequency of 72 MHz or 48 MHz or 50 MHz from the same 16 MHz.
You can also choose to use an external crystal as a clock source for the PLL.
If you're using an external crystal, you'll be able to change the crystal in addition to using the PLL, that makes further possibilities.
As a quick rule of thumb (but not restricted to), you can clock your microcontroller at any clock frequency up to the microcontroller's maximum clock frequency. For many of the STM32Fxxx containing a Cortex-M3 core, this is 72MHz, but there are some that allows you to use higher clock frequencies.
You can usually choose clock frequencies with 1 MHz intervals if you use for instance an 8 MHz external crystal.
-But again, you're not limited to this value.
If you have a device number (eg. the full name of the STM32 device), and there's a special clock frequency you'd like to check if it can be clocked at, please post the model and the frequency, then I'll try checking the closest frequency available (it might be an exact match). I may be able to provide you with a few extra options.
It's also possible to shut down the main oscillator and enter 'sleep mode' by using the low power clock source (either internal or external).
So for clocking the CPU, you have these options:
HSI (High Speed Internal)
HSE (High Speed External)
LSI (Low Speed Internal)
LSE (Low Speed External)
PLL (which gets its clock input from either HSI or HSE)
The first 4 have fixed frequencies, while the last can be used to change clock speed while your software is running.
Personally, I'm using a STM32F407, with an 8MHz external clock crystal. I've programmed the PLL to multiply the frequency, so I get 168 MHz.
Thank you,jensbauer .
I read the STM32 Reference Manual(RM0008) carefully today,and I found these:
Each clock source can be switched on or off independently when it is not used, to optimize power consumption.(page 92/1128)
Each clock source can be switched on or off independently when it is not used, to optimize
power consumption.(page 92/1128)
and
The Flash memory programming interface clock (FLITFCLK) is always the HSI clock.(page 93/1128)
It seems that the stm32 provides options to turn off all of clock sources.But,there is a problem,the HSI is always used for flash memory programming,so I guess my stm32 chip will be locked(another word,can not download program into flash any more)if I turn HSI off.Am I right?
Fortunately, no.
The microcontroller should turn on HSI if it's necessary. This could happen if it's in sleep mode and both HSI and HSE are turned off.
But in order to turn off HSI, you need to make sure it's not in use, otherwise it will not be turned off.
So if any of the PLLs are using it or if your system-clock is using it directly, then it will not turn itself off, when you tell it to.
Note: If you're flash-programming the device via SWD (for instance STLink), then the flash-programming software will be able to turn on the HSI via the SWD interface. OpenOCD can do this for instance.
Learning a lot,very helpful.Thanks a lot.jensbauer
I could understand that although an 8MHz external crystal is available on STM32F4 discovery the clock is being sourced from the MCO of ST-Link interface.if X2 is required,R68 is to be removed.
Is this true?
So what about the stability of clock ? ANy comments on clock drifts?