herunterladen

August 2016 DocID028052 Rev 2 1/29
1
AN4736
Application note
How to calibrate STM32L4 Series microcontrollers
internal RC oscillator
Introduction
The STM32L4 Series microcontrollers have two internal RC oscillators that can be selected as the
system clock source. These are known as the HSI16 (high-speed internal) and MSI (multi-speed
internal) oscillators. The HSI16 oscillator has a typical frequency of 16
MHz. The MSI oscillator is a
multispeed, low-power clock source.
The STM32L4 Series microcontrollers have two secondary internal clock sources:
• LSI: 32 kHz (low-speed internal)
• HSI48: 48MHz (high-speed internal) that can be used directly for USB, for RNG (random number
generator) and for SDMMC (SD/SDIO MMC card host interface).
The operating temperature has an impact on the accuracy of the RC oscillators. At 30 °C, the HSI16
oscillator has an accuracy of ± 0.5 %, the MSI oscillator has an accuracy of ± 0.6 % and the HSI48
oscillator has an accuracy of ±4%. But in the temperature range of -40
°C to 105 °C, the accuracy
decreases. To compensate for the influence of temperature on internal RC oscillators accuracy, the
STM32L4 Series microcontrollers have built-in features allowing to calibrate the HSI16, MSI and
HSI48 oscillators and measure the LSI (low-speed internal) oscillator frequency.
When a low-speed external (LSE) clock source at 32.768 kHz is available in the system, the MSI
frequency can be automatically trimmed by hardware to reach an accuracy better than ±0.25
%. This
hardware auto-calibration with LSE is called PLL (phase-locked loop) mode. This application note
does not use this mode and focuses only on the user trimming.
This application note also focuses on how to calibrate below internal RC oscillators: HSI16, MSI and
HSI48. Three methods are presented: the first method is based on finding the frequency with the
minimum error, the second one consists in finding the maximum allowed frequency error and the third
one implements a table of premeasured values and then searches in it for the appropriate change. All
three are implemented by providing an accurate reference signal.
The measurement of the LSI oscillator is performed by connecting the oscillator to a timer input
capture.
The X-CUBE-RC-CALIB embedded software package is delivered with this application note,
containing the source code to perform those internal oscillators calibrations and all the embedded
software modules required to run the examples.
Note: All the information related to HSI48 is only applicable to the following product families:
STM32L43x, STM32L44x, STM32L45x, STM32L46x, STM32L496 and STM32L4A6.
www.st.com