avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-chat] 32768 Hz clock


From: Royce Pereira
Subject: [avr-chat] 32768 Hz clock
Date: Sat, 22 Apr 2006 19:53:57 +0530
User-agent: Opera M2/9.0 (Win32)

Hi all,

I built an experimental digital clock using Mega8. The output is 7 seg  
HH:MM:SS.
System clock is internal 1MHz RC oscillator.
A 32768 Hz watch crystal is connected to TOSC1 & TOSC2.
Timer2 is used with the following setup upon reset-

        ASSR |= 1<<AS2; //select external asynchronus clock.

      TCCR2=0x9;    //prescaler= CK/1
      OCR2=64;    //512 interrupts per sec
      TCNT2=0;

      while(ASSR & 7){ } //wait for busy flags.

      TIMSK=0x80;    //Enable Timer2 comp interrupt.

      sei();      //enable global interrupt

In my ISR I have:

ISR(TIMER2_COMP_vect)
   {
      if(!--sec)
         {
            sec=512;
                //update time every sec..
          }
        return;
   }

However, comparing to my wristwatch,  I find my clock falls behind about 1 
minute every hour, so after 10 hrs, it's behind by 10 mins! My code above seems 
OK. Are there any hardware issues I need to address? Thanks for any help!

Regards,
-Royce



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]