English
Language : 

AN4631 Datasheet, PDF (1/30 Pages) STMicroelectronics – How to calibrate an STM32L0xx internal RC oscillator
AN4631
Application note
How to calibrate an STM32L0xx internal RC oscillator
Introduction
Note:
The STM32L0xx 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 lower
speed, low-power clock source.
The STM32L0xx microcontrollers have two secondary clock sources.
• LSI: 37 kHz (Low-Speed Internal)
• HSI48: 48MHz (High-Speed Internal) that can be used directly for USB and for random number
generator (RNG).
The operating temperature has an impact on the accuracy of the RC oscillators. At 25 °C, the HSI16
oscillator has an accuracy of ±1% typically, the MSI oscillator has an accuracy of ± 0.5% 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 STM32L0xx microcontrollers have built-in features to allow you to calibrate the HSI16,
MSI and HSI48 oscillators and measure the MSI and LSI (Low-Speed Internal) oscillator frequencies.
This application note focuses on how to calibrate 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 only searches in it to 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.
1 STM32L0xx refers to Ultra Low Power Access line, USB line and USB and LCD line devices in this
document.
2 Ultra Low Power Access line devices are STM32L051xx microcontrollers where the Flash memory
density ranges between 32 and 64 Kbytes.
3 Ultra Low Power USB line devices are STM32L052xx and STM32L062xx microcontrollers where the
Flash memory density ranges between 32 and 64 Kbytes.
4 Ultra Low Power USB and LCD line devices are STM32L053xx and STM32L063xx microcontrollers
where the Flash memory density ranges between 32 and 64 Kbytes.
Type
Table 1. Applicable products and software
Part Number
STM32L051C6, STM32L051C8, STM32L051K6, STM32L051K8, STM32L051R6, STM32L051R8,
Microcontrollers
Software
STM32L052C6, STM32L052C8, STM32L052K6, STM32L052K8, STM32L052R6, STM32L052R8,
STM32L053C6, STM32L053C8, STM32L053R6, STM32L053R8
STM32L062K8
STM32L063C8, STM32L063R8
X-CUBE-RC-CALIB
April 2015
DocID027266 Rev 2
1/30
www.st.com
1