2007-08-03 12:37 AM
2007-07-16 12:26 AM
Hello.
I am planning to continuously calibrate the RC oscillator by using the mains frequency (50Hz). What I want to realize is different from what application note AN2326 says. The AN2326 routine is executed once (during the boot phase). My routine should instead adjust the RC oscillator frequency while the application is running to compensate temperature and supply voltage variations. The feedback loop is simple: the code measures the duration of N power cycles (N is a design constant which have to be trimmed to balance measurement precision and control loop speed), then compares the result with the nominal one, i.e. 20ms x N. From this timing error, I have to adjust the RCCR and SICR registers, but the datasheet provides only the typical minimum frequency of RC oscillator (4.4 MHz) that is obtained with the reset values i.e. RCCR = 0xFF, SICR = 0x60. With the typical maximum frequency (i.e. when RCCR = 0x00, SICR = 0x00) I could estimate the mean value of a frequency step: how the RC oscillator frequency changes after a unit change. According to some other rough observations, I found that this variation should be 8kHz, but I am not sure if this result is true. During the boot phase, I should measure the minimum and maximum frequency, but it would take too much time and rom space and I do not know how this measure changes with temperature and supply tension. I will appreciate any suggestion. Thanks EtaPhi2007-07-26 01:12 AM
Hello Etaphi,
I also found a step around 8kHz. With RCCR at 0, the RC frequency is around 12.5 MHz. Normally the step frequency should vary in the same scale as the the RC frequency itself. As a step is around 1/1000 of the frequency this variation is meaningless. If your calibration is done permanently, I think you can use this average value. By the way, which accuracy are you targetting ? Best regards Laurent2007-07-26 07:48 PM
Hello Laurent,
the accuracy that I can achieve (according to the Control Theory) is 8 MHz +/- 8 kHz, i.e. 100 ppm whichever the temperature or supply voltage is. It is at least ten times better than the datasheet value and the effort to have it is so small compared to the benefits that, in my opinion, it should be pursued whenever possible. Regards, EtaPhi2007-08-02 10:25 PM
Hello Etaphi,
Very good ! But as this is a very small product with few I/Os, the idea was to calibrate the RCCR on the application board at production level by providing the 50Hz on the input capture, in order to have a good accuracy, then download the real application freeing the input capture pin for any purpose. Best regards Laurent2007-08-03 12:37 AM
Laurent,
the application that I am developing is a power meter. It uses a ST7LITEU05. PA2 is connected to a resistor ladder that attenuates the mains. It uses both the PA2 input capture and analog input functions. The remaining I/O are used as follows: * two analog inputs are tied to Hall sensors to measure the current; * two pins are used to communicate with the host by means of an opto-coupler. The ST7LITEU05 fits perfectly my design (no unused pin, cheap solution which isolates the hardware and software of the other applications), and I plan to use it as a building block for my applications. I therefore not need to free any I/O pin (I could use the RESET pin as output if I need to light a led) :) The continuous RCCR calibration idea is not limited to a 50Hz reference. Any timing reference is useful. In another application I use it on the slave devices (they are ST7FLITE29s) that are linked to a master that provides the timing reference and that is the only one that is driven by a crystal oscillator. Best regards, EtaPhi