Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

EE Design > In Technical
| Home | Contact |

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

      Time(sec) = [ d'(FFFFh - TMR1H TMR1L)' / Crystal clock(Hz) ]
      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



| Home | Top Page | Contact |


Copyright Notice: This article, including all text, documents and schematic diagrams, are the intellectual property of Vincent Wong, and is Copyright (c) 2005. Reproduction or re-publication by any means whatsoever, whether it is electrical & electronic, mechanical or electro-mechanical, is strictly prohibited under International Copyright laws. The author (Vincent Wong) grants the reader the right to use this information for personal use only. Commercial use is prohibited without express written authorisation from Vincent Wong.

Copyright of Vincent Wong. All Rights Reserved.