Skip to content

Commit

Permalink
clock/crystal: use 64 prescaler
Browse files Browse the repository at this point in the history
  • Loading branch information
stettberger committed Jul 25, 2010
1 parent 9a3dee9 commit da511f0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions services/clock/clock.c
Expand Up @@ -60,8 +60,8 @@ clock_init(void)
#ifdef CLOCK_CRYSTAL_SUPPORT
ASSR = _BV(CLOCK_TIMER_AS);
CLOCK_TIMER_CNT = 0;
/* 128 prescaler to get every second an interrupt */
CLOCK_TIMER_TCCR = _BV(CLOCK_SELECT_2) | _BV(CLOCK_SELECT_0);
/* 64 prescaler to get every 0.5 second an interrupt */
CLOCK_TIMER_TCCR = _BV(CLOCK_SELECT_1) | _BV(CLOCK_SELECT_0);

/* Wait until the bytes are written */
#ifdef CLOCK_TIMER_RBUSY
Expand Down Expand Up @@ -96,6 +96,15 @@ SIGNAL(CLOCK_SIG)
OCR1A = 65536-CLOCK_SECONDS+CLOCK_TICKS;
#endif

#if defined(CLOCK_CRYSTAL_SUPPORT)
/* If we use Crystal Support we have an interrupt every 0.5
seconds, so we have to drop every second interrupt */
static uint8_t clock_crystal_interrupt_drop = 0;
clock_crystal_interrupt_drop ^= 1;
if (clock_crystal_interrupt_drop)
return;
#endif

#if defined(NTP_SUPPORT) || defined(DCF77_SUPPORT)
if (!sync_timestamp || sync_timestamp == timestamp)
#endif
Expand Down

2 comments on commit da511f0

@justinotherguy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit appears to cause the clock to run at double speed when using CLOCK_CRYSTAL_SUPPORT - any idea on how to achieve a better "comprimise"?

@eku
Copy link
Contributor

@eku eku commented on da511f0 Jan 27, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinotherguy: check out the latest master, should work now

Please sign in to comment.