Introduction
Author: Lloyd Clark, Microchip Technology Inc. |
An increasing number of AVR® devices contain both an ultra-low-power (ULP) internal oscillator and an oscillator module that functions only when an external 32.768 kHz crystal is connected to the device. This application note describes a method of achieving both precise timing and ultra-low power consumption by periodically enabling the 32.768 kHz external crystal oscillator for recalibration of the ULP internal oscillator. Example code is provided for an ATtiny416 device. The Real-Time Counter (RTC) module on the device is continuously driven by the ULP internal oscillator to keep track of time. Most of the time, the 32.768 kHz crystal oscillator is disabled so that it does not consume power. However, periodically (every 15 minutes in the example code) the crystal oscillator is enabled for several seconds and used by the 16-bit Timer/Counter Type B (TCB) to accurately measure the duration between successive "ticks" of the RTC module. This allows crystal-oscillator-like timing precision to be achieved as well as ultra-low power consumption because the crystal oscillator is disabled more than 99% of the time.