Home
thesis - Personal Web Pages - University of North Carolina at Charlotte
Contents
1. define UART BAUD 4K8 207 define UART BAUD 9K6 103 define UART BAUD 14K4 68 define UART BAUD 19K2 51 define UART BAUD 28K8 34 define UART BAUD 38K4 25 define UART BAUD 57K6 16 define UART BAUD 76K8 12 define UART BAUD 115K2 8 define UART BAUD 230K4 3 define UART BAUD 250K 3 define UART BAUD 500K 1 define UART BAUD 1M 0 else CPUCLOCK 16 baud 1 define UART BAUD 2K4 207 define UART BAUD 4K8 103 define UART BAUD 9K6 51 define UART BAUD 14K4 34 define UART BAUD 19K2 25 define UART BAUD 28K8 16 define UART BAUD 38K4 12 define UART BAUD 57K6 8 define UART BAUD 76K8 6 define UART BAUD 115K2 3 define UART BAUD 230K4 a define UART_BAUD_250K 1 define UART BAUD 500K 0 define UART BAUD 1M 0 not supported endif define XMIT BUF SIZI define RECV BUF SIZI 250 250 extern volatile UINT8 uart xmit buf XMIT BUF SIZI extern volatile UINT8 uart xmit buf RECV BUF SIZI UINT8 USART1 Send UINT8 UINT8 UINT8 USART1_Init UINT8 UINT8 UINT8 UINT8 UINT8 USART1 Recv UINT8 endif f KA k KKK ke e x A x END HK ck kk k kc k kck RR KAR KAR KAR RAR ke ke x kx x 56 OK K K kk k k Ck Ck Ck k kk kk kk Ck Ck Ck Ck AAA KR File Na Version Author License Purpose me USART c Oat Sandeep Sirpatil GNU General Public License A circular buffer device driver for UART ACKC
2. ESC_ESC buf il return USART1 Send idx slip xmit buf int SLIP getFrame UINT8 buf UINT16 size UINT16 i 32 33 check the frame status if slip rcv frame isEmpty FALSE containe a new frame If new frame is available copy the data and clear the receiveframe for i 0 i lt slip rcv frame length i buf i slip rcv frame buffer i size slip_rcv_frame length slip_rcv_frame isEmpty TRUE return 0 Jelsef If no new frame avialable retunr 1 Gl p return l This function is to be called as many times as possible It checks the receiveframe if found empty it tries to get data from the USART layer and assemble a new frame void SLIP_process UINT8 ch int moredata 1 if slip rcv frame isEmpty TRUE if slip rcv frame writeFlag FALSE beginning of a new frame slip rcv frame length 0 while moredata TRUE a getdata flag if USART1 Recv amp ch 0 if a byte is received then process it switch ch case END if slip rcv frame writeFlag FALSE start of new frame slip rcv frame writeFlag TRUE indicate the write is in progress else End of frame received slip rcv frame isEmpty FALSE indicate a new frame is stored slip rcv frame writeFlag FALSE moredata FALSE end the while loop break Case
3. txBuf UPPER BYTE MAC XMIT PACK ET E 1 txBuf 2 17 length txBuf 3 0x34 txBuf 4 0x12 txBuf 5 TRUE ack request txBuf 6 10 fprintf stderr Scanf X amp add if add 0 txBuf 3 txBuf 4 Dest Addr in hex LOWE UPPE R_BY R_BY E add E add fprintf stderr LED Duty Cycle scanf Sd amp duty txBuf 7 LOWER BYTE duty SLIP Send txBuf 17 fprintf stderr Nn Jbreak ng case 2 int chnl 0 62 1 i 22r txBuf 0 LOWER BYTE MAC SET CHANNE txBuf 1 UPPER BYTE MAC SET CHANNE txBuf 2 4 length fprintf stderr nChannel range 11 26 scanf d amp chnl while chnl lt 11 chnl gt 26 fprintf stderr nIncorrect Channel scanf d amp chnl F case 3 case 4 txBuf 3 LOWER BYTE chnl SLIP Send txBuf 4 Jbreak int addr txBuf 0 LOWER BYTE MAC SET ADDR txBuf 1 UPPER BYTE MAC SET ADDR txBuf 2 5 fprintf stderr AnNode address in Hex scanf SX amp addr txBuf 3 LOWER_BYTE addr txBuf 4 UPPER_BYTE addr SLIP_Send txBuf 5 Jbreak int rxCntrl txBuf 0 LOWER BYTE MAC SET RECEIVER txBuf 1 UPPER BYTE MAC SET RECEI
4. int SLIP Term return port Close int port Open int ret Function definitions of local functions E ca O NOCTTY this is not the controlling terminal program else Cntr C will close process O NDELAY or O NONBLOCK Do not care abt DCD line status and non blocking read fd open dev ttyAM1 O_RDWR fd open PORT O RDWR O NOCTTY if fd 1 return 1 port open failed O_NOCTTY O_NDELAY O_NDELAY tcgetattr fd amp oldconfig save the old config 65 change and enable receiver int 66 tcgetattr fd amp newconfig Set the port speed parameters cfsetispeed amp newconfig BAUD RATE cfsetospeed amp newconfig BAUD RATE 8N1 newconfig c cflag amp PARENB newconfig c cflag amp CSTOPB newconfig c cflag amp CSIZE newconfig c cflag CS8 newconfig c cflag amp CRTSCTS No Flow control newconfig c cflag CLOCAL CREAD local line no ownew set line parameters for raw input ie no processing newconfig c lflag 8 ICANON ECHO ECHOE ISIG Input flags newconfig c iflag amp IXON IXOFF IXANY Output flags newconfig c oflag amp OPOST raw output set the new options to the port ret tcsetattr fd TCSANOW amp newconfig return 0 port Close restore old port settinngs if fd 0 amp amp
5. FIGURE 2 7 FIGURE 2 8 FIGURE 2 9 vii LIST OF FIGURES Star and peer to peer networks 4 8 LR WPAN device architecture 1 10 The channel structure in IEEE 802 15 4 4 11 The PHY packet structure ML Een o a OR be i e es 12 The format of a genral MAC frame 4 13 A MAC superframe structure Ale 15 Communication to a coordinator in a beacon enabled network 1 16 Communication to a coordinator in a non beacon enabled network 1 16 Communication from a coordinator in a beacon enabled network 1 17 FIGURE 2 10 Communication from a coordinator in a nonbeacon enabled network 1 18 FIGURE 3 1 FIGURE 3 2 FIGURE 3 3 FIGURE 4 1 FIGURE 4 2 FIGURE 4 3 FIGURE 4 4 FIGURE 4 5 FIGURE 4 6 FIGURE 4 7 CC2420 simplified block diagram 6 22 CC2420DB Overview 5 5 5 2 o oed ess 23 TS 7200 Hardware Components 8 26 Setup OVEL VAC anna 28 Software structure and data TOW ioci si 32 The structure of MAC Packet u al 22 Packet Transmission Mechanism 36 Packet receiving mechanism us eoe nn Le oe AA A 37 Test program Teil eSATA UNS de a E Se ne us 39 A received frame by test program ar as GU es 39 viii LIST OF TABLE TABLE 2 1 Frequency bands and data rates T ee ee 11 ADC AES ALU API ARM CC2420DB CPU CRC CSMA CA DHCP DLL DSSS ext2 FCS FFD FIFO G
6. FrameID and Length fields take 3 bytes consequently a maximum of 252 bytes is available for the Data field The MAC layer defines a function called MAC Process which must be called often This function receives packets from SLIP and processes them accordingly It is best to place a call to this function in the infinite loop part of the software if the software is multi threaded a separate thread can be assigned to execute this function periodically 4 4 2 Linux Serial Line Internet Protocol SLIP The SLIP was designed to encapsulate IP datagram and send it over serial lines It encapsulates data to form frames so that the receiving end can differentiate the frames and provide the data to the upper layers SLIP protocol defines two special characters END octal 300 and ESC octal 333 To send a packet a starting character of END is sent first it is followed by the data in the packet If a data byte is the same code as END character a two byte sequence of ESC and octal 334 is sent instead If it is the same as an ESC character a two byte sequence of ESC and octal 335 is sent instead After the entire data in the packet is sent an END character is sent to end the frame 9 SLIP encapsulation drops corrupted packets thus ensuring that the MAC layer 34 always receives a complete data packet SLIP is a simple protocol and causes very less overhead 4 4 3 Linux
7. HAL and Basic RF Library The Hardware definition files define macros to the registers in the microcontroller and CC2420 thus providing an easier way to access the hardware To support program development hardware abstraction layer presents with functions and macros to access most of the CC2420 and microcontroller resources These functions and macros can be used without hardware specific knowledge The Basic RF library provides simple function to send and receive 802 15 4 packets through CC2420 4 4 5 ATmegal28L SLIP The SLIP layer functionality is the same as in Linux s SLIP layer It encapsulates every MAC frame being sent and unpacks every received frame and provides it to the MAC layer The current implementation buffers a single MAC frame received 4 4 6 ATmegal28L Serial driver The serial driver provides an interrupt based buffered mechanism for transmitting and receiving data It implements two circular buffers for transmission and reception The data being transmitted is copied to the transmit buffer and the transmit interrupt is triggered The transmit interrupt routine checks for an available data byte and copies it to the transmit data register if the transmit data buffer is empty it disables further interrupt triggers When a byte of data is received in the microcontroller it triggers the receive interrupt routine which copies the data byte to receive buffer 36 4 5 MAC Communication NODE 1 NODE 2 CC2420DB
8. Preamble packet header data unit PSDU delimiter 6 bytes lt 127 bytes A PHY packet fields Preamble 32 bits synchronization Start of packet delimiter 8 bits signify end of preamble PHY header 8 bits pe ecify length of PSDU PSDU x 127 bytes PHY layer payload Figure 2 4 The PHY packet structure 4 Figure 2 4 illustrates a PPDU Each PPDU contains a synchronization header SHR which consists of a preamble and start of packet delimiter SFD a PHY header PHR containing frame length information and PHY payload or PHY service data unit PSDU The preamble field is used by the transceiver to obtain chip and symbol synchronization with an incoming message The preamble field is composed of 32 binary zeros The SFD is an 8 bit field indicating the end of preamble and start of packet data The PHY header specifies the length of PSDU in bytes The PSDU field is variable and carries the actual PHY packet For all packet types of length five bytes or greater than seven bytes the PSDU contains the MAC sublayer frame 4 2 4 MAC sublayer specification The MAC sublayer provides two services the MAC data service and the MAC management service interfacing to the MAC sublayer management entity MLME 13 service access point SAP The MAC data service enables the transmission and reception of MAC protocol data units MPDU across the PHY data service 1 The features of the MAC sublayer ar
9. Serial port Serial port access in Linux is fairly simple and easy Each serial port on the system is available as a ttyS device file representing the port number 0 for COMI 1 for COM and so on These files are located under dev directory The configuration for the serial port is stored in a structure termios which is defined in the header file termios h The COM2 of the TS 7200 is connected to the CC2420DB which can be accessed by the device file dev ttyAM1 The serial port is configured for sending and receiving of raw data bytes The data can be sent and received via write and read functions respectively The reference 9 is a good guide for serial port programming in Linux 44 4 ATmegal28L MAC This layer complements the Linux s MAC layer with implementation of device specific functionality The MAC layer receives MAC frames from the SLIP layer and processes them When a 802 15 4 packet is received it is wrapped with MAC frame and sent to the Linux MAC layer through SLIP This layer utilizes the sample code provided by Chipcon to communicate with CC2420 The current stack code expects the MAC Process function to be called in the infinite while loop of the microcontroller This function checks for a new 802 15 4 packet processes it it then checks for any new frame in the SLIP layer to process 35 The sample code consists of Hardware definition files Hardware Abstraction Layer
10. uart_Xmit_Ridx UINT8 return 1 buffer full uart xmit buf xmit Widx arryl i xmit_Widx if xmit_Widx XMIT_BUF_SIZE xmit_Widx 0 loop back uart Xmit Widx xmit Widx restore the pointer enable TX int UART1 TX INT ENABLE return 0 USART1 Recv UINT8 ch if uart Recv Ridx RECV BUF SIZE uart Recv Ridx 0 if uart Recv Ridx uart Recv Widx return 1 jelse uart_Recv_Ridx ch uart recv buf uart Recv Ridx 1 return 0 59 Interrupt routine for Receive ISR USART1 RX vect UINT8 ch if uart Recv Widx 1 uart Recv Ridx uart Recv Widx 1 RECV BUF SIZE amp amp uart Recv Ridx err cntr dummy read ch UDRI jelse uart_recv_buf uart_Recv_Widx UDR1 uart Recv Widx if uart Recv Widx RECV BUF SIZE uart Recv Widx 0 ISR for TX ISR USART1 UDRE vect txISRCntr if uart Xmit Ridx XMIT BUF SIZE uart Xmit Ridx 0 loop back if uart Xmit Ridx uart Xmit Widx UART1 TX INT DISABLE jelse uart Xmit Ridx UDR1 uart xmit buf uart Xmit Ridx 1 f KA k KKK ke e x A x END He XX ck kckck EE KE ck kckckck ck kc k ck ck kokckck ck ck ck ck ck kk OK K Kk KK kk Ck Ck k kk kk k k Ck Ck k CK CK kk X K k kk kA Ck kk kk UK OK Ck kckck ck kckckck ck ck ck I I amp File Name util h iS Version 0 1 m Author Sandeep Sirpatil ui License
11. 192 168 100 192 168 0 101 and 192 168 0 102 respectively 28 Router Figure 4 1 Setup overview 4 2 Atmel Development Environment 4 2 1 AVR Studio AVR Studio is an Integrated Development Environment IDE for assembling and debugging AVR application in Windows environment It provides a project management tool source file editor and chip simulator and interfaces with the JTAGICE mkII for downloading and debugging of applications The AVR Studio also has a symbolic source level debugger with features for Break Points variables watch edit single stepping Additional features can be added through the use of plugins 29 4 2 2 WinAVR WinAVR is a suite of executable open source software development tools for the Atmel AVR series of microcontrollers hosted in windows platform The installation and usage Instructions can be found in the user manual 24 The software development tools include Compilers Assemblers Linker Librarian File converters C Library Debugger In Circuit Emulator software Many support utilities All the software for the ATmegal28L microcontroller was developed using WinAVR tools version 20060421 and AVR Studio version 4 12b 4 3 Linux Environment The TS 7200 comes with TS Linux embedded distribution installed in the on board Flash memory TS Linux is a compact distribution based on Busybox ideal for small footprint BusyBox combines tiny versions of many common Linux
12. AC SET CHANNEL 5 AC GET CHANNEL 6 AC SET RECEIVER 7 AC GET RECEIVER 8 AC XMIT PACKE 9 AC RECV PACKET 10 AC SET ACK 11 AC GET ACK 12 ID length segNum SrcAdd srcPanID AckReg Rssi length 1 1 2 2 1 MAC_RECV_PKT_OVERHEAD 11 f KA k k ke k ke e e x A x END XKOKCKCKCKCkCkCk ck kk k kc RRA RR kk kk kok ko ke ke ke ke xe kx EE 1 63 KKK K kk kk Ck Ck Ck k kk kk kk Ck Ck Ck CK CK kk X k k kk k CK Ck kk AX K kCk kc kc kck ck kckckck ck ck KK Version Author License Purpose X RR F ACKCkCk kk ck ck ck ck k ck ck k ck ck k ck ck k ck ck k ck ck k ck ck kk A kk ck kk A ck ck A k ck k k ck k k ck k k kk EEE EEK ifndef SLIP H define SLIP H SLIP define END define ESC define ESC define e END ESC_ESC define SLIP TX BUFF SIZ define SLIP RX define FRAME SIZE File Name SLIP h 0 1 Sandeep Sirpatil GNU General Public License This file contains SLIP configuration and function prototypes definitions 0300 0333 0334 0335 250 500 pa 55 BUFF SIZI 250 Serial port definitions define BAUD RATE define BAUD RATE define BAUD RATE define BAUD RATE define PORT B9600 B57600 B115200 B230400 dev ttyAM1 Function declerations int SLIP Init int SLIP Term int SLIP Process int SLIP Send unsigned char bu
13. ESC slip rcv frame buffer slip rcv frame length slip rcv frame buffer slip rcv frame length f KA k k ke k Koko x A x RK KKK k ke ke ke KK KK ifndef USART_ define USART_ define USART 2X ifdef USART define UART ch else no more moredata while END rx_lastByte ESC break case if rx_lastByte ESC_END keep a ESC END slip_rcv_frame length rx_lastByte 0 else TODO handle error break case ESC ESC if rx lastByte ESC ESC slip rcv frame length rx lastByte 0 else TODO handle error break default S FALSE lip rcv frame length t data in Queue 54 record of it lip rcv frame buffer slip rcv frame length XKOKCKCKCKCkCkCk ck kk kk X kk kk kk kk OK ke e e kx x File Name USART h Version Author License Purpose CPUCLOCK H H r 2XMODE 0 1 GNU Sandeep Sirpatil General Public License Provides varios configuration options for UART driver OD E 1 8 baud 1 T BAUD 2K4 CkCKkCk kk ck k ck ck k ck ck k ck ck k ck ck ck ck ck k ck ck k ck ck AS Puts USART in 2x mode 416 ACKCkCk kCk ck k ck ck A KA k ck ck k ck ck k ck A kk A k ck A k ck A k ck k k kk KA AX Teo x x Eo X X Xx xXx not preferred
14. GNU General Public License X E Purpose provides utility macros OKCKCKCk XX KR KE KE EEK k k kk kc k Ck ck k k k kck kc k kc kck k kckck kc k kc k kck kokckck ck ck ck ck kc ifndef UTIL H define UTIL H define LOWER_BYTE x unsigned char x 4 OxFF define UPPER BYTE x unsigned char x amp OxFF00 gt gt 8 define GET INT x y UINT8 x lt lt 8 UINT8 y endif UTIL H f KA k kok KARA END XKOKCKCKCKCkCkCk ck kk k kc k kck ck kokck ck kk kk ko ke X kk Linux Code BORK KKK KK k k kok k kok RARA RRA HK ko kk i File Name main c E Version 0 1 a Author Sandeep Sirpatil Bi a License GNU General Public License x Purpose Sample test application i KCKCKCKCKCkCKCk Ck A Ck kCk Ck kCkCk k kc k Ck kk k kk k k kc k kck ck K kok kok ck ck ok KI A include include h include lt errno h gt void sig catcher int sig void menu int main unsigned char ch rxBuf 50 txBuf 50 int rxLen 0 int rtn txBuf 0 A txBuf 1 B txBuf 2 ESC txBuf 3 D txBuf 4 E txBuf 5 FES if signal SIGINT sig catcher SIG_ERR fprintf stderr Sigset cannot set SIGINT SLIP Init SLIP Send txBuf 6 while 1 f SLIP Process rtn SLIP Recv rxBuf amp rxLen if rtn 0 fprintf stderr Got a packet n printBuf rxBuf rxLen printP
15. Home Networking with IEEE 802 15 4 A Developing Standard for Low Rate Wireless Personal Area Networks IEEE Communication Magazine August 2002 Chipcon User Manual Rev1 3 SmartRF CC2420DBK Demonstration Board Kit http www chipcon com files CC2420DBK User Manual 1 3 pdf Chipcon SmartRF CC2420 2 4GHz IEEE802 15 4 Zigbee RF Transceiver http www chipcon com files CC2420 Data Sheet 1 4 pdf ATMEL ATMEGA 128L AVR 8 Bit RISC Datasheet http www atmel com dyn resources prod_documents doc2467 pdf TS 7200 Datasheet http www embeddedarm com Manuals ts 7200 datasheet pdf G Frerking Serial programming HOW TO http tldp org HOWTO Serial Programming HOWTO J Romkey RFC 1055 Nonstandard for transmission of IP datagrams over serial lines SLIP http www faqs org rfcs rfc1055 html 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 44 J Lee An Experiment on Performance Study of IEEE 802 15 4 Wireless Networks Proc of Emerging Technologies and Factory Automation 2005 Volume 2 19 22 Sept 2005 Page s 451 458 A Lennon Embedding Linux JEE Review Volume 47 Issue 3 May 2001 Page s 33 37 D Geer Survey Embedded Linux Ahead of the Pack Distributed Systems Online IEEE Volume 5 Issue 10 Oct 2004 Page s 3 3 S Hong Embedded Linux Outlook in the PostPC Industry Proc of Object Orien
16. UNIX utilities into a single small executable A full featured Linux distribution can also be run on either the Network File System NFS root file system or installed on a large CompactFlash card 30 The on board Flash contains the TS Linux kernel which is a standard kernel with patches to customize for this hardware The version of the on board kernel was ts 8 A newer version ts 10 based on standard kernel version 2 4 26 was available and the on board Flash was updated with this version A 512MB CompactFlash card was formatted with the second extended file system ext2 on a desktop running Linux via a USB CompactFlash card reader The customized Debian 3 0 Woody distribution available on Technologic system website was installed on the CompactFlash card The configuration of the RedBoot bootloader was updated to specify the CompactFlash card file system as the root file system to the kernel There are many advantages of running a full featured Linux distribution where the associated tools utilities application and software development environment are available The Debian distribution as a default runs a secure shell SSH server Any SSH client could be used to login into this Linux PuTTY is one such client and is available as free software for many operating environment including windows Its easy to install and configure 23 A terminal over SSH was preferred over the standard terminal available on the serial port as this ter
17. desde 10 24 MAC sublayer specification tete sauna lan 12 2 4 1 MAGC frame Formal ado det a Sde os 13 2 4 2 S perframe CU io ie 14 2 4 3 Data transfer model usina Bean 15 2 4 4 CSMA CA mechanism viii 18 245 ulis Le 19 CHAPTER3 HARDWARE DESCRIPTION ss 20 3 1 System Archie cule sus oe e ee enne Oi Me E 20 32 XC2420 RP TransCelyer vii nest 20 3 3 CC2420DBK Demonstration Board Kit 23 vi 3 3 1 Atmel ATmegal28L Overview sonet to notet eb Ee canicas 24 34 XS 7200 OVERVIEWS oet o pe but os desta dete ui o b oo dade oo oo ce 25 CHAPTER4 SOFTWARE DESCRIPTION ss 27 4 1 SYST SOIL a2 costa tumba bu i dz dal n aaa ou ni 2 4 2 Atmel Development Environment 28 4 2 1 AVR ie A EN 28 4 2 2 RA VR zoo nee a tr A a Vio ead diem 29 43 Ja Environment mar e P eo Ed 29 4 3 1 ru m n k 30 T MEM RAIL DEUM 31 4 4 1 Linux Media Access control MAC 32 4 4 2 Linux Serial Line Internet Protocol SLIP eee 33 4 4 3 Linux Serial POHL u une 34 4 4 4 Almesa PL MAC das 34 4 4 5 ATme gal28 E P e Tin ne se 35 4 4 6 Admegal2 5b Serials driver nn een 35 4 5 MAC Communication 1 oat Min nent ans 36 4 6 O ee 38 CHAPTBRS CONCLUSIODBU siii 41 5 1 Dut re Work ue dete ooo o este genen zen Sessor 42 REFERENCES nn a AEEA 43 APPENDIX CODE as as 46 FIGURE 2 1 FIGURE 2 2 FIGURE 2 3 FIGURE 2 4 FIGURE 2 5 FIGURE 2 6
18. device may communicate with other devices out of its radio reach by routing the message through other devices 2 2 Architecture A set of layers is used to describe the architecture of the LR PAN Each layer is responsible for a logical part of the standard and offers services to the higher layers The layout of layers is based on the open systems interconnection OST seven layer model An LR WPAN device comprises of a PHY which contains the radio frequency RF transceiver along with its low level control mechanism and a MAC sublayer that provides access to the physical channel for all types of transfers 1 Figure 2 2 illustrates the layer arrangement in the standard The upper layers consists of network layer which is responsible for network configuration and message routing and application layer which provides the intended functionality for the device An IEEE 802 2 Type 1 logical link layer LLC can access the MAC sublayer through the service specific convergence sublayer SSCS 1 The LR WPAN architecture can be implemented in either an embedded device or as a device requiring support of an external device such as PC 10 Upper Layers 802 2 LLC SSCS MAC 1 PHY 7 Physical Medium ium Figure 2 2 LR WPAN device architecture 1 2 3 PHY specification The PHY layer is expected to provide two services the PHY data service and PHY management service interfacing to the physical layer management ent
19. enabled networks The current version lacks support for security features which can be implemented The stack can be ported to operating systems such as Windows CE which is another popular embedded operating system As Windows CE is widely used in personal digital assistants and cell phones IEEE 802 15 4 wireless functionality can be added to such devices 1 2 3 4 5 6 7 8 9 10 REFERENCES Institute of Electrical and Electronic Engineers Inc IEEE Std 802 15 4 2003 IEEE Standard for Information Technology Telecommunications and Information Exchange between Systems Local and Metropolitan Area Networks specific Requirements Part 15 4 Wireless Medium Access Control MAC and Physical Layer PHY Specifications for Low Rate Wireless Personal Area Networks LR WPAN http standards ieee org getieee802 download 802 15 4 2003 pdf J A Gutierrez On the use of IEEE 802 15 4 to enable wireless sensor networks in building automation Proc of IEEE Int Conf Personal Indoor and Mobile Radio Communications PIMRC 04 Barcelona Spain September 2004 Vol 3 pp 1865 1869 A Sikora V F Groza Coexistence of IEEE 802 15 4 with other Systems in the 2 4 GHz ISM Band Proc of IEEE Instrumentation and Measurement Technology Conference IMTC 05 Ottawa Canada May 2005 pp 1786 1791 E Callaway P Gorday L Hester J A Gutierrez M Naeve B Heile V Bahl
20. energy use and coexistence issues of IEEE 802 15 4 with other wireless technologies The vast majority of applications will require the use of embedded devices The embedded devices used in the IEEE 802 15 4 wireless nodes can range from a small battery powered sensor to a large central controller with large processing power and data storage ability The central controller can also provide user interface connect with other wired wireless networks and control other devices These central controllers require an embedded operating system for their operation as they have to perform a variety of functions Linux is an open source UNIX like kernel that can be freely distributed under the terms of GNU General Public License GPL Linux was specifically developed as an operating system for server desktop environment Currently there is a lot of interest among the open source community to customize Linux for embedded applications Linux is growing as an embedded operating system of choice because of its advantages such as no licensing fees scalability reliability a large programmer base and community support 12 According to a survey conducted by Venture Development Corporation a technology research and marketing firm Linux owned the highest percentage of new embedded development projects of any operating system 13 Linux is used in industrial controllers network routers commercial devices and home entertainment systems These devices are expected
21. fd 1 tcsetattr fd TCSANOW amp oldconfig close fd fprintf stderr Port closed Wn return 0 test return 1 Max packet size is about 150 bytes int sends a packet through the serial port frammed in slip protocol x SLIP_Send unsigned char buf int len unsigned char slipBuff SLIP TX BUFF SIZE int idx 0 int i send an initial END character to flush out any data that may have accumulated in the receiver due to line noise Ef slipBuff idx END idx for i 0 i lt len i if idx 2 gt SLIP TX BUFF SIZE return 1 buffer overflow switch buf i data equals END then send ESC followed by END case END slipBuff idx ESC idx slipBuff idx ESC END idx break case ESC slipBuff idx idx slipBuff idx ESC ESC idx break default slipBuff idx bufli idx Ei n Q lt slipBuff idx END end of frame idx printBuf slipBuff 10 debug if idx write fd slipBuff idx fprintf stderr write succ n return 0 write success jelse return 1 write failure int SLIP_Recv unsigned char buf int length int if rx frame isEmpty FALSE for i 0 i lt rx_frame length i t t buf i rx_frame buffer i length rx_frame length rx_frame isEmpty TRUE jelsel
22. kc A X XX kckckck ck kc k ck ck kokckckck ck kk KKK KK kk k k kk Ck k kk kk kk Ck Ck Ck CK CK kk X K k HH kk K K kk ck ck ck ck kckckck ck ck k kk File Name AC c Version 0 1 Author Sandeep Sirpatil License GNU General Public License gt Purpose This file implements the device specific functionality of IEEE 802 15 4 d I X A A Ox AS include include include SLIP h include MAC h define SLIP TX BUF SIZ define SLIP RX BUF SIZ Structure for local This RX Struct will radio This copy of the received pac processing volati UINT8 r volatil UINT8 s UINT8 s I 140 140 Ej pH le BASIC RF RX INFO rf rcv f rx buffer BASIC RF MAX e UINT8 received newFrame copy of t get written into when a packet is received from he received packet info PAYLOAD SIZE lip TxBuff Sl lip RxBuff Sl BASIC RF TX INFO r UINT8 rf Tx Buffer BASIC RF MAX PAYLOAD SIZ E Tx Info LIP TX BUF SIZE LIP RX BUF SIZE E li extern volatile BASIC RF TX INFO rf Tx Info Initialize function int MAC Init rf rcv info pPayload rf Tx Info pPayload receiv d newFram return Primarily radio and handl 0 handles packets to be received by SLIP packets received via radio to be sent FALSI rf_rx_buffer rf Tx Buff
23. to include IEEE 802 15 4 wireless functionality in the near future There are many commercial implementations of IEEE 802 15 4 and ZigBee stack There are also a few community projects working on implementing an open source version of the IEEE 802 15 4 stack The current statuses of these projects indicate that development has almost come to a stop 25 26 27 The lack of a working open source implementation of the standard was a big motivation factor to develop one and also develop the setup as an embedded Linux wireless development platform 1 2 Current Work There are currently numerous research projects conducted in various aspects of IEEE 802 15 4 standard A paper titled On the use of IEEE 802 15 4 to enable wireless sensor networks in building automation 2 provides an insight into the application of the standard and its effects on building maintenance energy consumption safety and security An article Home networking with ZigBee 28 presents the comparison of Bluetooth ZigBee 802 11 and other proprietary solutions and shows that ZigBee will succeed where others failed in home networking The results of the work presented in a paper titled Coexistence of IEEE 802 15 4 with other Systems in the 2 4 GHz ISM Band 3 show that IEEE 802 15 4 can co exist with other networks is robust and reliable even in the presence of some interference Another paper titled An Experiment on Performance Study of IEEE 802 15 4 Wireless
24. wait the device waits for another random number of backoff slots before trying to access the channel again If the channel is found idle the device can begin transmitting on the next available slot Acknowledgement and beacon frames are sent without using a CSMA CA mechanism 1 2 4 5 Security The MAC sublayer provides a baseline security measures such as maintaining an access control list ACL and symmetric cryptography to protect transmitted frames The higher layers determine when security is to be used at the MAC sublayer and provide all the necessary keying material to provide the security services This chapter provided a brief introduction to the IEEE 802 15 4 standard For a complete specification readers are advised to refer to the reference 1 CHAPTER3 HARDWARE DESCRIPTION 3 System Architecture The aim was to use the existing hardware in the lab keeping the cost down yet maintaining modularity and expandability in the system The CC2420 DBK is a demonstration kit from Chipcon consisting of a pair of CC2420DB boards each containing a CC2420 IEEE 802 15 4 compliant RF transceiver and an Atmel ATmegal28L microcontroller This kit was considered for our familiarity with AVR microcontrollers and easy availability of JTAGICE mkII debugger for microcontroller There are dozens of small single board computers available which are capable of executing Linux on them varying is physical size CPU speed and features Our requ
25. 5 4 Protocol Implementation and Measurement of Current Consumption M S Thesis University of North Carolina Charlotte Dec 2005 M Marchesotti M Migliardi R Podesta A Measurement Based Analysis of the Responsiveness of the Linux Kernel Proc of International Symposium and Workshop on Engineering of Computer Based Systems 21 30 March 2006 APPENDIX ATmegal28L code E kk k kok k RARA RR KARA RAR RA HK kk File Name MAC h Version Ost Author Sandeep Sirpatil E License GNU General Public License Purpose This file contains constansta for MAC and function prototypes CkCKkCk kk ck kk ck k ck ck k ck ck k ck ck ck ck ck k ck ck k ck ck k ck A kk A k ck A k ck A k ck k k ck k k k AKA AKA HX Te x AAA X X X ifndef MAC H define MAC H Define Frame IDs define MAC SET PAN ID 1 define MAC GET PAN ID 2 define MAC SET ADDR 3 define MAC GET ADDR 4 define MAC SET CHANNEL 5 define MAC GET CHANNEL 6 define MAC SET RECEIVER 7 define MAC GET RECEIVER 8 define MAC XMIT PACKET 9 define MAC RECV PACKE 10 define MAC SET ACK 11 define MAC GET ACK 12 FrameID length segNum SrcAdd srcPanID AckReg Rssi length Li 2 1 1 2 2 dod 1 1 11 define MAC RECV PKT OVERHEAD 11 int MAC Init int MAC Process fendif MAC H JRKKKE Kk kk END KOKCKCkCk ck ck k kckck
26. C2420DB nodes for communication using the 802 15 4 MAC frames The program uses 0x2420 as the PAN ID of the nodes and uses channel 26 The short address of the node is selected based on the joystick position if it was pressed down a short address of 0x1234 is selected else if moved in any direction an address of 0x5678 is selected for the node at startup If the potentiometer is turned or the joystick centre button is held down a data packet containing the potentiometer value is sent to the other node which is used to control the Pulse Width Modulation PWM duty cycle thus effectively controlling the brightness of the Orange LED The standalone Node 2 was programmed with the sample demo program For the Node 1 a test program was written which would execute on the Linux SBC and use the stack to communicate with the Node2 The test program would perform the same 39 functionality as the demo program but uses user inputs for the PWM duty cycle and displays the contents on the received packets Figure 4 7 Test program menu Figure 4 7 shows the menu system of the test program Menu option 1 sends a packet to Node 2 with a user input value for the PWM duty cycle and the node address Upon receiving the packet Node 2 would update the PWM duty cycle value and can be noticed on the brightness of the LED Other functions of the test program were tested similarly by making appropriate changes on the demo program of
27. CC2420DB Acknowledgement Acknowledgement Optional Optional Figure 4 4 Packet Transmission Mechanism Figure 4 4 illustrates the mechanism to send data from Node 1 to Node 2 The data packed into a MAC frame and wrapped with SLIP is sent from the TS7200 to the CC2420DB The microcontroller receives the frame and identifying as data to transmit sends it to CC2420 for transmission over radio If the acknowledgement option was set the microcontroller waits for an acknowledgement from the other node before it times out If it receives an valid acknowledgement it forwards it to the Linux MAC else it sends an transmission error 37 NODE 1 NODE 2 CC2420DB Acknowledgement Optional Figure 4 5 Packet receiving mechanism Figure 4 5 illustrates the packet reception The Node 2 sends a data packet addressed to Node 1 Upon receiving it the CC2420 interrupts the microcontroller The microcontroller gets the data from CC2420 buffer if the packet requested acknowledgement it sends an acknowledgement to CC2420 for transmission The microcontroller then encapsulates the data with a MAC frame and sends it to the Linux SBC 38 Figure 4 6 The test setup 4 6 Setup for testing The system was setup as described in the section 4 1 and illustrated in Figure 4 1 The sample demo program provided by Chipcon for CC2420DB was used in testing The program establishes a point to point RF link between two C
28. D RISC RSSI RTC RXFIFO SAP SBC SDRAM SFD SLIP SPI SRAM SSH TXFIFO UART USART USB WPAN xi Pulse Width Modulation Random Access Memory Radio Frequency Reduced Function Device Reduced Instruction Set Computer Received Signal Strength Indication Real Time Counter Receive First In First Out Service Access Points Single Board Computer Synchronous Dynamic RAM Start of Frame Delimiter Serial Line IP Serial Peripheral Interface Static Random Access Memory Secure Shell Transmit First In First Out Universal Asynchronous Receiver Transmitter Universal Synchronous Receiver Transmitter Universal Serial Bus Wireless Personal Area Network CHAPTERI INTRODUCTION There has been tremendous growth in the field of wireless communication during the last decade The wide acceptance of 802 11 standards for wireless local area network WLAN and cellular phone networks have proved that low cost wireless solutions are feasible and acceptable There are many applications that require low cost low data rate low power and inexpensive solution to network within a small area thus requiring a low rate wireless personal area network LR WPAN There are many proprietary solutions that address these needs but they are expensive and incompatible between manufacturers The IEEE 802 15 4 is a new standard for LR WPAN providing a low cost and less complicated solution The expected applications are hom
29. DR break case MAC GET ADDR break case MAC SET CHANNE break case MAC GET CHANNEL break case MAC SET RECEIVER break case MAC GET RECEIVER break case MAC XMIT PACKET break 70 04XNn frameId 04X n GET_INT bu 04XNXn GET INT bu 71 fprintf stderr An Packet Received Nn case MAC RECV PACKET E fprintf stderr Frame Id MAC RECV PACKET fprintf stderr Frame Length u n buf 2 fprintf stderr Frame Seq num u n buf 3 fprintf stderr Frame SrcAddr 5 buf 4 stderr Frame SrcPANId 7 buf 61 fprint f Fh QC Fh Fh Fh Fh Fh bh bh br Hh fprintf stderr Frame ACK Request 02X n buf 8 fprintf stderr Frame RSSI d n buf 9 fprintf stderr Frame Pkt Length u n buf 10 printB sbuf 11 buf 10 fprintf stderr End of Frame n break case MAC SET ACK break case MAC GET ACK break default fprintf stderr Case fail in func printPacket In f KA k KKK KKK A x END A ck kk k kc k X kk X kk kok ck KAR OK RARAS KKK K kk kk kk k kk kk kk kk k CK Ck kA K k kk I AK K AK k ck ck ck ck kckckck ck ck kk File Name include h T Version 0 1 Author Sandeep Sirpatil License GNU General Public License F Purpose A general include file for the whole ACKCkCk ck Ckck ck ck ck k ck ck c
30. ET RECEIVER if slip_RxBuff 3 0 rx off basicRfReceiveOff DISABLE GLOBAL INT FASTSPI STROBE CC2420 SRFOFF ENABLE GLOBAL INT Jelse if slip RxBuff 3 1 rx on basicRfReceiveOn DISABLE GLOBAL INT FASTSPI_STROBE CC2420_SRXON ENABLE GLOBAL INT break case MAC GET RECEIVER break case MAC X H H FU D Q N ET receive from slip and send it via radio rf Tx Info destAddr GET INT slip RxBuff 4 slip RxBuff 3 rf Tx Info ackRequest slip RxBuff 5 rf Tx Info length slip RxBuff 60 memcpy rf Tx Info pPayload amp slip_RxBuff 7 slip_RxBuf f 6 basicRfSendPacket rf Tx Info if basicRfSendPacket amp rf Tx Info TODO return status via SLIP xl TOGGLE YLED 50 jelse TOGGLE RLED break case MAC_RECV_PACK break E H return 0 UINT16 rx cntr 0 BASIC RF RX INFO basicRfReceivePacket BASIC RF RX INFO pRRI int i20 Adjust the led brightness PWMO_SET_DUTY_CYCLE pRRI gt pPayload 0 Blink the green LED SET GLED halWait 10000 CLR GLED rf rcv info seqNumber pRRI gt seqNumber rf_rcv_info srcAddr pRRI gt srcAddr rf_rcv_info srcPanld pRRI gt srcPanld rf rcv info length pR
31. GET INT h frameld PAN ID UINT8 n UINT16 panid lip RxBuff 3 rfSettings p switc MAC SI case E ET INT slip RxBuff 4 s ngth af r E clear flag ceived on SLIP and process them f amp slipRxLength ess it 0 x slip RxBuff 1 slip RxBuff 0 a nId panid halRfWaitForCrystalOscillator DISABLE GLOBAL INT FASTSPI WRITE RAM LE amp myAddr CC2420RAM SHORTADDR 2 n FASTSPI WRITE RAM LE amp panid CC2420RAM PANID 2 n ENABLE GLOBAL INT break case MAC_GET_PAN_ID break case MAC_SET_ADDR UINT8 n UINT16 addr GET INT slip RxBuff 4 slip RxBuff 3 rfSettings myAddr addr halRfWaitForCr DISABLI af ystalOscillator _GLOBAL_INT 49 FASTSPI WRITE RAM LE amp addr CC2420RAM SHORTADDR 2 ENABLE GLOBAL INT break case MAC_GET_ADDR break case MAC_SET_CHANNEL check channel range 11 26 valid if 10 lt slip RxBuff 3 amp amp slip_RxBuff 3 lt 27 DISABLE GLOBAL INT if if on turn it off rfSettings receiveOn FASTSPI STROBE CC2420 SRFOFF halRfSetChannel slip RxBuff 3 if rfSettings receiveOn FASTSPI STROBE CC2420_SRXON ENABLE GLOBAL INT break case MAC_GET_CHANN E p break case MAC S
32. IMPLEMENTATION OF IEEE 802 15 4 PROTOCOL STACK FOR LINUX by Sandeep Sirpatil A thesis submitted to the faculty of The University of North Carolina at Charlotte in partial fulfillment of the requirements for the degree of Master of Science in the Department of Electrical and Computer Engineering Charlotte 2006 Approved by Dr James M Conrad Dr Ivan L Howitt Dr Bharat S Joshi 2006 Sandeep Sirpatil ALL RIGHTS RESERVED 11 111 ABSTRACT SANDEEP SIRPATIL Implementation of IEEE 802 15 4 Protocol Stack for Linux Under the direction of DR JAMES M CONRAD The IEEE 802 15 4 is a new wireless standard introduced for low power low cost wireless communication with moderate data rates It is intended to be used in embedded applications for home office automation industrial control and sensor networks In such applications there is generally a need for a master controller which will be responsible for data acquisition and communicate with other systems Linux is gaining popularity as an embedded operating system There are many industrial controllers data acquisition systems that use Linux as the operating system These controllers could potentially be used as the master controller for the wireless network This thesis work implements a subset features of IEEE 802 15 4 for Linux operating system and develop a modular expandable Linux platform for IEEE 802 15 4 wireless systems The developed software sta
33. KkCk kCkCck kCkCck A KA kk ck k ck ck k ck ck X ck ck X X A X X A kk A kk A k ck k ck ck k k ck k k k k KA AKA HX Te X AAA X X X include lt include h gt include USART h define UART1 TX INT ENABLE do UCSRIB BM UDRIE1 while 0 define UART1 TX INT DISABLE do UCSRIB BM UDRIE1 while 0 volatile UINT8 uart xmit buf XMIT BUF SIZE volatile UINT8 uart recv buf RECV BUF SIZE volatile UINT16 uart Recv Ridx 0 volatile UINT16 uart Recv Widx 0 volatile UINT16 uart Xmit Ridx 0 volatile UINT16 uart Xmit Widx 0 volatile UINT16 txISRCntr 0 volatile UINT16 rxISRCntr 0 volatile UINT8 rxChar 0 Initialize UINT8 baud UINT8 databits Num of databits generally 8 UINT8 stopbits Num of stop bits generally 1 UINT8 parity O no parity l even 2 odd UINT8 USART1 Init UINT8 baud UINT8 databits UINT8 stopbits UINT8 parity INIT UART1 UART BAUDRATE 9K6 UART OPT 8 BITS PER CHAR UART OPT ONE STOP BIT UA disa ble global RT OPT NO PARITY int DISABLE UBRRIL UCSRIA UCSRIB UCSRIC ifdef U UBRRIH GLOBAL INT unsigned baud 0 char baud 58 amp 0x01 Multi procesor disable 0 default state 0x06 default USART 2XMODI CSRIA BM U2X1 else UCSRIA a
34. Networks 11 presents the results of an experiment conducted to evaluate the performance of various features such as direct and indirect transmissions CSMA CA mechanism data payload size and beacon enabled mode The data throughput delivery ratio and received signal strength were investigated as performance metrics The results show that non beacon network has better raw data rates and utilization ratio as compared to beacon enabled networks The hardware board developed by Mr Assad 29 is an inexpensive IEEE 802 15 4 evaluation board Mr Rai 30 used this setup in evaluating energy consumption in IEEE 802 15 4 communication Their work very helpful as it is very important to determine energy consumption of wireless nodes as they are expected to operate for long time on small batteries A paper titled Embedded Linux Outlook in PostPC Industry 14 presents an analysis of embedded Linux in the industry how it compares to other commercial embedded OS The paper concludes with a forecast in growth of industry adoption of Linux and proposes standardization measures to sustain the growth Linux is inherently a non real time OS there have been many efforts to add real time functionality to Linux kernel A paper titled A Measurement Based Analysis of the Responsiveness of the Linux Kernel 31 presents experiments conducted on various non preemptible sections of the kernel code and quantified its effects on interrupt latency The results sho
35. Node 2 e 192 168 0 102 PutTY 2 03 04 05 06 07 05 09 End of Frame Figure 4 8 A received frame by test program 40 Figure 4 8 shows the contents of a received packet on Nodel from Node 2 The test program displays the various fields associated with the packet received it also displays the raw bytes of the packet CHAPTER5 CONCLUSION The objectives of the thesis work has been achieved with the implementation of subset features of IEEE 802 15 4 features on a Linux SBC and demonstrate the use of such a controller in LR PAN The SBC with Linux setup and the development tools form the embedded Linux development system The complete system with the hardware setup and the software stack can be used in the following ways e Serves as an embedded Linux development system with the development tools other interfaces such as Ethernet and USB and many applications e Can be used in investigating and developing upper layer protocols such as ZigBee e Evaluating various aspects of IEEE 802 15 4 protocol e As a tool in the study of co existence of IEEE 802 15 4 with other wireless standards e Asa packet logger analyzer in IEEE 802 15 4 networks e As an educational tool in teaching LR PAN and embedded Linux e As a valuable resource in the ongoing research of IEEE 802 15 4 at UNC Charlotte 42 5 1 Future work This thesis work can be extended in many ways The stack can be enhanced with the support for beacon
36. RI gt length rf rcv info ackRequest pRRI gt ackRequest rf rcv info rssi pRRI gt rssi memcpy rf rcv info pPayload pRRI gt pPayload pRRI gt length received newFrame TRUE TOGGLE GLED rx CIENCIA for i 0 i lt pRRI gt length i rf rcv info pPayload i pRRI pPayload i Continue using the one and only reception structure return pRRI basicRfReceivePacket f KA k k k k ke e e x A x END XKOKCKCKCKCkCkCk ck kk kk kck ck kokck RARA I OK ke ke xe kx KKK K kk kk Ck Ck Ck k kk kk kk Ck Ck Ck CK CK kk X k k kk k CK Ck kk AX K kCk kc kc kck ck kckckck ck ck KK File Name Version Author License Purpose ifndef SLIP H define SLIP H define END define ESC define ESC END define ESC ESC 0 1 Sandeep Sirpatil GNU General Public License This file contains SLIP configuration and function prototypes int SLIP Init SLIP h 0300 0333 0334 0335 int SLIP Send unsigned char buf void SLIP process int SLIP getFrame UINT8 buf endif SLIP H BRK KK Kk kk KCKCKkCk kCkCck kk ck ck KA A KA X K A k ck A X ck ck X X ck AS Te A xo x XE X X X indicates end of packet indicates byte stuffing ESC ESC ESC END means END data byte ESC ESC means ESC data byte int length UINT16 size END Fe ck k ck kckck Ck Ck Ck ck ck kckc
37. TS HAL IDE IDE IEEE IF 1x LIST OF ABBREVIATIONS Analog to Digital Converter Advanced Encryption Standard Arithmetic and Logic Unit Application Program Interface Advanced RISC Machine CC2420 Development Board Central Processing Unit Cyclic Redundancy Check Carrier Sense Multiple Access with Collision Avoidance Dynamic Host Configuration Protocol Dynamic Link Library Direct Seguence Spread Spectrum Extended File System Frame Check Seguence Full Function device First In First Out Guaranteed Time Slots Hardware Abstraction Layer Integrated Drive Electronics Integrated Development Environment Institute of Electrical and Electronics Engineers Intermediate Freguency IP ISM ITU T JTAG LAN LR WPAN MAC MFR MHR MIPS MMU MPDU NFS OHCI O QPSK PA PAN PC PDA PHY POSIX PPDU PSDU Internet Protocol Industrial Scientific and Medical Telecommunication Standardization Sector Joint Test Action Group Local Area Network Low Rate Wireless Personal Area Networks Medium Access Control Layer MAC Footer MAC Header Million Instructions Per Second Memory Management Unit MAC Protocol Data Unit Network File System Open Host Controller Interface Offset Quadrature Phase Shift Keying Power Amplifier Personal Area Network Personal Computer Personal Digital Assistant Physical Layer Portable Operating System Interface PHY Protocol Data Unit PHY Service Data Unit PWM RAM RF RF
38. VER txBuf 2 4 fprintf stderr nReceiver control 1 0n 0 Off scanf d amp rxCntrl while rxCntrl 0 amp amp rxCntrl 1 f fprintf stderr NnIncorrect scanf d amp rxCntrl txBuf 3 LOWER_BYTE rxCntrl SLIP_Send txBuf 4 break case 5 int panIg txBuf 0 LOWER BYTE MAC SET PAN ID I txBu 1 UPPER BYTE MAC SET PAN ID txBuf 2 5 fprintf stderr nSet PanID in HEx scanf X amp panld Fh FFD bh hh et txBuf 3 LOWER BYTE panld txBu 4 UPPER BYTE panld SLIP Send txBuf 5 Jbreak default fprintf stderr Incorrect choice PARAR ke ke e e x x END XKOKCKCKCKCkCkCk ck kk k kc KK ke ke xe kx BOK KKK k oko k RAR RARA RARA HK kk File Name MAC h Version 0 1 Author Sandeep Sirpatil License GNU General Public License Purpose This file contains constants for MAC CkCKkCk AKA kk ck kk ck k ck ck k ck ck ck ck ck X ck ck X X ck kk A kk A k ck A k ck A k ck kk ck k kk AKA AKA HX ifndef de dde def de de de def de de de de de def fi ne Fram 2 11 define fendif MAC H and function prototypes N AAA X X HF F AC H AC H AC SET PAN ID 1 AC GET PAN ID 2 AC SET ADDR 3 AC GET ADDR 4
39. XVI O PAN coordinator Device Communication flow Figure 2 1 Star and peer to peer networks 4 2 1 Network Topologies A LR PAN can be setup to operate in either of the two topologies the star topology or the peer to peer topology As shown in the Figure 2 1 the PAN coordinator forms the central node in the star topology Every device in the network communicates with the central node The PAN coordinator is used to initiate terminate or route communication around the network The PAN coordinator is the primary controller of the network AI devices generally have a 64 bit extended address This address can be used or exchanged for a shorter address allocated by the PAN coordinator when the device associates with the PAN coordinator The PAN coordinator may be powered by mains outlet while the devices generally are battery powered The applications of star topology are home automation personal computer PC peripherals toys and games The peer to peer topology allows any device to communicate with any other device within the radio reach but requires a PAN coordinator to form the network This topology allows formation of complex network configurations such as mesh networking topology This type of topology is useful in applications such as industrial control and monitoring wireless sensor networks monitoring environment inventory and tracking This topology allows the network to be ad hoc self organizing and self healing A
40. acket rxBuf rxLen clearBuf rxBuf rxLen if rxBuf 0 X break ch getchar if ch z SLIP Send txBuf 6 jelse if ch m 3 S jelse if 60 61 E MAC XMIT PACK EE E MAC XMIT PACK TRUE ack request int duty fprintf stderr inside txBuf 0 LOWER_BY txBuf 1 UPPER BY txBuf 2 17 length txBuf 3 0x34 txBuf 4 0x12 txBuf 5 txBuf 6 10 duty getchar duty getchar fprintf stderr scanf d amp duty before Errno d d errno rtn rtn fscanf stdin Duty cycle d duty fprintf stderr Errno Sd d errno rtn txBuf 7 LOWER_BYT E duty txBuf 7 0xDE SLIP Send txBuf 17 fprintf stderr sleep 1 SLIP Term return 0 void sig_catcher int sig fprintf stderr SIG caught SLIP Term exit EXIT FAILURE perror SIGINT port closed and exit void menu unsigned char txBuf 50 int menu fprintf stderr n Menu System n stderr 1 Send Packet An set Short Address Nn fprintf fprintf stderr 2 Set Channel n fprintf stderr 3 fprintf fprintf stderr 5 set PAN scanf Sd amp menu switch menu case 1 int add 0 duty stderr 4 set Receiver control n ID n txBuf 0 LOWER BY E MAC XMIT PACK
41. ck is easily portable to other hardware platforms and operating systems The system is intended to be useful on research of various aspects of IEEE 802 15 4 standard iv ACKNOWLEDGEMENTS I would like to express my sincere gratitude and thank my advisor Dr James M Conrad for his constant encouragement support and his belief in me for successful completion of this thesis work His approach and guidance to solve the problems I encountered were of significant help I would also Thankful to Dr Ivan L Howitt and Dr Bharat Joshi for accepting to be committee members and for their advice and support I would like to express my sincere appreciation and thank my friends Gajendra Singh Gurudatt Mysore Michael Thomas and many others for their support throughout I also want to thank the open source developer community for their efforts and dedication without which this work would not have been possible TABLE OF CONTENTS LIST OF FIGURES en t wate i Rate t dict een Ca m ES padu neda vii ESTOPTABLE Un sei viii LIST OFABBREVIATIONS tiii Een IX CHAPTERES INTRODUCTION e eese deae o pe TRIS 1 1 1 Motivacion 2 127 Current W OTK s a eed A A te o re 3 1 3 Completed Thesis Work ui oi 5 E Organization OF THESIS cessante acne de 6 CHAPTER2 INTRODUCTION TO IEEE 802 15 4 eee 7 2 T Network T Opologles 2 uie uto ec e ae en 8 3 3 ONECIBIGGEUEO S ioco ob idos savan A iced Max anc e OIL une 9 2 3 PED SDESI CHO adeo edu tiet etae td ERR Sox ae bee tu
42. dgment Figure 2 10 Communication from a coordinator in a non beacon enabled network 1 2 4 3 3 Peer to peer data transfers In a peer to peer network every device may communicate with every other device within its radio reach In order to achieve this effectively the devices will need to either turn their receiver on continuously or synchronize with each other In the former case the devices can communicate using unslotted CSMA CA In the latter case other synchronization measures have to be used Description of such measures is left to the upper layers to decide and is beyond the scope of this standard 2 4 8 CSMA CA mechanism The standard defines two types of channel access methods depending on the network configuration Non beacon enabled networks use unslotted CSMA CA method The device wishing to transmit data will wait for a random period of time If the channel is found idle it shall transmit the data else if the channel was found to be busy the 19 device waits for another random period of time before trying to access the channel again Acknowledgment frames are sent without using CSMA CA mechanism The beacon enabled networks use slotted CSMA CA mechanism where the backoff slots are aligned with the start of the beacon transmission A device wishing to transmit data during CAP will locate the boundary of the next backoff slot and then wait for a random number of backoff slots If the channel is busy following this
43. e LITE AN c XILINX CPLD MAX197 A D 10 100 LM diede i fa E ETHERNET JUMPERS COM2 8A D LCD STRATA DIO EP9302 ARMS JTAG MAX197 FLASH SPI PROCESSOR Figure 3 3 TS 7200 Hardware Components 8 The TS 7200 features a true IDE compact Flash socket A compact Flash card in the socket appears as a hard drive to the operating system Compact Flash cards are available in a wide range of capacities A 512 MB card is sufficient to install a customized version of Debian Linux distribution The board also features USB and Ethernet ports which can be used to connect to other devices This board serves right for a PAN coordinator as it is expected to be the master controller CHAPTER4 SOFTWARE DESCRIPTION 4 1 System Setup The setup consists of the CC2420DBK TS 7200 Desktop Laptop Router and two JTAGICE mkII debuggers Figure 4 1 illustrates the setup The laptop desktop and TS 7200 were connected to the router to form a local area network LAN The desktop computer is connected to one of the CC2420DB via JTAGICE mkII debugger This setup forms one node of the wireless network The other CC2420DB and TS 7200 connected via RS 232 form another node and this CC2420DB is connected to the Laptop via another JTAGICE mkII The router is the dynamic host configuration protocol DHCP server of the network The DHCP server was configured to assign specific Internet Protocol IP addresses to the desktop laptop and TS 7200 which were
44. e beacon management channel access guaranteed time slot GTS management frame validation association and disassociation 2 4 1 MAC frame format The MAC frame structure is designed to keep the complexity at a minimum while ensuring they are sufficiently robust to be transmitted on a noisy channel The general format of a MAC frame is shown in the Figure 2 5 Variable Frame Sequence Address Frame check control number Payload sequence MAC MAC header MHR MAC service data MAC footer sublayer unit MSDU MFR MAC protocol data unit MPDU s n vena PHY service data unit PSDU PHY protocol data unit PPDU Figure 2 5 The format of a general MAC frame 4 A MAC frame is composed of the MAC header MHR MAC service data unit MSDU and MAC footer MFR The first field of the header is the frame control field It indicates the type of the MAC frame specifies format of the address field and controls 14 acknowledgement The address field is variable of length 0 to 20 bytes Based on the frame type the address field may contain source and destination addresses no address or destination address A short 8 bit device address or 64 bit IEEE device address may be used 4 The payload is of variable length with a restriction of 127 bytes for the complete MAC frame The data contained in payload is dependent on the frame type The 802 15 4 MAC has four different frame types These are the beaco
45. e clock cycle 7 The ATmegal28L provides the following features e 128K bytes of in system programmable Flash e 4K bytes EEPROM e 4K bytes SRAM e Real Time Counter RTC e 2USART 25 e SPIport e 8 channel 10 bit ADC Two 8 bit Timer Counters and two 16 bit Timer Counters e JTAG test interface 3 4 TS 7200 overview The TS 7200 is a compact full featured single board computer SBC This board was selected based on its features and the manufacturer provided good support for Linux by providing precompiled Linux Kernel Debian distribution and tool chain This board is small in size and priced economically TS 7200 is based on the Cirrus EP9302 ARM9 CPU The EP9302 features an advanced 200 MHz processor design with a memory management unit MMU that allows support for high level operating systems such as Linux Windows CE and others 8 As a general purpose controller it provides a standard set of peripherals on board Figure 3 3 illustrates the hardware components on TS 7200 8 The features of TS 7200 are e 200 MHz ARM9 CPU with MMU e 8 MB Strata Flash drive 16 MB Optional e 32 MB SDRAM 64 MB Optional e True Integrated Drive Electronics IDE Compact Flash socket e 2USB 2 0 OHCI ports 12 Mbit s max e 2 serial ports up to 230 Kbaud e 10 100 Ethernet port e Watchdog Timer 26 e SPI bus interface e PC 104 expansion bus COMPACT FLASH INTERFACE PC 104 INTERFACE 5V POWER COM1DB9 ARIA com m ana ag
46. e office automation industrial sensors and control distributed sensor networks and environment monitoring 2 The silicon implementation of the standard is inexpensive when compared to other proprietary solutions as the standard is open and available to everyone As a result the chip making companies compete to develop a better product at a lower cost The cost of a wireless node is an important factor as some applications require large number of nodes The ZigBee alliance an association of companies working together to develop ZigBee standard based products for monitoring and control has led to the increased adoption of the IEEE 802 15 4 standard The ZigBee standard defines upper layer that are built on the IEEE 802 15 4 standard The aim of the ZigBee alliance is to replace every switchbox electrical outlet and various sensors in a building by wireless nodes that communicate with each other even though manufactured by different manufacturers This standard is being widely adopted by the industry and the numbers of products based on the standard are increasing exponentially The ZigBee alliance is forecasting that in the next four to five years time there could be 50 ZigBee devices per home and eventually as many as 150 15 1 1 Motivation The IEEE 802 15 4 is a relatively new standard and thus attracts new research on its various aspects Many universities are conducting research on the use of different routing protocols efficient
47. er LE int mac pr ctr 0 int MAC_Process UINT16 slipRxLength int i 0 TR rf rcv info if received newFram Make a new SLI slip TxBuff 0 slip TxBuff 1 slip TxBuff 2 length slip TxBuff 3 LOWE MAC U P frame and send it R BYTE MAC RECV PACK E LE UPPER BY RECV_ E MAC RECV PACK PKT OVERHEAD rf rcv info seqNumber 47 ket should be used for further and transmitted via over SLIP E got a new frame from radio Jy 48 slip TxBuff 4 LOWER BYTE rf rcv info srcAddr slip TxBuff 5 UPPER BYTE rf rcv info srcAddr slip TxBuff 6 LOWER BYTE rf rcv info srcPanId slip TxBuff 7 UPPER BYTE rf rcv info srcPanId slip TxBuff 8 rf rcv info ackRequest slip TxBuff 9 rf rcv info rssi slip TxBuff 10 rf rcv info length memcpy amp slip TxBuff MAC RECV PKT OVERHEAD rf rcv info pPayload rf rcv info le ngth for i 0 i lt rf rcv info length i IR slip_TxBuff MAC_RECV_PKT_OVERHEAD i rf rcv info pPayload i SLIP_Send slip_TxBuff ECV_PKT_OVERHEAD rf_rcv_info le mac_pr_ctr received_newFram MAC RI FALS check for new any frames re SLIP_process if SLIP getFrame slip RxBuf got a SLIP frame proc unsigned int frameId frameld
48. ew rx frame writeFlag TRUE indicate the else End of frame received rx frame isEmpty FALSE indicate a new rx frame writeFlag FALSE moredata FALSE end the while loop fprintf stderr slip got a frame n break case ESC rx lastByte ESC keep a record of it break case ESC END if rx lastByte ESC rx_frame buffer rx_frame length END rx frame length rx lastByte 0 else TODO handle error break case ESC ESC if rx lastByte ESC rx_frame buffer rx_frame length rx frame length rx lastByte 0 else TODO handle error break default rx_frame buffer rx_frame length ch rx frame length ti un a else no more data in Queue moredata FALSE while return 0 f KA k k k k KK KK A x END KOKCKCKCKCkCkCk Ck kk k kc k kck ck kokck ck kk ck ok ck kk ke e kx x OK K K kk kk Ck k kk kk kk kk k CK Kk kA K k kk k AAA AX K Kk ck ck ck ck ck kk kk ck k ck kk File Name util h Version 0 1 Author Sandeep Sirpatil A License GNU General Public License gt Purpose This file contains utility macros ES and function prototypes A KOKCKCKCKCKCKCkCk kok k kCk k Ck kk Ck kCk k kok k Ck kc k Ck kk k kk k kok k k kk kk kok kok kk x ke ifndef UTIL H define UTIL H define LOWER_BYTE x unsigned cha
49. f int SLIP Recv unsigned char buf int fendif SLIP H f REC Kk kk END Te A xo x XE X X X indicates end of packet indicates byte stuffing ESC ESC END means ESC ESC_ ESC means int len length XKCKCKCkCKCKCkCk ck kk k kc RRA RRA RARA kc kok sk ke ke xe kx BORK KKK k oko k oko k RAR KAR KARA HK kk File Name Version Author License Purpose X AA O F SLIP c 0 1 Sandeep Sirpatil GNU General Public License This file implements SLIP Layer X X x F F KOKCKCKCKCkCKCk Ck A Ck kCk k kCkCk kCk k Ck kCk Ck kk k k kc k kck ck K kok kok I ck kk kk OxCO OxDB The file contains the code to interface to the serial port 64 END data byte OxDC ESC data byte OxDD and send and receive SLIP frames include include h Receive Circular buffer static int rx rdIdx 0 static int rx wrIdx 0 static unsigned char rx buffer SLIP RX BUFF SIZI static unsigned char rx lastByte struct rxFrame unsigned char buffer FRAME SIZE int length int isEmpty int writeFlag y struct rxFrame rx_frame struct termios oldconfig newconfig int fd int port Open int port Close int rx putByte char c int rx getByte unsigned char c int SLIP Init rx frame isEmpty TRUE rx frame writeFlag FALS rx frame length 0 fd 0 return port Open E
50. f the stack is implemented on the Linux side and the other part resides on the ATmegal28L microcontroller The Linux section implements the device independent higher level functionality of the stack The device specific part is implemented on the ATmegal28L This allows for easy porting to new 802 15 4 RF transceivers 32 TS 7200 CC2420DB Serial UART CC2420 Driver Driver RS 232 Figure 4 2 Software structure and data flow 4 4 1 Linux Media Access control MAC As illustrated in the Figure 4 2 the software is implemented in layers The Media Access Control MAC layer is the top layer and it provides a set of functions to initialize configure control send and receive packets of data over the radio The MAC layer on the Linux side maintains the state and configuration of the node It communicates with its counterpart on the microcontroller in the form of data packets FrameID FrameID Length LSB MSE FrameID 2 bytes Length 1 byte Data 0 252 bytes Figure 4 3 The structure of MAC packet 33 Figure 4 3 shows the structure of aMAC packet as composed of 3 fields The first field FrameID identifies the type of packet and is of 2 bytes in length The next field is Length a 1 byte field specifying the total length of the packet in bytes The third field Data is the actual data its length varies based on the type of packet The largest number for the Length field can be 255 and the header i e
51. first one is the data transfer to a coordinator in which a device transmits the data The second transaction is the data transfer from a coordinator to the device The third transaction is the data transfer between the peer devices 2 4 3 1 Data transfer to a coordinator When a device needs to transfer data to a coordinator in a beacon enabled network it listens for the beacon when the device finds a beacon it synchronizes to the superframe structure At an appropriate time it transmits data using slotted CSMA CA to the coordinator The coordinator may send an optional acknowledgement frame to complete the transaction This sequence is summarized in Figure 2 7 16 Coordinator Beacon Data Acknowledgment optional Figure 2 7 Communication to a coordinator in a beacon enabled network 1 If the device is in a non beacon enabled network it transmits the data frame using an unslotted CSMA CA to the coordinator The coordinator may acknowledge successful reception with an optional acknowledgment frame The sequence is summarized in Figure 2 8 Coordinator Acknowledgment optional Figure 2 8 Communication to a coordinator in a non beacon enabled network 1 2 4 3 2 Data transfer from coordinator When the coordinator needs to transfer data to a device in a beacon enabled network it indicates in the network beacon that data message is pending The device periodically listens to the network beaco
52. irements were low cost easily expandable good support from the manufacturer and community A number of SBC s were considered and TS 7200 from Technologic systems was selected 3 2 CC2420 RF Transceiver Chipcon was one of the first companies to develop a silicon implementation of the standard in the form of CC2420 IC The CC2420 is a true single chip 2 4GHz IEEE 802 15 4 complaint RF transceiver designed for low power and low voltage applications CC2420 includes a digital direct sequence spread spectrum base band modem providing a spreading gain of 9dB and an effective data rate of 250 kbps 21 The CC2420 provides extensive hardware support for packet handling data buffering burst transmissions data encryption data authentication clear channel assessment link guality indication and packet timing information These features reduce the load on the host controller and allow CC2420 to interface with low cost microcontrollers The CC2420 is designed as an SPI slave peripheral Figure 3 1 illustrates a simplified block diagram of CC2420 which features a low intermediate freguency IF receiver The received RF signal is amplified by the low noise amplifier LNA and down converted in guadrature I and O to the IF At IF 2 MHz the complex I Q signal is filtered and amplified and then digitized by the ADCSs Automatic gain control final channel filtering de spreading symbol correlation and byte synchronization are performed digital
53. ity PLME The PHY data service allows the transmission and reception of PHY protocol data units PPDU across the physical radio channel The features of PHY are activation and deactivation of the radio transceiver energy detection ED link quality indication channel selection clear channel assessment CCA transmission and reception of packets across the physical medium 11 Table 2 1 Frequency bands and data rates 1 band MHz Chip rate 2 Bit rate Symbol rate 1 kchip s Modulation kb s ksymbols Symbol sl 868 915 2 2 MHz MHzPHY Channel 0 Channels 1 10 p f MHz 868 0 868 6 928 0 2 4 GHz PHY Channels 11 26 gt 5 MHz 0000000000000008 2400 0 2483 5 Figure 2 3 The channel structure in IEEE 802 15 4 4 The standard offers two PHY options which differ in frequency bands and data rate The Error Reference source not found summarizes the frequency bands modulation and spreading technique The standard defines 27 channels numbered 0 to 26 across the three frequency bands as illustrated in Figure 2 3 Sixteen channels are available in the 2450 MHz band 10 in the 915 MHz band and 1 in 868 MHz band The relation between the channel number and centre frequency is defined as F 868 3 MHz fork 0 kis the channel number 12 F 906 2 k 1 MHz fork 2 1 2 10 F 2405 5 k 11 MHz fork 11 12 26 PHY protocol data unit PPDU Start of PHY PHY service
54. k K A k ck ck ck ck ck ck ck ck kk ck k ck ck kk A k ck A ck ck A ck ck k k ck k k ck k k kk A FH A AH KU application X ifndef INCLUDE H define INCLUDE H general definitions used in the stack fi fi fi fi fi fi fi fi fi fi fi fi nc nc nc nc nc nc nc nc nc nc nc nc lu lu lu lu lu lu lu lu lu lu lu lu de de de de de de de de de de de de sys types h lt sys stat h gt lt fentl h gt lt termios h gt lt stdio h gt lt signal h gt lt unistd h gt lt stdlib h gt lt errno h gt util h SLIP ah MAC h ifndef TRU LE TE define TRUE 1 endif ifndef FALSE define FALSE 0 endif endif INCLUDE H f KA k kok KKK KKK END KOKCKCKCKCkCkCk ck kk kk kck ck kokck ckokok ck kok ko ke ke ke ke x kx x 12
55. kck ck kc k Kk EEE kc k kc kk BORK KKK KK k kok RR KARA oko k RAR HK kk File Name SLIP c Version Author License Purpose include 0 1 Sandeep Sirpatil GNU General Public License This file implements SLIP layer and uses UART layer as serial driver lt include h gt include include de de UINT8 slip xmit buf SLIP TXBUF SIZ fine SI fine SI USART h SLIP h LIP TXBUF SIZI LIP RXBUF SIZI Gl u UINT8 rx lastByte 200 250 E AS Te AAA A X Xo F 51 struct Slip Rcv Frame UINT8 buffer SLIP RXBUF SIZI UINT16 length UINT8 isEmpty UINT8 writeFlag E ca struct Slip Rcv Frame slip rcv frame int SLIP Init return 0 int SLIP Send unsigned char buf int idx 0 int i 0 slip rcv frame isEmpty TRUE slip rcv frame length 0 slip rcv frame writeFlag FALSE slip xmit buf idx END idx for i 0 i lt length i if idx 2 gt SLIP TXBUF SIZE return 1 switch buf case case idx idx break ESC slip xmit buf idx idx idx break default slip xmit buf idx idx slip xmit buf idx END idx ND slip xmit buf idx B s lip xmit buf idx slip xmit buf idx int length Buffer overflow ESC_END
56. ly The SFD pin goes high when a start of frame delimiter has been detected CC2420 buffers the incoming data in a 128 byte receive FIFO buffer The user may read the FIFO through the SPI interface CRC is verified in hardware while the RSSI and correlation values are appended to the frame CCA is available on a pin in receive mode 6 22 Serial microcontroller interface Digital and Analog test interface Figure 3 1 CC2420 simplified block diagram 6 The CC2420 transmitter is based on direct up conversion The data is buffered in a 128 byte transmit FIFO separate from the receive FIFO The preamble and start of frame delimiter are generated by hardware Each symbol 4 bits is spread using the IEEE 802 15 4 spreading sequence to 32 chips and output to the digital to analog converters DACs An analog low pass filter passes the signal to the quadrature I and Q up conversion mixers The RF signal is amplified in the power amplifier PA and fed to the antenna 23 3 3 CC2420DBK Demonstration Board Kit The CC2420DBK Demonstration Board Kit includes two CC2420DB Demonstration Boards These boards contain a CC2420 with necessary support components an Atmel ATmegal28L AVR microcontroller 32 Kbytes external RAM a PCB antenna as well as a joystick buttons and LED s that can be used to implement a visual user application interface The demonstration board is also furnished with connectors for JTAG ISP and direct acce
57. minal was found to be more stable and the applications were found to interact well with it 4 3 1 Cygwin Cygwin is a Linux like environment for Windows It consists of a Dynamic Link Library DLL named cygwin1 dll which acts as an emulation layer providing substantial Portable Operating System Interface POSIX system call functionality and a collection 3l of tools which provide a Linux look and feel Many of the Linux applications are ported to execute in Cygwin environment 22 An NFS server was installed in the Cygwin the installation steps 17 by H Sparks were found helpful It was setup to run and export a local folder usr Sandy The TS 7200 was configured to mount this folder at location mnt laptop automatically on boot up by adding an entry in the etc fstab file This setup would make the folder visible to both the systems thus enabling file and application sharing Additional installation and configuration information can be found in the Linux NFS how to 16 Technologic Systems provides Linux programming tools toolchain for Cygwin environment The toochain was installed on Cygwin thus allowing Linux applications for TS 7200 to be built from the Cygwin environment The Cygwin environment was preferred over natively building applications on TS 7200 since the laptop computer offered more computational resources 44 Stack Overview The software stack implementation is split into two parts one part o
58. mp BM U2X1 endif switch databits Case 5 UCSRIC amp BM UCSZ1 UCSRIC amp BM UCSZ1 UCSRIB amp BM UCSZ1 break case 6 UCSRIC BM UCSZ1 UCSRIC amp BM UCSZ1 UCSRIB amp BM UCSZ1 break case 1 UCSRIC amp BM UCSZ1 UCSRIC BM UCSZ1 UCSRIB amp BM UCSZ1 break case 8 UCSRIC BM UCSZ1 UCSRIC BM UCSZ1 UCSRIB amp BM UCSZ1 break case 9 UCSRIC BM UCSZ1 UCSRIC BM UCSZ1 UCSRIB BM UCSZ1 break default return 1 if stopbits 1 UCSRIC BM USBS1 jelse if stopbits 2 UCSRIC BM USBS1 jelse return 1 if parity 0 UCSRIC amp BM UPM11 UCSRIC amp BM UPM10 else if parity 1 even UCSRIC BM UPM11 UCSRIC amp BM UPM10 else if parity 2 odd UCSRIC UCSRIC jelse return 1 58 UCSRIB BM RX EN1 BM RXCIE1 rx int enable UCSR1B BM TXEN1 tx enable Initialize ENABLE GLOBAL INT return 0 Starts the interrupts for transmission void USART1 startTx UINT8 ch send function UINT8 USART1 Send UINT8 numBytes UINT8 arry UINT16 i 0 UINT16 xmit Widx 0 xmit Widx uart Xmit Widx local copy for i 0 i lt numBytes itt if xmit Widx 1 uart Xmit Ridx xmit Widx 1 XMIT BUF SIZE amp amp
59. n and if a message is pending transmits a MAC 17 command requesting the data using slotted CSMA CA The coordinator acknowledges the successful reception of the data request from the device by transmitting an optional acknowledgement frame The requested data frame is then sent by the coordinator using slotted CSMA CA The device may send an optional acknowledgement frame The coordinator will then remove the frame from its list of pending frames in the beacon The sequence is summarized in Figure 2 9 1 Coordinator Beacon Data Request Acknowledgment Data M Acknowledgment Figure 2 9 Communication from a coordinator in a beacon enabled network 1 When the coordinator needs to transfer data to a device in a non beacon enabled network it stores the data and waits for the device to make contact and request the data The device will send MAC command requesting the data using unslotted CSMA CA The coordinator may send an optional acknowledgement frame indicating successful reception of the request If any data is pending the coordinator transmits the data using unslotted CSMA CA to the device else it will send a zero length payload frame 18 indicating there is no data available The device acknowledges successful receptions with optional acknowledgement frame The sequence is summarized in Figure 2 10 2 Network Coordinator Dave Data Request Acknowledgment Data Acknowle
60. n frame data frame acknowledgement frame and MAC command frames which are used for MAC peer to peer communication The seguence number field is used to identify successful transmission of a frame when the received acknowledgment frame contains the same seguence number The frame check seguence FCS is a 16 bit International Telecommunication Union Telecommunication Standardization Sector ITU T cyclic redundancy check CRC to ensure data integrity 1 2 4 2 Superframe structure The standard allows the optional use of a superframe structure illustrated in Figure 2 6 The superframe is sent by the coordinator bounded by network beacons It is divided into 16 equally sized slots A device can transmit at any time during the slot but must finish before the next superframe beacon The channel access during the time slots is contention based For low latency applications or applications requiring specific data bandwidth the PAN coordinator may dedicate portions of the active superframe to that application These portions are called guaranteed time slots GTS The GTS form the 15 contention free period CFP which always appear at the end of the contention access period CAP AII contention based transactions must be complete before the CFP begins Superframe beacons m n ali d Figure 2 6 A MAC superframe structure 4 2 4 3 Data transfer model There are three types of data transfer transactions The
61. r x OxFF define UPPER BYTE x unsigned char x amp OxFF00 gt gt 8 x MSB y LSB define GET INT x y unsigned char x lt lt 8 unsigned char y void printBuf unsigned char buf int len void clearBuf unsigned char buf int len void printPacket unsigned char buf int len fendif f KA k k e k e e x A x END He kk kckck ck k Ck ck ck kckckck ck kc k ck ck kokckckck ck kc k ck kk CK CKkCk AKA AKA kk ck A K A kk ck AA ck X KX ck X X ck X X ck kk A kk A k ck A k ck k k ck k kk HK A AK XX File Name SLIP h ui Version 0 1 Author Sandeep Sirpatil i License GNU General Public License Purpose This file utility functions KOKCKCKCKCKCKCkCk kCkCk kCkCKCkCkCk Ck kCk k kok k Ck kc k Ck kCk Ck kk k k kc k kck ck kk k kok kk kok ARA AS include include h Printf the contenets of buffer in Hex to stderr void printBuf unsigned char buf int len TEST fprintf stderr for i 0 i lt len i fprintf stderr 02X buf i fprintf stderr void clearBuf unsigned char buf int len int i 0 for i 0 i lt len i buf i 0 void printPacket unsigned char buf int len unsigned int frameld frameld GET INT buf 1 buf 0 switch frameld case MAC SET PAN ID break case MAC GET PAN ID break case MAC SET AD
62. return 1 no new frame return 0 Serial receive Queue management functions int rx putByte char c if rx wrIdx 1 rx_rdIdx rx wrIdx 1 SLIP RX BUFF SIZI rx rdIdx return 1 Queue full amp amp LE rx buffer rx wrIdx c rx_wrldx if rx wrIdx SLIP RX BUFF SIZ Gl int 68 rx wrIdx 0 return 0 rx_getByte unsigned char c if rx rdIdx SLIP RX BUFF SIZ rx rdIdx 0 reset it E a if rx rdIdx rx_wrIdx return 1 Queue empty rx_rdldx c rx buffer rx rdIdx 1 return 0 Should be called periodically to process the input buffer int process it frame write is in progress frame is stored SLIP Process unsigned char buffer 50 ch int rtn 0 i 0 int moredata 1 rtn read fd amp buffer 50 printf Slip read return d rtn fprintf stderr f Slip read return if rtn gt 0 for i 0 i lt rtn i rx putByte buffer i TODO need to take care of Queue full condition check the current frame status if empty load new frame if rx frame isEmpty TRUE if rx frame writeFlag FALSE beginning of a new frame rx_frame length 0 while moredata TRUE a getdata flag if rx getByte amp ch 0 if a byte is received then switch ch case END if rx frame writeFlag FALSE start of n
63. ss to CC2420 for expansion 5 3 3V voltage regulator AVR ISP connector Optional IV or 4x 1 5 AA battery CC2420 RF section External RAM 1x32kB Figure 3 2 CC2420DB Overview 5 24 Figure 3 2 illustrates the various features on the CC2420DB demonstration board The board serves as a development platform There is an onboard voltage regulator which allows it to be powered by either a 9V battery for portability or a wall adaptor of 4 10V It has a standard DB9 connector for RS232 communication with the microcontroller and headers for ISP and JTAG connections which can be used to program the microcontroller and debug the application The ATmegal28L has the ability to interface an external RAM the board contains a 32KB external RAM which is quite sufficient for the program The board also features a 5 way joystick buttons and LED s A small potentiometer is connected to the on chip ADC of ATmegal28L 3 3 1 Atmel ATmegal28L Overview The ATmegal28L is a low power CMOS 8 bit microcontroller based on the AVR enhanced RISC architecture By executing powerful instructions in a clock cycle the ATmegal28L achieves throughputs approaching 1 MIPS per MHz The AVR core combines a rich instruction set with 32 general purpose working registers All the 32 registers are directly connected to the Arithmetic Logic Unit ALU allowing two independent registers to be accessed in one single instruction executed in on
64. t by the manufacturer and huge user community The TS 7200 manufacturer supports Debian distribution it is well recognized for its stability and component package management it also has a large advanced user community Debian version 3 0 woody was installed on a 512MB compact flash and TS 7200 s RedBoot boot loader was configured accordingly Debian hosts development tools for large number of programming languages this adds to the adaptability of the setup to any system The CC2420DBK was selected to be used as IEEE 802 15 4 for its features and availability of development tools for it in the lab The possible ways to interface CC2420 to the TS 7200 were set of designs of system were evaluated for their flexibility modularity and complexity and the system was designed to have a good balance of these attributes A subset of IEEE 802 15 4 protocol was implemented for Linux in C programming language A test program was developed to use the stack and communicate with another IEEE 802 15 4 device The setup is developed as an embedded wireless Linux platform The contribution of the work is to provide an open source GPL licensed IEEE 802 15 4 protocol stack and publish a paper on the work The work also provides a test setup to evaluate standard on Linux operating system 1 4 Organization of Thesis The thesis report is divided into five chapters Chapter 2 introduces the IEEE 802 15 4 protocol It discusses various features net
65. ted Real Time Distributed Computing 2003 14 16 May 2003 Page s 37 40 C Evans Pughe Bzzzz zzz ZigBee wireless standard JEE Review Volume 49 Issue 3 March 2003 Page s 28 31 C Smith Linux NFS HOWTO http nfs sourceforge net nfs howto H Sparks Cygwin NES Server HOWTO http www csparks com CygwinNFS index xhtml A Rodland Novice s Guide to AVR Development http www atmel com dyn resources prod documents novice pdf C O Hynn Downloading Installing and Configuring WinAVR http winavr sourceforge net install config WinAVR pdf TS 7200 User s Manual http www embeddedarm com Manuals ts 7200 manual rev2 2 pdf Linux for ARM on TS 7000 User s Guide http www embeddedarm com Manuals linuxarm guide rev2 0 pdf Cygwin User s guide http cygwin com cygwin ug net cygwin ug net html PuTTY user manual http www putty nl 0 58 htmldoc WinAVR manual http winavr sourceforge net install config WinAVR pdf Linux wireless sensor LAN project http linux 802 15 4 sourceforge net Universal ZigBee Stack http sourceforge net projects zigzagbee 27 28 29 30 31 45 ZigBuzz http sourceforge net projects zigbuzz M Galeev Home Networking with ZigBee http www embedded com showArticle jhtml articleID218902431 A H Ansari Hardware Development of an Embedded Wireless Evaluation Board MS Thesis University of North Carolina Charlotte Dec 2005 R Rai IEEE 802 1
66. w the user space task do not influence the kernel s response time to external interrupts In general many of the net applications network device drivers several file systems even under heavy fragmentation do not represent source of unresponsiveness and thus Linux can safely adopted in soft real time systems With kernel version 2 6 18 basic real time support is now available in the main kernel source and thus improves the real time performance With the growing advancements in Linux it is projected to continue its growth as an embedded OS 1 3 Completed Thesis work The work started with an investigation of IEEE 802 15 4 It is gaining wide support from industry for its adoption and attracting new research in various aspects of it Further investigation found no open source working implementation of IEEE 802 15 4 for Linux With Linux gaining foothold in embedded operating systems mainly for it being open source and the number of devices using Linux is increasing everyday Many of these devices will need to add IEEE 802 15 4 functionality to them and the current Work is expected to be helpful in this regard Many single board computers were considered and evaluated for their performance features price and software support A SBC with inadequate support from the manufacturer in the form of device drivers kernel patches and operating system will require enormous individual effort TS 7200 SBC was selected for its features good suppor
67. work topologies communication mechanisms and layer of the protocol Chapter 3 describes the hardware setup and the features of the individual components Chapter 4 introduces the software component It describes the software development environment the Linux environment the software stack developed and testing Chapter 5 details results and conclusions and suggests future work CHAPTER2 INTRODUCTION TO IEEE 802 15 4 The IEEE 802 15 defines the Wireless Personal Area Network WPAN The Task Group 4 is working on defining a standard for low rate WPAN LR WPAN The standard defines the physical PHY and medium access control MAC layer specifications The devices that take part in a LR WPAN can be either a reduced function device RFD or full function device FFD The FFD can take one of the three roles a personal area network PAN coordinator a coordinator or a device An FFD can communicate with other FFDs or RFDs while an RFD can communicate only with an FFD An RFD is intended for simple devices in the network such as a light switch which does not operate continuously or send large data and generally associates with a single FFD Therefore an RFD can be implemented with very minimum resources A WPAN consists of two or more devices within radio reach communicating on the same physical channel A WPAN shall include at least one FFD operating as the PAN coordinator of the network 1 Star network Peer to peer network He C X
Download Pdf Manuals
Related Search
Related Contents
Onkyo TX-NR838 Product Sheet 2376680281472953007 Stamina Products RECUMBENT BIKE User's Manual Bedienungsanleitung greenController Grundig Vertiga UMS 5101 CDC User's Manual Manuel d`utilisation HSG 1111 - Partnershop Copyright © All rights reserved.
Failed to retrieve file