Real Time Clock with the Embedded RTT

Discussion about SAM7 Series and ARM7TDMI based products.

Moderator: nferre

User avatar
stephan_cadene
Contact:
Location: Atmel Corp.
Posts: 163
Joined: Thu Feb 12, 2004 7:48 pm

Real Time Clock with the Embedded RTT

Mon Nov 21, 2005 7:04 pm

Hi everybody,

Here is an IAR project in order to have a RTC software by using [RTT + RC-Oscillator + a compensation process which is going to be described in future Application Note.
The resulting drift error (with a AT91SAM7S-EK Evalutaion Board) has been equal to 9.9 ppm vs. a watch with static temperature.
With dynamic temperature:
The compensation process is started each 5 second. Thus, this drift error will be, in case the temperature vary slowly vs. compensation delay (5s), near to 10 ppm. This compensation delay can be set in a .h file.
This project gives Date and Time through DBGU to your Hyperterminal application on your pc (use the readme.html small documentation embedded in zip file).

The bin file is attached too in order to burn the application without using IAR project manager (by using SAM-BA for example).

Summary about these 3 following attachments:
The former is the full IAR project for AT91SAM7S256,
The second is the binary file only for the AT91SAM7S64 Evaluation Board,
The latter is the full IAR project for the AT91SAM7S64 Evaluation Board.
xpercad
Location: MEXICO
Posts: 29
Joined: Sun Mar 20, 2005 6:46 pm

Mon Mar 13, 2006 9:45 pm

Please let me know how to download the referenced attachd files for this project. They do not appear in the sticky post.

Thanks.

Aaron
Aaron
Lazio
Posts: 5
Joined: Tue Feb 28, 2006 5:43 pm

Mon Apr 10, 2006 9:34 pm

I would like to get the copy of the whole project but I couldn't find
it in the sticky, would you please repost the attached files?
Thanks!
xpercad
Location: MEXICO
Posts: 29
Joined: Sun Mar 20, 2005 6:46 pm

Tue Apr 11, 2006 6:36 pm

Hi Lazio,

You can find the project files here: http://rojko.cz/xy/AT91SAM7S256-BasicRT ... A-1_21.zip
Aaron
Lazio
Posts: 5
Joined: Tue Feb 28, 2006 5:43 pm

Tue Apr 11, 2006 8:24 pm

Hi xpercad: Got it! Thanks a lot!
nleahcim
Posts: 87
Joined: Thu Aug 25, 2005 7:06 pm

Wed Apr 11, 2007 6:02 am

Hi - it seems the only link to this project has died. Does anybody know where I can find this project? Thanks!

-Michael
gerthmar
Posts: 1
Joined: Wed Apr 04, 2007 10:46 am

Mon Apr 16, 2007 11:24 am

Check out this link, there is a port of the ATMEL RTT Basic Example to GCC, but i did not have time to test it so far:

http://www.siwawi.arubi.uni-kl.de/avr_p ... _at91.html[/url]
nleahcim
Posts: 87
Joined: Thu Aug 25, 2005 7:06 pm

Tue Apr 17, 2007 9:20 pm

gerthmar wrote:Check out this link, there is a port of the ATMEL RTT Basic Example to GCC, but i did not have time to test it so far:

http://www.siwawi.arubi.uni-kl.de/avr_p ... _at91.html[/url]
That is all I could find as well. I had hoped to find the IAR version, but oh well.

Has anybody seen code using the RTT interrupt? I'm having the worst trouble getting it working.
scoobyjh
Posts: 14
Joined: Wed Apr 25, 2007 10:07 am

Wed Apr 25, 2007 10:51 am

Hi nleahcim,

I wrote an interrupt mechanism for the RTT on a sam7se512 for a 1second tick. I had problems when I used level sensitive system controller ints. I found that I got multiple interrupts on every increment.

I set positive edge triggered and the problem went away. Then I tried using the PIT with edge triggered and consequently missed interrupts! So I switched back to level triggered and the PIT works fine...shame about the RTT! With all the other problems with it we are going to use an external RTC instead!
nleahcim
Posts: 87
Joined: Thu Aug 25, 2005 7:06 pm

Sat Apr 28, 2007 8:10 pm

scoobyjh wrote:Hi nleahcim,

I wrote an interrupt mechanism for the RTT on a sam7se512 for a 1second tick. I had problems when I used level sensitive system controller ints. I found that I got multiple interrupts on every increment.

I set positive edge triggered and the problem went away. Then I tried using the PIT with edge triggered and consequently missed interrupts! So I switched back to level triggered and the PIT works fine...shame about the RTT! With all the other problems with it we are going to use an external RTC instead!
I eventually got my interrupt working as well. I'm using it to be level sensitive and not having the problem that you had, interestingly enough. I'm using hte AT91SAM7X256 though, so maybe that accounts for the difference?

Anyways - how accurate did you find the RTT to be? I'm having terrible problems with it's accuracy.
scoobyjh
Posts: 14
Joined: Wed Apr 25, 2007 10:07 am

Thu May 03, 2007 9:33 am

nleahcim wrote: I eventually got my interrupt working as well. I'm using it to be level sensitive and not having the problem that you had, interestingly enough. I'm using hte AT91SAM7X256 though, so maybe that accounts for the difference?

Anyways - how accurate did you find the RTT to be? I'm having terrible problems with it's accuracy.
Not sure why level works for you and not me, I thought the RTT peripheral would be the same for the AT91SAM7SE512 as for your processor. Maybe not :)

Anyway, you have to calibrate the RTT at startup and then maybe also at runtime if you need to (depending on the voltage and ambient temperature variations of your environment).

There is an Atmel app note which describes this and I have some code that does it if you are interested. At startup, after you have initialised the clock generator you can calibrate the RTT. I believe that subsequent calibrations need to stop and restart the master clock and PLL, which is annoying because you have to switch the core to clock from the internal oscillator while you do this!

Also, you have to reset the RTT [and this also resets the counter] when calibrating, which doesn't make it a continuous counter.
nleahcim
Posts: 87
Joined: Thu Aug 25, 2005 7:06 pm

Sat May 12, 2007 12:55 am

scoobyjh wrote:Not sure why level works for you and not me, I thought the RTT peripheral would be the same for the AT91SAM7SE512 as for your processor. Maybe not :)

Anyway, you have to calibrate the RTT at startup and then maybe also at runtime if you need to (depending on the voltage and ambient temperature variations of your environment).

There is an Atmel app note which describes this and I have some code that does it if you are interested. At startup, after you have initialised the clock generator you can calibrate the RTT. I believe that subsequent calibrations need to stop and restart the master clock and PLL, which is annoying because you have to switch the core to clock from the internal oscillator while you do this!

Also, you have to reset the RTT [and this also resets the counter] when calibrating, which doesn't make it a continuous counter.
So, during run time, is it possible to recalibrate the timer during run time without restarting the master clock? Perhaps is there some way to count the clock from my 18.432MHz crystal? I'm using a really, really high accuracy crystal, so that would be ideal.

Thanks!

-Michael
scoobyjh
Posts: 14
Joined: Wed Apr 25, 2007 10:07 am

Tue May 22, 2007 12:25 pm

nleahcim wrote: So, during run time, is it possible to recalibrate the timer during run time without restarting the master clock? Perhaps is there some way to count the clock from my 18.432MHz crystal? I'm using a really, really high accuracy crystal, so that would be ideal.

Thanks!

-Michael
If you want to use the internal compensation feature then no you cannot do it without restarting the master clock. Here is the link to the app note which describes the compensation:
http://www.atmel.com/dyn/products/app_n ... scillators
It is called:Using a Real-time Timer with Non-calibrated RC Oscillator as Real-time Clock

If however you can find another way of counting the slow clocks using a different clock source then perhaps you can implement your own compensation mechanism without having to stop the master clock.

Sorry for the delay in reply, I have been ill.
Cheers.[/url][/b]

Return to “SAM7 ARM7TDMI MCU”

Who is online

Users browsing this forum: No registered users and 2 guests