Boomerang Radio Parameters

From TinyOS Wiki
Jump to: navigation, search

Change frequency at compile time

One way to set the CC2420 radio channel is to do it at compile time by assigning the environment variable CC2420_CHANNEL perhaps like this

export CC2420_CHANNEL=12

The valid channels for the CC2420 are 11 to 26, and the default is channel 11. You can put that export command in your login script such as ~/.bashrc to make it persistent across login sessions. If you want a radio channel specific to an application, you can put a similar command in that application's Makefile, like this

CC2420_CHANNEL=12

The next time you build your application, the changes will take effect. Do not forget to also recompile and reinstall TOSBase with the new channel, as well, if applicable.

Change transmit power at compile time

To change the transmit power at compile time, you will need to predefine a preprocessor directive called CC2420_DEF_RFPOWER. To do this, define your compile flags "CFLAGS" before compiling your application. You must specify a power index from 1 to 31. The valid values are 1 through 31 with power of 1 equal to -25dBm and 31 equal to max power (0dBm)

CFLAGS=-DCC2420_DEF_RFPOWER=x make tmote

Change transmit power or frequency at run time

Another way to set the CC2420 radio channel or transmit power is to use the CC2420Control interface provided by the CC2420RadioC component. The two applicable commands are

command result_t TunePreset( uint8_t rh, uint8_t channel );
command result_t SetRFPower( uint8_t rh, uint8_t power );
rh 
Either RESOURCE_NONE for automatic resource scheduling or a resource handle acquired by the CC2420ResourceC component. Note, this parameter is not present in any of the commands in the TinyOS 1.x CC2420Control interface
channel 
One of the valid 802.15.4 present channels. Valid channel values are 11 through 26. The channel frequencies are calculated by
Freq = 2405 + 5(k-11) MHz for k = 11,12,...,26
power 
A power index from 1 to 31. The input value is simply an arbitrary index that is programmed into the CC2420 registers. The output power is set by programming the power amplifier. The valid values are 1 through 31 with power of 1 equal to -25dBm and 31 equal to max power (0dBm)