From 465125c5e77f4042967cbe1fc86126fdb4ef0cc0 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Tue, 23 Feb 2010 18:41:20 +0000 Subject: [PATCH] Added support for 32-bit clock ticks: when reading the 32-bit value, make sure that it does not change between readouts to avoid reading right in the middle of it being updated --- cpu/msp430/clock.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cpu/msp430/clock.c b/cpu/msp430/clock.c index 1f5c79eb5..95740823c 100644 --- a/cpu/msp430/clock.c +++ b/cpu/msp430/clock.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: clock.c,v 1.21 2010/01/30 14:03:35 adamdunkels Exp $ + * @(#)$Id: clock.c,v 1.22 2010/02/23 18:41:20 adamdunkels Exp $ */ @@ -63,7 +63,9 @@ interrupt(TIMERA1_VECTOR) timera1 (void) { /* Make sure interrupt time is future */ do { + /* TACTL &= ~MC1;*/ TACCR1 += INTERVAL; + /* TACTL |= MC1;*/ ++count; /* Make sure the CLOCK_CONF_SECOND is a power of two, to ensure @@ -98,7 +100,12 @@ interrupt(TIMERA1_VECTOR) timera1 (void) { clock_time_t clock_time(void) { - return count; + clock_time_t t1, t2; + do { + t1 = count; + t2 = count; + } while(t1 != t2); + return t1; } /*---------------------------------------------------------------------------*/ void