Pervasive Tangibility - TIMER2 en Realtime Clock (RTC) with 32kHz Crystal and Sleep <p>I'm still working on the unnamed project. It involves low power operation. The story is moving forward on different fronts simultaneously. Previously I looked at power consumption issues on a running ATMega168/ ATMega328 configuered as Arduino Lilypads. Significant issues turned out to be <a href="/floating_pins">floating pins and the Power Reduction Register</a> (PRR). To adjust the processor speed and clock source, I had to get comfortable with changing the <a href="/fuses">fuse settings</a> in the AVR. The next piece of the puzzle is setting up sleep mode. Sleep involves going to sleep and waking up, and also knowing what time it is when the MCU wakes up. The ATMega provides a higly accurate (moreso than the normal 16 MHz crystal) super low power clock using a special feature of TIMER2. TIMER2 can generate its own clock, separate from the normal system clock. It uses external watch crystal crystal connected to the TOSC1 and TOSC2 pins. Because this clock is accessable only to TIMER2, it can run while the rest of the AVR is asleep. If TIMER2 is configued to generate a periodic interrupt (there's more than one configuration that will work) that interrupt will wake up the AVR. Whenever the work is done, a few magic lines of code in the program can be used to put the AVR back to sleep. The TIMER2 interrupt with the watch crystal can be used to generate accurate interrupts for any purpose, not just sleep.</p> <p>&nbsp;CLICK READ MORE TO SEE THE REST OF THE POST</p> <p><a href="" target="_blank">read more</a></p> Crystal Interrupts oscillator RTC TIMER2 Mon, 07 Feb 2011 17:11:46 +0000 Ed_B 153 at