Internal RTC?

http://www.atmel.com/dyn/resources/prod_documents/doc1259.pdf

Apparently, the ATMega168/328p/(probably) whatever you use has an internal RTC. Has anyone worked with this? How about working with this and Arduino?

I haven't heard of anyone using this, but it seems like a very reasonable option for clock projects.

Apparently, the ATMega168/328p/(probably) whatever you use has an internal RTC.

Where did you read that?

http://www.atmel.com/dyn/products/param_table.asp?category_id=163&family_id=607&subfamily_id=760

http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf (on the first page, "Real Time Counter with Separate Oscillator" under peripheral features, and on page 157-158)

Sorry - assumed RTC == Real-time Clock.

You know, that never really occurred to me... I assumed the same thing... And the document about the real time clock seems to allude to it, because they both run off an external 32.768 kHz watch crystal. I'm not saavy with this stuff, in fact I'm just getting started. What is the difference?

EDIT: I looked at the document list, and the app note referring to the real time clock was listed under atmega328p.

I've worked with it on an atmega644 using bascom, that worked fine.

The 48/88/168/328 chip also has two Tosc pins which could be used with an 32.768 Khz crystal.

Unfortunately those pins... are now connected to the 16MHZ crystal of the arduino.

Using them for rtc operations would mean you'll have to use the internal oscillator (which can achieve 8 MHz) and change a lot of fuses and registers. Changing fuse-settings can be quite tricky and it is hardly mentioned in the Arduino-IDE.

looked at the document list, and the app note referring to the real time clock was listed under atmega328p

My (very cursory) reading of the app note is that it is using the AVR [u]as[/u] an RTC, not merely using some element of it.

However, as Simpson_jr noted, losing the ability to run at 16MHz is a bit limiting.

You can do this on the Arduino Mega, as the TOSC pins are not the main crystal pins. You will have to set up a Timer interrupt, do some code for time counting, place the 32,768kHz crystal on the TOSC pins and set the prescaler to 128.

Why 128? 128 * 256 = 32768. So with a 128 prescaler, the timer will interrupt the program every second. I thought about creating that myself... I even have almost all the code made to turn into a library... I do need a 32,768kHz crystal and an Arduino Mega board. If anyone is willing to assist me with it, go ahead. :) LOL

Finding the crystal shouldn't be a problem, you've probably already got a load at home. The crystal of first cheap plastic clock I opened worked immediately and I found loads of others on all kinds of old boards/cards.

What if I didn’t run at 16 MHz? This project idea is actually for a custom board running the arduino bootloader, and/or a breadboard arduino (I don’t really use my Duemilanove anymore).

I’m curious to see if we could get this to work…

Simpson_Jr: Finding the crystal shouldn't be a problem, you've probably already got a load at home. The crystal of first cheap plastic clock I opened worked immediately and I found loads of others on all kinds of old boards/cards.

Assuming I have those around me is a mistake. I don't, the only thing I have with that crystal is my Casio, and apart from being my favorite watch, is still working. Spare parts are so scarce around here I can't put a mega16 running because I don't have the capacitors for the crystal. I know, I know, I'm lazy. I'll be headed to my favorite electronics shop next week so I may find something.

[quote author=Geek 2.0 link=topic=56908.msg408912#msg408912 date=1301409372] What if I didn't run at 16 MHz? This project idea is actually for a custom board running the arduino bootloader, and/or a breadboard arduino (I don't really use my Duemilanove anymore).

I'm curious to see if we could get this to work... [/quote]

It all boils down on what you are using. If you change the fuses on the mega168 or 328 and use the 8MHz internal clock, you can have the TOSC pins for the real time clock. Or, if you are using another chip, you may be able to get away with both. For example, if you are using the ATmega16, 32, 324 or 644 (they all share the same pinout), you can have an external crystal and also the 32768Hz crystal for the RTC. (the TOSC pins are PC6, 7) I was actually test my code on the ATmega16 mentioned previously, so I guess all I need is the crystal and two 22pF capacitors. LOL