Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Difficulty getting CC2420 CW mode running

$
0
0

Hi, Hi I am using the CC2420 2.4 GHz IEEE 802.15.4 / ZigBee-ready RF Transceiver in my Contiki-run Zolertia motes. I cannot get the CW mode to run, despite performing all the needed steps. I verified that no tone was produce by using a spectrum analyser.

Here is the code I am using (note it is contiki orientated):

#include "dev/cc2420.h"
#include "dev/cc2420_const.h"

#include "contiki.h"
#include <stdio.h>
#include <string.h>


/*---------------------------------------------------------------------------*/
#define BUSYWAIT_UNTIL(cond, max_time) \
do { \
rtimer_clock_t t0; \
t0 = RTIMER_NOW(); \
while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \
} while(0)
/*---------------------------------------------------------------------------*/
static void
strobe(enum cc2420_register regname)
{
CC2420_STROBE(regname);
}
/*---------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------*/
static void
setreg(enum cc2420_register regname, unsigned value)
{
CC2420_WRITE_REG(regname, value);
}
/*---------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------*/
static unsigned
getreg(enum cc2420_register regname)
{
unsigned reg;
CC2420_READ_REG(regname, reg);
return reg;
}
/*---------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------*/
static unsigned int
status(void)
{
uint8_t status;
CC2420_GET_STATUS(status);
return status;
}
/*---------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------*/
PROCESS(single_carrier, "Process to generate umodulated carrier on CC2420 RF pins."); //definition of processs and name for debugging
AUTOSTART_PROCESSES(&single_carrier); //load on boot
/*---------------------------------------------------------------------------*/

PROCESS_THREAD(single_carrier, ev, data) //content of the process
{
PROCESS_BEGIN(); //begining on the process - this should come before any variables are intialised
printf("Process begun...\n");

/* Turn on voltage regulator and reset. */
SET_VREG_ACTIVE();
clock_delay(250);
SET_RESET_ACTIVE();
clock_delay(127);
SET_RESET_INACTIVE();
clock_delay(125);

/* Turn on the crystal oscillator. */
strobe(CC2420_SXOSCON);

BUSYWAIT_UNTIL((status() & (BV(CC2420_XOSC16M_STABLE))), RTIMER_SECOND / 10);
printf("Crystal oscillator enabled. \n");

//set the TX_MODE
setreg(CC2420_MDMCTRL1, 0x0508);
printf("MDMCTRL1 register value: %d \n", getreg(CC2420_MDMCTRL1));

//write 0x1800 to DACTST
setreg(CC2420_DACTST, 0x1800);
printf("DACTST register value: %d \n", getreg(CC2420_DACTST));

//set channel
cc2420_set_channel(17);
printf("New channel: %d\n", cc2420_get_channel());

//set txpower
cc2420_set_txpower(31);
printf("tx_power: %d\n",cc2420_get_txpower() );

//issue STXON command strobe
//strobe(CC2420_STXCAL);
strobe(CC2420_STXON);

while(1){}

PROCESS_END(); //defines the end of a process
}

//This is the output I get from running the code on a zolertia mote - note the registers are written correctly.

Rime started with address 193.12.0.0.0.0.0.1
Crystal oscillator enabled.
MAC c1:0c:00:00:00:00:00:01 Contiki-2.6-35-gf5c8cff started. Node id is set to 1.
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26
Tentative link-local IPv6 address fe80:0000:0000:0000:c30c:0000:0000:0001
Starting 'Process to generate umodulated carrier on CC2420 RF pins.'
Process begun...
Crystal oscillator enabled.
MDMCTRL1 register value: 1288 //0x0508
DACTST register value: 6144 // 0x1800
New channel: 17
tx_power: 31

Thanks for your kind help.

Dominic




Viewing all articles
Browse latest Browse all 262198

Trending Articles