DocID025202 Rev 7
120/1080
RM0365
Reset and clock control (RCC)
154
External crystal/ceramic resonator (HSE crystal)
The 4 to 32 MHz external oscillator has the advantage of producing a very accurate rate on
the main clock.
The associated hardware configuration is shown in
. Refer to the electrical
characteristics section of the
datasheet
for more details.
The HSERDY flag in the
Clock control register (RCC_CR)
indicates if the HSE oscillator is
stable or not. At startup, the clock is not released until this bit is set by hardware. An
interrupt can be generated if enabled in the
Clock interrupt register (RCC_CIR)
The HSE Crystal can be switched on and off using the HSEON bit in the
Caution:
To switch ON the HSE oscillator, 512 HSE clock pulses need to be seen by an internal
stabilization counter after the HSEON bit is set. Even in the case that no crystal or resonator
is connected to the device, excessive external noise on the OSC_IN pin may still lead the
oscillator to start. Once the oscillator is started, it needs another 6 HSE clock pulses to
complete a switching OFF sequence. If for any reason the oscillations are no more present
on the OSC_IN pin, the oscillator cannot be switched OFF, locking the OSC pins from any
other use and introducing unwanted power consumption. To avoid such situation, it is
strongly recommended to always enable the Clock Security System (CSS) which is able to
switch OFF the oscillator even in this case.
External source (HSE bypass)
In this mode, an external clock source must be provided. It can have a frequency of up to
32 MHz. Select this mode by setting the HSEBYP and HSEON
bits in the
. The external clock signal (square, sinus or triangle) with ~40-60% duty
cycle depending on the frequency (refer to the datasheet) has to drive the OSC_IN pin while
the OSC_OUT pin can be used a GPIO. See
.
9.2.2 HSI
clock
The HSI clock signal is generated from an internal 8 MHz RC Oscillator and can be used
directly as a system clock or divided by 2 to be used as PLL input.
The HSI RC oscillator has the advantage of providing a clock source at low cost (no external
components). It also has a faster startup time than the HSE crystal oscillator however, even
with calibration the frequency is less accurate than an external crystal oscillator or ceramic
resonator.
Calibration
RC oscillator frequencies can vary from one chip to another due to manufacturing process
variations, this is why each device is factory calibrated by ST for 1% accuracy at T
A
=25°C.
After reset, the factory calibration value is loaded in the HSICAL[7:0] bits in the
If the application is subject to voltage or temperature variations this may affect the RC
oscillator speed. The user can trim the HSI frequency in the application using the
HSITRIM[4:0] bits in the
Clock control register (RCC_CR)
.
For more details on how to measure the HSI frequency variation, refer to
Internal/external clock measurement with TIM16
.