Low-Power Real-Time Clock

Low-Power Real-Time Clock

This application note shows the implementation of a software, low-power Real-Time Clock (RTC) on an 8-bit PIC16(L)F171X microcontroller using the Timer1 module. Timer1 enables the device to operate in Sleep mode, provided that it runs from an external clock source. While in Sleep mode, the device will draw minimal current. Interrupt events, such as a keypress on an Interrupt-on-Change (IOC) pin or a Timer1 overflow, can wake the device up from Sleep. At that time, the MCU can do various things, such as updating the time on the LCD. This implementation includes the use of the MPLAB Code Configurator (MCC) for easier code development, and is applicable on any 8-bit PIC microcontroller given that the required peripherals are supported.

This implementation uses the Explorer 8 Development Board, a full-featured development board and platform for 8-bit PIC microcontrollers. Most of the components used are already provided by the board, with the exception of the Timer1 watch crystal, and a few others (additional resistors, capacitors and switch S3). Design time is minimized and code development is simplified with the use of code libraries and MCC.

The figure shows the block diagram of the design integrated with the Explorer 8 Development Board. The RA2, RB5, RC3 and RC5 pins are the control and communication signals to the 16x2 LCD display via the MCP23S17 I/O expander. The RB<2:0> pins are the inputs for the switches. Both the system and timer clock sources use external crystal oscillators for each. The OSC1 and OSC2 pins are connected to the on-board, 8 MHz crystal oscillator as the device’s system clock source. As Timer1 needs to run in Sleep mode, it is configured to operate asynchronously to the device, connected to an external watch crystal through the SOSCI and SOSCO pins. Using a crystal oscillator is the least expensive and has the quickest start-up time. Timer1 is where an accurate frequency is required. A good choice for a crystal is a 32.786 kHz (watch) crystal.

Sources: Microchip

Join the Conversation!

User must log-in to comment.

Add Comment

You must log-in to comment.