]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
- Set DCO calibrate target back to 4096 binary kHz
authorvlahan <vlahan>
Tue, 10 Jul 2007 00:24:31 +0000 (00:24 +0000)
committervlahan <vlahan>
Tue, 10 Jul 2007 00:24:31 +0000 (00:24 +0000)
- Add new command/event in Msp430ClockInit to enable overriding of the startup values for the DCO calibrate routine
- Modify PlatformC/PlatformP in platform/telosa to use intermediate configuration MoteClockC that can be used to override the default clock initialization via MoteClockP
- Add MoteClockC and MoteClockP in platform/telosb to allow for usage of the DCOR flag / ROSC on tmote sky. The overriding configuration is currently disabled pending closer review of the calibration routine behavior for the new setup and other potential gotchas

tos/chips/msp430/timer/Msp430ClockInit.nc
tos/chips/msp430/timer/Msp430ClockP.nc
tos/chips/msp430/timer/Msp430DcoSpec.h
tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h
tos/platforms/telosa/MoteClockC.nc [new file with mode: 0644]
tos/platforms/telosa/PlatformC.nc
tos/platforms/telosa/PlatformP.nc
tos/platforms/telosb/MoteClockC.nc [new file with mode: 0644]
tos/platforms/telosb/MoteClockP.nc [new file with mode: 0644]

index 0c0e24e88052d311b3a34d56053b33819e731fea..e78caf1826b5f9f6d6e578166891bee9ddd3d968 100644 (file)
 
 /**
  * @author Cory Sharp <cssharp@eecs.berkeley.edu>
+ * @author Vlado Handziski <handzisk@tkn.tu-berlin.de>
  */
 
 interface Msp430ClockInit
 {
+  event void setupDcoCalibrate();
   event void initClocks();
   event void initTimerA();
   event void initTimerB();
 
+  command void defaultSetupDcoCalibrate();
   command void defaultInitClocks();
   command void defaultInitTimerA();
   command void defaultInitTimerB();
index 094cda714f7652a649361b9bbc1e42a5e72c6e9d..080facc7a4963be230e4c8d1134b3da6869ecf72 100644 (file)
@@ -22,6 +22,7 @@
 
 /**
  * @author Cory Sharp <cssharp@eecs.berkeley.edu>
+ * @author Vlado Handziski <handzisk@tkn.tu-berlind.de>
  */
 
 #include <Msp430DcoSpec.h>
@@ -44,10 +45,22 @@ implementation
   enum
   {
     ACLK_CALIB_PERIOD = 8,
-    ACLK_HZ = 32768U,
-    TARGET_DCO_DELTA = (TARGET_DCO_HZ / ACLK_HZ) * ACLK_CALIB_PERIOD,
+    TARGET_DCO_DELTA = (TARGET_DCO_KHZ / ACLK_KHZ) * ACLK_CALIB_PERIOD,
   };
 
+
+  command void Msp430ClockInit.defaultSetupDcoCalibrate()
+  {
+  
+    // --- setup ---
+
+    TACTL = TASSEL1 | MC1; // source SMCLK, continuous mode, everything else 0
+    TBCTL = TBSSEL0 | MC1;
+    BCSCTL1 = XT2OFF | RSEL2;
+    BCSCTL2 = 0;
+    TBCCTL0 = CM0;
+   }
+    
   command void Msp430ClockInit.defaultInitClocks()
   {
     // BCSCTL1
@@ -99,6 +112,11 @@ implementation
     TBCTL = TBSSEL0 | TBIE;
   }
 
+  default event void Msp430ClockInit.setupDcoCalibrate()
+  {
+    call Msp430ClockInit.defaultSetupDcoCalibrate();
+  }
+  
   default event void Msp430ClockInit.initClocks()
   {
     call Msp430ClockInit.defaultInitClocks();
@@ -174,14 +192,6 @@ implementation
     int calib;
     int step;
 
-    // --- setup ---
-
-    TACTL = TASSEL1 | MC1; // source SMCLK, continuous mode, everything else 0
-    TBCTL = TBSSEL0 | MC1;
-    BCSCTL1 = XT2OFF | RSEL2;
-    BCSCTL2 = 0;
-    TBCCTL0 = CM0;
-
     // --- calibrate ---
 
     // Binary search for RSEL,DCO,DCOMOD.
@@ -211,6 +221,7 @@ implementation
 
     atomic
     {
+      signal Msp430ClockInit.setupDcoCalibrate();
       busyCalibrateDco();
       signal Msp430ClockInit.initClocks();
       signal Msp430ClockInit.initTimerA();
index 186461ae81e6fd972f1e5f06af7b99c73453106a..84ce060ac3f19be1a1e4f87a54c70f307875522f 100644 (file)
@@ -30,7 +30,7 @@
 /**
  * Specify the target cpu clock speed of your platform by overriding this file.
  *
- * Be aware that tinyos relies on binary 4Mhz, that is 4096000 Hz.  Some
+ * Be aware that tinyos relies on binary 4MHz, that is 4096 binary kHz.  Some
  * platforms have an external high frequency oscilator to generate the SMCLK
  * (e.g. eyesIFX, and possibly future ZigBee compliant nodes). These
  * oscillators provide metric frequencies, but may not run in power down
@@ -44,6 +44,6 @@
 #ifndef MS430DCOSPEC_H
 #define MS430DCOSPEC_H
 
-#define TARGET_DCO_HZ 4096000 // the cpu clock rate in Hz
-
+#define TARGET_DCO_KHZ 4096 // the target DCO clock rate in binary kHz
+#define ACLK_KHZ 32 // the ACLK rate in binary kHz
 #endif
index 98bf085ac3512f56006dcb939a5d1fef59f35d1a..89f4ebb984d2e62ea5a4a42cc4dd8a517a11983a 100644 (file)
@@ -40,6 +40,6 @@
 #ifndef MS430DCOSPEC_H
 #define MS430DCOSPEC_H
 
-#define TARGET_DCO_HZ 4000000 // the cpu clock rate in Hz
-
+#define TARGET_DCO_KHZ 3904 // the target MCLK clock rate in binary kHz (4 000 000 Hz)
+#define ACLK_KHZ 32 // the ACLK rate in binary kHz
 #endif
diff --git a/tos/platforms/telosa/MoteClockC.nc b/tos/platforms/telosa/MoteClockC.nc
new file mode 100644 (file)
index 0000000..12df90b
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2007, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universität Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id$
+ *
+ */
+
+ /**
+ * @author Vlado Handziski <handzisk@tkn.tu-berlind.de>
+ */
+configuration MoteClockC
+{
+  provides interface Init as MoteClockInit;
+}
+implementation
+
+{
+  components Msp430ClockC;
+  
+  MoteClockInit = Msp430ClockC.Init;
+}
index ca1ad4141f3788d0e59aa7d08a094f540965a860..812f8d33ab4418b28d379c51671f2d8a573a6801 100644 (file)
@@ -32,10 +32,10 @@ configuration PlatformC
 }
 implementation
 {
-  components PlatformP, MotePlatformC, Msp430ClockC;
+  components PlatformP, MotePlatformC, MoteClockC;
 
   Init = PlatformP;
-  PlatformP.Msp430ClockInit -> Msp430ClockC.Init;
+  PlatformP.MoteClockInit -> MoteClockC;
   PlatformP.MoteInit -> MotePlatformC;
 }
 
index 144517896b977bd20e20a125ab768f381ec589cf..93c1b6fdb7941fc996e017f1cd0799918d3507d9 100644 (file)
@@ -2,13 +2,13 @@
 
 module PlatformP{
   provides interface Init;
-  uses interface Init as Msp430ClockInit;
+  uses interface Init as MoteClockInit;
   uses interface Init as MoteInit;
   uses interface Init as LedsInit;
 }
 implementation {
   command error_t Init.init() {
-    call Msp430ClockInit.init();
+    call MoteClockInit.init();
     call MoteInit.init();
     call LedsInit.init();
     return SUCCESS;
diff --git a/tos/platforms/telosb/MoteClockC.nc b/tos/platforms/telosb/MoteClockC.nc
new file mode 100644 (file)
index 0000000..4fe3391
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2007, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universität Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id$
+ *
+ */
+ /**
+ * @author Vlado Handziski <handzisk@tkn.tu-berlind.de>
+ */
+configuration MoteClockC
+{
+  provides interface Init as MoteClockInit;
+}
+implementation
+
+{
+  components Msp430ClockC, MoteClockP;
+  
+  MoteClockInit = Msp430ClockC.Init;
+  //MoteClockP.Msp430ClockInit -> Msp430ClockC;
+}
diff --git a/tos/platforms/telosb/MoteClockP.nc b/tos/platforms/telosb/MoteClockP.nc
new file mode 100644 (file)
index 0000000..bd3cfdc
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2007, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universität Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $Id$
+ *
+ */
+  /**
+ * @author Vlado Handziski <handzisk@tkn.tu-berlind.de>
+ * @author Cory Sharp <cssharp@eecs.berkeley.edu>
+ */
+module MoteClockP {
+  uses interface Msp430ClockInit;
+}
+
+implementation {
+
+  event void Msp430ClockInit.setupDcoCalibrate()
+  {
+  
+    // --- setup ---
+
+    TACTL = TASSEL1 | MC1; // source SMCLK, continuous mode, everything else 0
+    TBCTL = TBSSEL0 | MC1;
+    BCSCTL1 = XT2OFF | RSEL2;
+    BCSCTL2 = DCOR; // enable DCOR
+    TBCCTL0 = CM0;
+   }
+    
+  event void Msp430ClockInit.initClocks()
+  {
+    // BCSCTL1
+    // .XT2OFF = 1; disable the external oscillator for SCLK and MCLK
+    // .XTS = 0; set low frequency mode for LXFT1
+    // .DIVA = 0; set the divisor on ACLK to 1
+    // .RSEL, do not modify
+    BCSCTL1 = XT2OFF | (BCSCTL1 & (RSEL2|RSEL1|RSEL0));
+
+    // BCSCTL2
+    // .SELM = 0; select DCOCLK as source for MCLK
+    // .DIVM = 0; set the divisor of MCLK to 1
+    // .SELS = 0; select DCOCLK as source for SCLK
+    // .DIVS = 2; set the divisor of SCLK to 4
+    // .DCOR = 1; select internal resistor for DCO
+    BCSCTL2 = DIVS1 | DCOR;
+
+    // IE1.OFIE = 0; no interrupt for oscillator fault
+    CLR_FLAG( IE1, OFIE );
+  }
+
+  event void Msp430ClockInit.initTimerA()
+  {
+    TAR = 0;
+
+    // TACTL
+    // .TACLGRP = 0; each TACL group latched independently
+    // .CNTL = 0; 16-bit counter
+    // .TASSEL = 2; source SMCLK = DCO/4
+    // .ID = 0; input divisor of 1
+    // .MC = 0; initially disabled
+    // .TACLR = 0; reset timer A
+    // .TAIE = 1; enable timer A interrupts
+    TACTL = TASSEL1 | TAIE;
+  }
+
+  event void Msp430ClockInit.initTimerB()
+  {
+    TBR = 0;
+
+    // TBCTL
+    // .TBCLGRP = 0; each TBCL group latched independently
+    // .CNTL = 0; 16-bit counter
+    // .TBSSEL = 1; source ACLK
+    // .ID = 0; input divisor of 1
+    // .MC = 0; initially disabled
+    // .TBCLR = 0; reset timer B
+    // .TBIE = 1; enable timer B interrupts
+    TBCTL = TBSSEL0 | TBIE;
+  }
+}