From b90075ea0ac2b07d090e0479cadee82b0632944c Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 16 Sep 2008 12:00:48 +0000 Subject: [PATCH] bug fix, msp430 hw bug (undocumented): when in continuous/compare mode the interrupt handler may get called before CCR==TR. behavior observed when the timer is toggled between STOP/CONT in an external interrupt handler (serial input). possibly this problem may also affect watchdog timer/timer B --- cpu/msp430/clock.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cpu/msp430/clock.c b/cpu/msp430/clock.c index a8bcee165..ac71caeab 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.14 2008/07/07 23:38:09 adamdunkels Exp $ + * @(#)$Id: clock.c,v 1.15 2008/09/16 12:00:48 fros4943 Exp $ */ @@ -56,6 +56,11 @@ static unsigned short last_tar = 0; interrupt(TIMERA1_VECTOR) timera1 (void) { ENERGEST_ON(ENERGEST_TYPE_IRQ); if(TAIV == 2) { + + /* HW timer bug fix: Interrupt handler called before TR==CCR. + * Occurrs when timer state is toggled between STOP and CONT. */ + while (TACTL & MC1 && TACCR1 - TAR == 1); + /* Make sure interrupt time is future */ do { TACCR1 += INTERVAL;