From: vlahan Date: Tue, 10 Jul 2007 00:24:31 +0000 (+0000) Subject: - Set DCO calibrate target back to 4096 binary kHz X-Git-Tag: release_tools_1_2_4_1~63 X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=commitdiff_plain;h=c03404945adfe801433985cc0bbf0c0ee622900e;p=tinyos-2.x.git - Set DCO calibrate target back to 4096 binary kHz - 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 --- diff --git a/tos/chips/msp430/timer/Msp430ClockInit.nc b/tos/chips/msp430/timer/Msp430ClockInit.nc index 0c0e24e8..e78caf18 100644 --- a/tos/chips/msp430/timer/Msp430ClockInit.nc +++ b/tos/chips/msp430/timer/Msp430ClockInit.nc @@ -21,14 +21,17 @@ /** * @author Cory Sharp + * @author Vlado Handziski */ 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(); diff --git a/tos/chips/msp430/timer/Msp430ClockP.nc b/tos/chips/msp430/timer/Msp430ClockP.nc index 094cda71..080facc7 100644 --- a/tos/chips/msp430/timer/Msp430ClockP.nc +++ b/tos/chips/msp430/timer/Msp430ClockP.nc @@ -22,6 +22,7 @@ /** * @author Cory Sharp + * @author Vlado Handziski */ #include @@ -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(); diff --git a/tos/chips/msp430/timer/Msp430DcoSpec.h b/tos/chips/msp430/timer/Msp430DcoSpec.h index 186461ae..84ce060a 100644 --- a/tos/chips/msp430/timer/Msp430DcoSpec.h +++ b/tos/chips/msp430/timer/Msp430DcoSpec.h @@ -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 diff --git a/tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h b/tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h index 98bf085a..89f4ebb9 100644 --- a/tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h +++ b/tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h @@ -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 index 00000000..12df90bd --- /dev/null +++ b/tos/platforms/telosa/MoteClockC.nc @@ -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 + */ + +configuration MoteClockC +{ + provides interface Init as MoteClockInit; +} +implementation + +{ + components Msp430ClockC; + + MoteClockInit = Msp430ClockC.Init; +} diff --git a/tos/platforms/telosa/PlatformC.nc b/tos/platforms/telosa/PlatformC.nc index ca1ad414..812f8d33 100644 --- a/tos/platforms/telosa/PlatformC.nc +++ b/tos/platforms/telosa/PlatformC.nc @@ -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; } diff --git a/tos/platforms/telosa/PlatformP.nc b/tos/platforms/telosa/PlatformP.nc index 14451789..93c1b6fd 100644 --- a/tos/platforms/telosa/PlatformP.nc +++ b/tos/platforms/telosa/PlatformP.nc @@ -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 index 00000000..4fe33910 --- /dev/null +++ b/tos/platforms/telosb/MoteClockC.nc @@ -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 + */ + +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 index 00000000..bd3cfdcf --- /dev/null +++ b/tos/platforms/telosb/MoteClockP.nc @@ -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 + * @author Cory Sharp + */ + +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; + } + +}