Forums

AT91SAM7A3 real-time timer

Started by Mochuelo June 19, 2006
Hi,

I see in the datasheet of the AT91SAM7A3 that the real-time timer
(RTT) is fed by the Slow Clock, which is an internal RC oscillator
(f=22 kHz to 42 kHz). The RTT has a 16-bit prescaler and a 32-bit
counter.

How are we supposed to use such an inaccurate clock as the source for
a real-time timer? The only way I can think of is to add a crystal
(which will not always be running (otherwise, there would be no reason
to use the RC oscillator)) and use it to "calibrate" the RC oscillator
every once in a while. The 16-bit prescaler of the RTT allows to do
this. This way, the 32-bit counter could count more or less exact
seconds. The datasheet (preliminary), however, does not say anything
about the drift of such an RC oscillator. How often would you say it
would be needed to perform such a calibration? Has anyone done this?

Is there a simpler method to use the RTT as what it is supposed to be?

Thanks,

Mochuelo wrote:
> Hi, > > I see in the datasheet of the AT91SAM7A3 that the real-time timer > (RTT) is fed by the Slow Clock, which is an internal RC oscillator > (f=22 kHz to 42 kHz). The RTT has a 16-bit prescaler and a 32-bit > counter. > > How are we supposed to use such an inaccurate clock as the source for > a real-time timer? The only way I can think of is to add a crystal > (which will not always be running (otherwise, there would be no reason > to use the RC oscillator)) and use it to "calibrate" the RC oscillator > every once in a while. The 16-bit prescaler of the RTT allows to do > this. This way, the 32-bit counter could count more or less exact > seconds. The datasheet (preliminary), however, does not say anything > about the drift of such an RC oscillator. How often would you say it > would be needed to perform such a calibration? Has anyone done this?
A test was done against a GPS receiver (which is pretty exact) over ~ 5 days. Difference was 36 ppms... 5 days is 432 000 seconds and 36 ppm is about 15 seconds or 3 seconds per day.
> > Is there a simpler method to use the RTT as what it is supposed to be? > > Thanks,
-- Best Regards, Ulf Samuelsson ulf@a-t-m-e-l.com This message is intended to be my own personal view and it may or may not be shared by my employer Atmel Nordic AB
On Tue, 20 Jun 2006 00:26:16 +0200, "Ulf Samuelsson"
<ulf@a-t-m-e-l.com> wrote:

>A test was done against a GPS receiver (which is pretty exact) over ~ 5 >days. >Difference was 36 ppms... >5 days is 432 000 seconds and 36 ppm is about 15 seconds or 3 seconds per >day.
Thank you for the information. That was under constant temperature, right? Do you know approximately what's the temperature coefficient of those RC oscillators? There's something I don't fully understand, though. Even in the worst case (22 kHz), a difference of one unit in the prescaler load value implies 1/22000=45.5 ppm, which would mean that there is an optimal choice for the prescaler value that would give you a max error of +-22.7 ppm. My question is "were you able to find any other prescaler load value that would give you an error better than 36 ppm, or that was the best one you found?" Did you try N-2, N-1, N+1, N+2? Best,
Mochuelo wrote:
> On Tue, 20 Jun 2006 00:26:16 +0200, "Ulf Samuelsson" > <ulf@a-t-m-e-l.com> wrote: > >> A test was done against a GPS receiver (which is pretty exact) over >> ~ 5 days. >> Difference was 36 ppms... >> 5 days is 432 000 seconds and 36 ppm is about 15 seconds or 3 >> seconds per day. > > Thank you for the information. > > That was under constant temperature, right?
In the office, so not wildy varying. It may be good to have an external temp sensor and recalibrate...
> Do you know approximately > what's the temperature coefficient of those RC oscillators? >
No clue.
> There's something I don't fully understand, though. Even in the worst > case (22 kHz), a difference of one unit in the prescaler load value > implies 1/22000=45.5 ppm, which would mean that there is an optimal > choice for the prescaler value that would give you a max error of > +-22.7 ppm. My question is "were you able to find any other prescaler > load value that would give you an error better than 36 ppm, or that > was the best one you found?" Did you try N-2, N-1, N+1, N+2?
No, (I didnt do the test myself)
> > Best,
-- Best Regards, Ulf Samuelsson ulf@a-t-m-e-l.com This message is intended to be my own personal view and it may or may not be shared by my employer Atmel Nordic AB