Skip to content
Permalink
Browse files

clock/crystal: use 64 prescaler

  • Loading branch information...
stettberger committed Jul 25, 2010
1 parent 9a3dee9 commit da511f074940423e8e8ef7ee67ca20e6d91f608c
Showing with 11 additions and 2 deletions.
  1. +11 −2 services/clock/clock.c
@@ -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
@@ -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

2 comments on commit da511f0

@justinotherguy

This comment has been minimized.

Copy link
Contributor

replied Jan 22, 2011

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

This comment has been minimized.

Copy link
Contributor

replied Jan 27, 2011

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

Please sign in to comment.
You can’t perform that action at this time.