what crystal oscillator should i use??

Discussion in 'General Electronics Chat' started by Sonoma_Dog, Sep 13, 2008.

  1. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    Hey all, i am trying to build a digital stop watch with TAmega168. So I am wondering what crystal oscillator should i be using? :confused: I know that a 16MHz will not work, because it doesn't divide even to one second.

    Thanks in advance!!
     
  2. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    You could use an I2C real-time clock chip running on a 32,768 Hertz crystal.

    hgmjr
     
  3. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    For example: DS1307

    hgmjr
     
  4. bertus

    Administrator

    Apr 5, 2008
    15,647
    2,346
  5. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    You would connect this chip up to the 2-wire interface (TWI) on the ATMEGA168.

    hgmjr
     
  6. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Use the 16-bit timer and the prescaler on the mega168 to get your 1Hz signal while using a crystal that divides evenly by the prescaler:
    4, 8, and 16 MHz all work. The 32.768 kHz crystal also works with the 8-bit T0 or T2

    Also use the CTC or PWM modes so the mega168 auto-reloads the timer.
     
  7. Sonoma_Dog

    Thread Starter Active Member

    Jul 24, 2008
    99
    0
    are you saying that 16Mhz, 4Mhz and 8Mhz clock will also works for digital stop watch? but they don't divide evenly with 2^X to get 1 Hz.

    Thanks
     
  8. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    You could use Timer 1 in CTC mode and set OCRA1 = 0xf424 and the prescaler to 256 if you are using a 16MHz crystal. This is the clear timer on compare match mode which you set a value and the timer will count to that value then reload automagically while triggering an interrupt
     
Loading...