This application note describes how to take advantage of the 16 MHz internal RC oscillator trimming feature on the STM8S and STM8A microcontroller to improve the frequency accuracy of the system compensating voltage and temperature frequency drift. The calibration technique, using the mains frequency as a timebase, is presented with an example of both hardware and software solutions. The example source code can be downloaded from the www.st.com. To benefit fully from the information in this application note, the user should be familiar with the STM8S and STM8A microcontroller architecture and with the basics of C language. For further information on the STM8S and STM8A family features, pinout, electrical characteristics, mechanical data and ordering information, please refer to the STM8S and STM8A datasheets. This document and its associated firmware, are written to accompany the STM8S and STM8A firmware library. Please contact STMicroelectronics for information on the STM8S and STM8A firmware library.
This document details how to utilize the 16 MHz internal RC oscillator (HSI) trimming feature on STM8S and STM8A microcontrollers to compensate for frequency drift caused by temperature and voltage variations. The technique uses the mains frequency as a reference timebase to calibrate the oscillator frequency in real-time.
| Nominal HSI frequency | 16 MHz |
|---|---|
| Factory calibration temperature | 25 °C |
| Factory calibration supply voltage | 5 V |
| Calibration period duration | 20 ms |
| Trimming range | -4 to +3 |
To improve frequency accuracy by compensating for temperature and voltage drift affecting the RC oscillator output.
The post-processed signal from the mains power source is used as a reference timebase.