English
Language : 

AN1324 Datasheet, PDF (1/15 Pages) Panasonic Semiconductor – Quadruple Operational Amplifiers
AN1324
APPLICATION NOTE
CALIBRATING THE RC OSCILLATOR OF THE
ST7FLITE0 MCU USING THE MAINS
INTRODUCTION
The ST7FLITE0 microcontroller contains an internal RC oscillator which can be trimmed to a
specific frequency with an accuracy of 1%. The oscillator frequency has to be calibrated by
software using the RCCR (RC Control Register). The value entered in the RCCR will switch on
a corresponding number of resistors that will modify the oscillator frequency. Whenever the
ST7FLITE0 microcontroller is reset, the RCCR is restored to its default value (FFh), so each
time the device is reset, you have to load the calibration value in the RCCR. There are prede-
fined calibration values stored in memory (refer to section 7.1 in the ST7FLITE0 datasheet)
You can load one of these values in the RCCR if one of the operating conditions matches that
in your application. Otherwise, you can define your own value, store it in EEPROM or any non-
volatile memory and load it in the RCCR register after each reset. However, if any of the ex-
ternal conditions (temperature or voltage, for instance) change too drastically, the stored value
may no longer produce the required 1% accuracy. One solution is to recalculate the RCCR
value after each reset, based on an external reference.
The purpose of this application note is to present a software solution using the frequency of
the European standard mains (220V/50Hz) as a timebase to adjust the internal RC oscillator
of the ST7FLITE0 to 1 MHz (1%). The same approach can also be used for the US mains
standard (110V/60Hz).
The basic software takes less than 160 ms to calibrate the oscillator and uses less than 90
bytes of program memory and five bytes of RAM for its simplest version. These RAM bytes
can be freed for other purposes when the calibration is done. Another example using averages
is given in this application note. This can be useful with noisy mains
This application note also contains the diagram of a low cost circuit which converts the mains
into a 5 volt power supply and protects the microcontroller from overcurrent on the input con-
nected to the mains.
AN1324/0604
Rev. 2
1/15
1