|
|
|
|
EE Design > In Technical
Title: Implementing software Real-Time Clock in PIC Microcontrollers Author: Vincent Wong Date: 29th March 2005 To setup timer 1 as a low power Real-Time Clock, a low frequency 32.768 KHz crystal is connected to the T1OSI and T1OSO pins of the PIC MCU. We will make timer 1 to reload every 1 sec interval, as an example to demonstrate this function. Setting up Timer 1 : In the initialization routine, we need to enable the timer oscillator, select do not sync and select external clock source. If prescaller is set to 1:1, and the crystal is 32.768 KHz, therefore
1 sec x 322768 Hz = d'(65535 - TMR1H TMR1L) TMR1H TMR1L = 32767 = 7FFFh Therefore, we have obtained the appropriate values for TMR1H = 7Fh TMR1L= FFh |