The official git repository for OSD-Contiki, the open source OS for the Internet of Things
Go to file
Atis Elsts 68b65e6c47 Fix CPU clock calibration in msp430f2xxx based platforms (e.g. Zolertia Z1).
The following problems were present in the existing DCO calibration algorithm:

Problem #1. In function msp430_quick_synch_dco(), the "for(i=0; i < 1000; i++) { .. }" loop is optimized away by the compiler, as i is not volatile. Making i volatile would improve the results, but would not be sufficient: see the next point.

Problem #2. According to MSP430F2617 Device Erratasheet, bug BCL12 precludes a naive implementations of "fast" calibration altogether. The bug is present on all MCU revisions up to date.

The description of the bug:
"After switching RSELx bits (located in register BCSCTL1) from a value of >13 to a value of <12 OR from a value of <12 to a value of >13, the resulting clock delivered by the DCO can stop before the new clock frequency is applied. This dead time is approximately 20 us. In some instances, the DCO may completely stop, requiring a power cycle.

Furthermore, if all of the RSELx bits in the BSCTL1 register are set, modifying the DCOCTL register to change the DCOx or the MODx bits could also result in DCO dead time or DCO hang up."

In Contiki code for msp430f2xxx @ 8MHz, the RSEL search currently typically goes from 15 down to 11, thus violating the rules.

Step-by-step RSEL change is proposed as the best possible workaround:
"[..] more reliable method can be implemented by changing the RSEL bits step by step in order to guarantee safe function without any dead time of the DCO."

Problem #3. The old Contiki code started from the highest possible calibration values: RSEL=15, DCOx=7. According to MSP430F2617
datasheet, this means that the DCO frequency is set to 26 MHz. For one, Vcc under 3V is not supported for this frequency, so this means that battery-powered nodes have a big problem. The minimal operating voltages are:
- 1.8V for RSEL <= 13
- 2.2V for RSEL = 14
- 3.0V for RSEL = 15
So the correct way is to always start calibration from RSEL <= 13, unless explicityly pre-calibred values are present.

Problem #4. Timer B should be turned off after the calibration, following the "Principles for Low-Power Applications" in MSP430 user's Guide.

The patch fixes these issues by performing step-by-step calibration and turning off Timer B afterwards. As opposed to MSP430F1xxx calibration, this algorithm does not change the ACLK divider beforehand; attempts to make calibration more precise would lead to looping in some cases, as the calibration step granularity at larger frequencies is quite big.

Additionally, the patch improves DCOSYNCH_CONF_ENABLED behavior, allowing the resynchronization to correct for more than one step.
2014-03-25 11:47:13 +01:00
apps Merge pull request #550 from oliverschmidt/master 2014-01-31 16:22:53 -08:00
core Merge pull request #364 from g-oikonomou/multicast-push 2014-03-18 10:11:11 +01:00
cpu Fix CPU clock calibration in msp430f2xxx based platforms (e.g. Zolertia Z1). 2014-03-25 11:47:13 +01:00
dev Removed all module makefiles. Instead, all .c files in a module directory are compiled. 2014-01-26 23:20:46 +01:00
doc Bumped the version number from 2.6 to 3.x, which is to be used in the development branch 2013-12-12 17:33:18 +01:00
examples Minor code style fixes 2014-03-05 20:31:18 +00:00
platform native: Add CTK to the module list 2014-03-21 23:01:02 +01:00
regression-tests Update regression sims to org.contikios 2014-03-05 20:31:19 +00:00
tools Also remove uninitialized motes 2014-03-20 14:51:05 +01:00
.gitignore Adds support for ADF7023 sub-GHz radio from Analog Devices and RL78 series MCU from Renesas. 2014-01-04 18:56:51 -05:00
.gitmodules Added the cc2538-bsl submodule to the tools dir 2014-03-07 15:44:29 +01:00
.travis.yml Updated cc65 URL. 2014-03-15 16:55:39 +01:00
LICENSE Removed the explicit year 2012 to make it more generic 2012-10-25 23:08:54 +02:00
Makefile.include Removed all module makefiles. Instead, all .c files in a module directory are compiled. 2014-01-26 23:20:46 +01:00
README-BUILDING.md Rename to md 2013-03-26 23:15:37 +01:00
README-EXAMPLES.md Several minor consistency improvements. 2013-07-31 00:55:31 +02:00
README.md Rename to md 2013-03-26 23:15:37 +01:00

The Contiki Operating System

Build Status

Contiki is an open source operating system that runs on tiny low-power microcontrollers and makes it possible to develop applications that make efficient use of the hardware while providing standardized low-power wireless communication for a range of hardware platforms.

Contiki is used in numerous commercial and non-commercial systems, such as city sound monitoring, street lights, networked electrical power meters, industrial monitoring, radiation monitoring, construction site monitoring, alarm systems, remote house monitoring, and so on.

For more information, see the Contiki website:

http://contiki-os.org