CC2520 radio
Work in progress
Description
This page is about aplication of hardware CC2520 with MSP430 or Stellaris from Texas Instruments for wireless control of model railroad (H0 scale) at Institute of Information Theory and Automation in Prague. Here you can get basic knowledge of hardware and software.
Description of aplication
The aplication is wireless sensor network of star topology. One central node and one to six inferior sensor nodes. Central node is also coordinator of wireless network and at the same time gateway for command computer (Matlab Simulink). Sensor nodes are of two types. First type is moving sensor node, which is embedded into model railroad car. Here sensor node drives small DC motor and counts pulses from optical mouse sensor at the bottom of car and receive signals from infrared side sensors. The second type of sensor node drives four railroad switches and senses four infrared gates.
Concept of wireless transmission
Star network topology can conveniently use broadcasting. Central node broadcasts command messages to inferior nodes. Every node sends his answer in fixed time after receving broadcast message. Some regularity is for sensor ntwork communication needed - every node has guaranteed transmission band. Transceiver CC2520 serves for wireless communication. This transceiver defines physical layer of communication stack in its hardware structure. This part is almost compatible with IEEE802.15.4.
Hardware
- TI/Chipcon CC2520 Second generation 2.4 GHz ZigBee/IEEE 802.15.4 RF transceiver
- Development kit based on MSP430 for whole wireless network (2 nodes and additional board for packet sniffing) CC2520DK, picture CC2520DK picture
Stellaris
- Development kit with microcontroller LM3S8962 [1]
Software
MSP430
- official USB driver for TI_USB_FET only for Windows
- TI Smart RF Studio development kit support software link - something for reading transceiver registers, packet sniffing
- pure packet sniffer for development board is here [2]
- TI Z-Stack link
- IAR evaluation version IAR is not so pedantic, getting second evaluation license is possible
- driver for TI_USB_FET under linux [3]
- MSP-GCC UniArch
Stellaris
- good for introduction to development on Stellaris kit under ubuntu [4] [5]
- some tips for eclipse development [6]
Report
April
9th - first contact with CC2520DK, testing factory code (packet error counting), the range seems to be sufficient with antenna (PCB antenna is not connected, it is a little bit confusing in schematic), test with running DC motor (model railway H0 1:87) nearby receiver (bad contact with sparkling), wireless communication is not affected, but program is sometimes corrupted because of sparkling
10th - simple sending packets via Smart RF Studio user guide page 112/113, firmware upgrade (evaluations boards + debugger) - one board without upgrade does not display messages from MSP, debugging of GenericApp (Coordinator + EndDevice)
14th - need replace - uses GPIO0 pin , mac_dualchip.c
void macDualchipTurnOnRadioPower(void) {....}
18th - library functions are in APS.h - Router2618.lib, TIMAC-MSP2618.lib and other (security header files are referencing to Security2618.lib). Details are in .map file after compiling
19th -
1. void macDualchipTurnOnRadioPower(void) {... macSpiWriteReg( GPIOCTRL1, GPIO_DIR_RADIO_OUTPUT | EXCEPTION_CHANNEL_A ); //instead GPIOCTRL0 //macSpiWriteReg( GPIOCTRL1, GPIO_DIR_RADIO_OUTPUT | EXCEPTION_RFC_FIFO ); //wathching this state is not so critical ...} 2. #define HAL_MAC_TX_ACK_DONE_GPIO_BIT 5 //instead 3
Exception EXCEPTION_RFC_FIFO is used only for defining of other states in mac_radio_defs.h and in interrupt service
#define MAC_RADIO_RX_FIFO_HAS_OVERFLOWED() (HAL_MAC_READ_FIFOP_PIN() && !HAL_MAC_READ_FIFO_PIN()) #define MAC_RADIO_RX_FIFO_IS_EMPTY() (!HAL_MAC_READ_FIFO_PIN() && !HAL_MAC_READ_FIFOP_PIN())
HAL_ISR_FUNCTION( halMacFifopIsr, FIFOP_VECTOR() ) {... if (!HAL_MAC_READ_FIFOP_PIN() && HAL_MAC_READ_FIFO_PIN()){ /*It appears that after rxPayloadIsr(), a FIFOP glitch can occur. ...*/ //but rxPayloadIsr() is in this comment only ...} ...}
Mai
12th - first success with SPI communication with radio, MSP is running on internal oscillator, radio needs crystal working in fundamental mode, I recommend KX-K 32,000000 FF 16 .
15th - first communcation with ZigBee coordinator from CC2520DK, but only with CC2520EM in place of radio+antenna,
- original TI Z-Stack needs GPIOs of CC2520 2 to port with interrupt capability, 2 to HW timer and 2 only for read/write
- orignal uses as mac_mcu_timer timerA, so i changed it to timerB
- pin changes
GPIO0 XT1IN clock GPIO1 P2.7 TX_FRM_DONE_BIT | TX_ACK_DONE_BIT GPIO2 P2.6 EXCEPTION_RFC_FIFOP GPIO3 P4.5 EXCEPTION_RFC_SNIFFER_CLK (original function of GPIO5) GPIO4 P4.6 EXCEPTION_RFC_SFD_SYNC GPIO5 P4.7 EXCEPTION_RFC_SNIFFER_DATA (original function of GPIO3)
- clock are running on 8 MHz instead of 6 MHz
- SPI and timer are sourced from ACLK, because SMCLK can't be sourced from XT1IN (MSP430f2618)
15th - again first communication with my complete design of board and coordinator from CC2520DK, simple sending both direction int value every 200 ms and string every 5 seconds, working range about 5 metres (through glass door).
24th - PWM control of DC motor + ADC on CC2520DK (potentiometer) - is done in Z-Stack - hal_adc.c .
PS2 protocol-optical mouse
After power up, Stream report enable (0xF4) command is needed for Stream mode (data transfer after event on mouse) functioning.
October
For beacon enabled PAN are these changes necessary (incomplete, in progress):
- change the DEFAULT_BEACON_ORDER and DEFAULT_SUPERFRAME_ORDER definitions (in ZDApp.c) to the desired beacon rate. The available beacon rates are defined in NLMEDE.h.
- change the stack profile (STACK_PROFILE_ID in nwk_globals.c) to either GENERIC_STAR or GENERIC_TREE (Tree mode is NOT recommended). The beacons will not work with HOME_CONTROLS or BUILDING_AUTOMATION.
- change nwk.h #define DEF_BEACON_ORDER 0 // 15 millisecond, instead #define DEF_BEACON_ORDER 15
- ZdApp.c zgDefaultStartingScanDuration = BEACON_ORDER_15_MSEC; //instead BEACON_ORDER_60_MSEC;
- nwk_globals.c _NIB.beaconOrder = BEACON_ORDER_15_MSEC //instead BEACON_ORDER_NO_BEACONS;
- _NIB.superFrameOrder = BEACON_ORDER_15_MSEC //instead BEACON_ORDER_NO_BEACONS;
But it does't work, I preserve non/beacon network
April
very important about IEEE adress
- TI implemented Z-Stack uses a little bit unsuitable IEEE adress for own HW implementation. It's stored in INFO memory of MSP so it needs to be changed, else there will be more endpoints with same IEEE adress. Coordinator associates one IEEE adress to one end device.