This application note gives two methods of calibrating the HSI internal RC oscillator.
The STM8L15x microcontroller family includes High-speed Internal (HSI) and Low-speed Internal (LSI) RC oscillators. While factory-calibrated for 1% accuracy at 25°C, their frequency varies with temperature and voltage. This document provides two methods to calibrate the HSI oscillator: finding the frequency with the minimum error or finding the maximum allowed frequency error. Both methods use an accurate reference source, such as the LSE oscillator or mains frequency, to measure the HSI frequency via a timer.
| HSI typical frequency | 16 MHz |
|---|---|
| LSI typical frequency | 38 kHz |
| HSI accuracy at 25°C | +1% typically |
| HSI accuracy range | -4.5% / +3% |
| Maximum HSI frequency variation | 16 MHz + 480 kHz |
| Minimum HSI frequency variation | 16 MHz - 720 kHz |
The first method is based on finding the frequency with the minimum error, and the second consists in finding the maximum allowed frequency error.
An accurate reference source such as the LSE frequency provided by an external 32.768 kHz crystal or the 50 Hz/60 Hz of the mains can be used.