Introduction

This application note describes how to implement a real time counter (RTC) on AVR microcontrollers that features the RTC module. The implementation requires only one discrete component – a 32.768kHz watch crystal. The application has very low power consumption because the microcontroller operates in Power-save mode most of the time. In Power-save mode the AVR controller is sleeping with only a timer running. The Timer is clocked by the external crystal. On every Timer overflow the time, date, month, and year are counted. This RTC implementation is written for the ATmega128, and can easily be ported to other AVRs with RTC Module. The advantages of implementing an RTC in software compared to an external hardware RTC are obvious: