chipcon c2420

hi all

(being blunt) i am trying to get two chipcon c2420 to get to talk to each other. any code examples? i am not using zigbee protocol just now.

have a nice day

TK

are these on some OEM’s module are are you working with bare chips?

You’ll need to config

802.15.4 channel #

Tx power level (use max)

PAN ID

destination IEEE address

and the same for the mating unit - reciprocal addresses of course.

The module level products include an API. Many use a Hayes AT command set. I’m not sure what API you have. You don’t want to struggle with the bare MAC layer interface (no API)

thanks

i am using pic18f4620 and flexipanel ezbee modules that have c2420 on them. thinking of using ccs compiler. havent decided on an api yet, any recommendations?

by API I meant the serial port protocol that your module uses. Such as Hayes AT commands as the MaxStream XBee and others in the $20 area use. Most also support a binary mode API if you prefer, because the AT command API is fine for transparent serial port mode, but awkward for things like setting the destination address for a given transmission (if you vary it).

EDIT: I looked at the PCB you are using. I see your problem. That’s a board with just the radio, no ZigBee stack, no API. Just a bare i2c port to talk to the radio chip. Kind of crude compared to today’s PCB modules.

It’s a bare RF module, the design may be a bit crude but I prefer an SPI interface to a UART. Very much a Zigbee MIRF (go sparky go!). How much was the module?

As for interfacing, I believe that there’s a Microchip app note with some data for this… AN965.

http://www.microchip.com/stellent/idcpl … e=en021878

I think you should be able to look over their Zigbee code documentation and code on how they talk to the 2420 to help design a simpler system for yourself.

I guess I’m lazy.

Just pay $20 for a MaxStream XBee or $35 or so for the XBeePro (60mW).

Plug it into a socket.

It works.

ZigBee optional.

$75 or so for the XBeePro module in a metal box with antenna and USB connctor to talk to PC as a mesh coodinator

Nah, different needs. I do a lot of CAN peripheral work and use integer MHZ based clocking to sustain 1Mbps connections there, so syncing to a standard UART baud rate is a pain (depending on MCU) without a second processor bridging via SPI. That’s just silly. I like being able to burst in a packet via SPI at 10MHz and then do something else for a while. I can use (and just might) the Maxstream modules, but I’d kill for an SPI comm system instead.

While I know you can program the Maxstream modules, they make me nervous if you can’t put them back to normal if the grand experiment doesn’t work out.

Yeah, I don’t think it’s wise to muck about inside the ZigBee microprocessor to add your application unless you are spending $$$$$ of NRE. Otherwise, a cheap microprocessor, outboard, is prudent.

After init, XOSC stable (got 0x40 status), i do following to test if it’s working:

TX Side:

	cc2420_set_register(17,2802);
	cc2420_SetChannel(17);
	CC2420_SetShortAddress(34);
	CC2420_SetPanID(12);

	cc2420_command(CC2420CMD_SFLUSHTX);
	cc2420_command(CC2420CMD_SRXON);

   	cc2420_set_register(CC2420REG_TXFIFO, 13+RDGBUFSIZE*4);		// length

   	cc2420_set_register(CC2420REG_TXFIFO, 136); 	// FCF
   	cc2420_set_register(CC2420REG_TXFIFO, 33);

   	cc2420_set_register(CC2420REG_TXFIFO, (U8)pktcnt);	 // sequence number



   	cc2420_set_register(CC2420REG_TXFIFO, 0);		// dest. PAN
   	cc2420_set_register(CC2420REG_TXFIFO, PANID);


   	cc2420_set_register(CC2420REG_TXFIFO, 0);		// dest. adr
   	cc2420_set_register(CC2420REG_TXFIFO, 56);


   	cc2420_set_register(CC2420REG_TXFIFO, 0);		// src. PAN
   	cc2420_set_register(CC2420REG_TXFIFO, PANID);

   	cc2420_set_register(CC2420REG_TXFIFO, 0);	   // src. adr.
   	cc2420_set_register(CC2420REG_TXFIFO, SHORTADDRESS);

	/* payload */

	for (j=0; j<RDGBUFSIZE; j++) {
	    for (i = 0; i <4 ; i++) {     
		  data = (U8)rdgbuf[j][i];  
		  cc2420_set_register(CC2420REG_TXFIFO, data);     
		  data = (U8)(rdgbuf[j][i]>>8);  
		  cc2420_set_register(CC2420REG_TXFIFO, data);     
		}
	}

	cc2420_command(CC2420CMD_STXONCCA);

RX side:

  CC2420_SetShortAddress(SHORTADDRESS);
  CC2420_SetPanID(PANID);
  cc2420_SetChannel(RFCHANNEL);
  cc2420_command(CC2420CMD_SFLUSHRX);
  cc2420_command(CC2420CMD_SRXON);

And then I wait for IRQ.

ISR looks something like this:

	cc2420_get_register(CC2420REG_RXFIFO, &length);
	for (j=0; j<11; j++) { 
	  cc2420_get_register(CC2420REG_RXFIFO, &rxdata); // strip out header
	  length--;
	}
    // get data
	for (j=0; j<RDGBUFSIZE; j++) {
	    for (i = 0; i != 4; i++) { 
		  cc2420_get_register(CC2420REG_RXFIFO, &rxdata);    
 	  	  length--;
		  rdgbuf[j][i] = rxdata;  
		  cc2420_get_register(CC2420REG_RXFIFO, &rxdata);    
 	  	  length--;
		  rdgbuf[j][i] |= rxdata<<8;  
		}
	}
	while (length>2) {
	  cc2420_get_register(CC2420REG_RXFIFO, &rxdata); 
	  length--;
	}
    cc2420_get_register(CC2420REG_RXFIFO, &rxdata);    	// RSSI
	ed = (S8)rxdata;
	ed -= 190;
	cc2420_get_register(CC2420REG_RXFIFO, &rxdata); // CORR

This code transfers ADC reading buffer from one device to another:

U16 rdgbuf[RDGBUFSIZE][4];		// ADC readings buffer