This application note describes how to use the mains to calibrate the ST7ULTRALITE MCU's RC oscillator.
The ST7ULTRALITE microcontroller contains an internal RC oscillator that requires software calibration to achieve specific frequency accuracy. This document presents a method to trim the oscillator using the RCCR and SICSR registers, utilizing the European (50Hz) or US (60Hz) mains frequency as a precise timebase reference. The software performs a dichotomous analysis to adjust the oscillator frequency to 1 MHz or 8 MHz depending on the configuration.
| Program memory usage (basic version) | less than 128 bytes |
|---|---|
| RAM usage (basic version) | five bytes |
| Calibration time (average version) | less than 800 ms |
| Program memory usage (average version) | 136 bytes |
| RAM usage (average version) | 11 bytes |
| Target oscillator frequency | 1 MHz or 8 MHz |
The software uses the mains frequency as a timebase to test if the RC oscillator frequency is above or below the targeted frequency and repeatedly transforms it by dichotomous analysis.
With a 220nF capacitor (C2), the available current is limited to 4.9 mA in the case of a European mains.