From e68d669265efd000076366c097b2761a8f4a44ed Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Sun, 3 Feb 2008 20:58:11 +0000 Subject: [PATCH] Added improvements suggested by Hardy Greich: define CPU speed in one place only (contiki-conf.h), added nop to XTAL settlement delay --- cpu/msp430/msp430.c | 11 ++++++++--- cpu/msp430/msp430.h | 8 +++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cpu/msp430/msp430.c b/cpu/msp430/msp430.c index cea92fbc1..276d556c1 100644 --- a/cpu/msp430/msp430.c +++ b/cpu/msp430/msp430.c @@ -28,20 +28,22 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: msp430.c,v 1.7 2007/11/17 10:28:18 adamdunkels Exp $ + * @(#)$Id: msp430.c,v 1.8 2008/02/03 20:58:11 adamdunkels Exp $ */ #include #include #include +#include "msp430.h" #include "dev/watchdog.h" #include "net/uip.h" + /*---------------------------------------------------------------------------*/ void msp430_init_dco(void) { /* This code taken from the FU Berlin sources and reformatted. */ -#define DELTA 600 +#define DELTA ((MSP430_CPU_SPEED) / (32768 / 8)) unsigned int compare, oldcapture = 0; unsigned int i; @@ -54,7 +56,9 @@ msp430_init_dco(void) crystal DCO frquenzy = 2,4576 MHz */ BCSCTL1 |= DIVA1 + DIVA0; /* ACLK = LFXT1CLK/8 */ - for(i = 0xffff; i > 0; i--); /* Delay for XTAL to settle */ + for(i = 0xffff; i > 0; i--) { /* Delay for XTAL to settle */ + asm("nop"); + } CCTL2 = CCIS0 + CM0 + CAP; // Define CCR2, CAP, ACLK TACTL = TASSEL1 + TACLR + MC1; // SMCLK, continous mode @@ -162,6 +166,7 @@ msp430_cpu_init(void) if((uintptr_t)cur_break & 1) { /* Workaround for msp430-ld bug! */ cur_break++; } + watchdog_start(); } /*---------------------------------------------------------------------------*/ #define asmv(arg) __asm__ __volatile__(arg) diff --git a/cpu/msp430/msp430.h b/cpu/msp430/msp430.h index 9bbe20a3f..33b94490d 100644 --- a/cpu/msp430/msp430.h +++ b/cpu/msp430/msp430.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: msp430.h,v 1.1 2007/03/15 21:38:22 adamdunkels Exp $ + * $Id: msp430.h,v 1.2 2008/02/03 20:58:11 adamdunkels Exp $ */ /** @@ -41,6 +41,12 @@ #ifndef __MSP430_H__ #define __MSP430_H__ +#include "contiki-conf.h" + +#ifdef F_CPU +#define MSP430_CPU_SPEED F_CPU +#else #define MSP430_CPU_SPEED 2457600UL +#endif #endif /* __MSP430_H__ */