Home

Atmel AVR2025: IEEE 802.15.4 MAC Software Package

image

Contents

1. 97 Figure 8 5 Atmel AVR Studio 4 JTAGICE dialog with Main tab 98 Figure 8 6 AVR Studio 4 JTAGICE dialog with Fuses tab 98 Figure 8 7 Atmel AVR Studio 4 JTAGICE dialog with Program tab 99 Figure 8 8 AVR Studio JTAGICE mkII dialog with Program tab download status 99 Figure 8 9 AVR Studio Open File 00 100 Figure 8 10 AVR Studio 4 select elf file see 101 Figure 8 11 Atmel AVR Studio Select debug platform and device window 101 Figure 8 12 AVR Studio JTAGICE dialog with Debug tab 102 Figure 8 13 AVR Studio after successful debug build download 102 Figure 9 1 Tree network 144 Figure 9 2 Promiscuous Mode Demo terminal program snapshot 147 Figure 9 3 Serial AT Interface program snapshot on node one 155 Figure 9 4 Serial AT Interface program snapshot on node two 155 Figure 9 5 Performance Test EVK Application State Diagram 158 Figure 9 6 Sequence diagram of Range measurement 159 Figure 9 7 Initializing Range measurement transmitter
2. Application re yr HIGHEST_STACK_LAYER MCL FFD is not set LI c I Accu ee 1 TAL TAL 1 AT86RF230B AT86RF212 PAL AVR PAL GENERIC AT90USB1287 1281 ATMEGA644P fes ad USBSTICK_C RCB 3 2 30B REB 2 3 230B a Sa Ts REB 5 0 212 REB 5 0 212 m RE I 1 6 1 1 1 HIGHEST_STACK_LAYER This build switch defines the layer that the end user application is actually based on The MAC software package comprises of three real layers from bottom PAL TAL and MAC Core Layer All these layer are forming the stack although not necessarily all layers are always part of the actual binary Depending upon the required functionality full blown MAC versus simple data pump the user application needs to define which layer it shall be based on that is which API it is using If an application for instance only uses the PAL and TAL layers that is MAC is not used all resources required for MAC are not part of the final application This reduces code size and SRAM utilization drastically Also if a Network Layer NWK will
3. 160 Figure 9 8 Initializing Range measurement receiver RX 160 Figure 9 9 Statistics of Range measurement sse 160 Figure 9 10 Initializing PER measurement sss 161 Figure 9 11 Main Menu after Peer Search Process in PER mode is successful 161 Figure 9 12 Transceiver Configuration sub 161 AMEL 2 250 Figure 9 13 Figure 9 14 Figure 9 15 Figure 9 16 Figure 9 17 Figure 9 18 Figure 9 19 Figure 9 20 Figure 9 21 Figure 9 22 Figure 10 1 Figure 10 2 Figure 10 3 Figure 10 4 Figure 10 5 Figure 10 6 Figure 10 7 Figure 10 8 AIMEL EEE Transceiver State Selection SUD 162 PER Test Configuration sub 162 Service Functions sub 162 Main menu after Peer Search process aborted failed 163 REB RAPA EE 166 Debug prints on reflector sssrinin anian aaa a aa 166 Sequence Diagram for Peer Search 5 22 167 Debug prints for Configuration mode followed by PER Measuremnt 169 Debug prints for Configuration mode followed by Range Measuremnt 169 Accelerometer Display 172 V3 2 with AT86RF230B and
4. Auto z Open platform options next time debug mode is entered lt lt Back Newt gt gt Finish Cancel Ver 4 15 5628 e Press Finish e In case there has been more than one JTAGICE detected a window pops up asking to select the proper JTAGICE to be used The JTAGICE mkll Dialog opens Select the Debug tab Within the Debug tab make sure that Preserve EEPROM contents when reprogramming device is selected AMEL ii amp 8412D AVR 5 12 102 Atmel AVR2025 AIMEL Figure 8 12 AVR Studio JTAGICE dialog with Debug tab JTAGICE mkII mu x Connection Debug Status PwM Bun timers in d mode Always activate eftemal reset When reprogramming device Print breakpoint information in output windo Disable use of BREAK instruction for breakpoints Iv Enable 1 0 Debug Register IDA in run mode Program Startup Entry function warm and break if not found not in section corresponding to boot reset fuses r Program Download CA dina pbiect file Only reprogram device if object file has changed Restore Defauts Abbrechen Ubemehmen e Press OK The image will be downloaded and the download status is indicated within Atmel AVR Studio 4 e Now Atmel AVR Studio 4 looks like Figure 8 13 Figure 8 13 AVR Studio after successful debug build download
5. available in AT86RF233 X Desensitization Disabled Toggling Receiver Desensitization 3 dBm depends For changing TX power of the radio transceiver TX Power on Allows the user to enter TX power in absolute dBm Transceiver values or TX_PWR register values A Auto ACK Disabled To enable disable auto ACK request Retransmission Disabled To enable disable auto re transmission for no ACK packet M CSMA Enabled To enable disable CSMA functionality for TX Antenna To toggle the antenna diversity mode on the node Y Diversity Enapleg connected to the PC Table 9 7 Description for Sub menu Transceiver State Selection 2 MGN Functionalities Derav Comment Option Value 5 RESET Allow the user to reset the transceiver AIMEL 163 m 8412D AVR 5 12 AIMEL Table 9 8 Description for Menu amp Default B DEEP SLEEP _ in DEEP SLEEP Only available in T SLEEP Put the transceiver SLEEP G TRX_OFF Put the transceiver in TRX_OFF state J PLL_ON Put the transceiver PLL_ON state K RX_ON Put the transceiver in RX_ON state Sub menu PER Test Configuration 3 Option Functionalities Value Comment No of test frames to be transmitted Max value N Test Frames 100 4 294 967 295 L Frame length 20 of frame inclusive of headers limits 12 Q Diversity Enabled To enable disable the antenna diversity on t
6. ma 1 e On the project property window select Debugging tab Here select the debugger and interface Make sure that Preserve EEPROM is selected 8412D AVR 5 12 AIMEL 108 Atmel AVR2025 Configuration N A Platform z Build Events Toolchain Selected debugger m CTITAGICE 070000004086 ID Interface ED Device JTAG Clock Debugging The JTAG Clock frequency must be lower than 1 4 of frequency the device is Advanced operating on Use external reset Use external reset m JTAG Daisy chain settings Target device is not part of a JTAG daisy chain C Daisy chain Devices before fo Instruction bits before Jo Devices after o Instruction bits after s e Start Debug session Figure 8 23 AVR Studio 5 Start Debugging and Break 2815 File Edit VAssistX Project Build Debug Tools Window bal Fd A 3 4_ i wATmegal281 JTAG on JTAGICE mk Pll Start Debugging and Break gt Start Debugging FS Start Without Debugging CtrieFS QF Ee ED oA S1 tion Explorer Reset Build e Solution Promiscuous Mode Demo 1 project Configuration N A Disable debugWIRE and Close E 11 Promiscuous Mode Demo Build Events gk Attach to Process a Dependencies 5 Output Files Exceptions Ctri
7. 39 Figure 4 12 Provided functionality for ASSOCIATION INDICATION RESPONSE and ASSOCIATION REQUEST CONFIRM 40 Figure 4 13 Provided functionality for ORPHAN INDICATION RESPONSE and SCAN ORPHAN REQUEST CONFIRM orphan scan procedure 42 Figure 4 14 Start of non beacon network and active scan 43 Figure 4 15 Enabling of receiver and proper data reception 44 Figure 4 16 Synchronization and loss of synchronization 45 Figure 4 17 Usage of the security layers by an 48 Figure 6 1 Build configuration example 4440400 58 Figure 6 2 Handling of promiscuous 61 Figure 6 3 Inclusion of vendor 68 Figure 7 1 Content of frame info 1 87 Figure 7 2 Transmission of periodic Beacon 88 Figure 8 1 Atmel AVR Studio verifying and setting of IEEE address 96 Figure 8 2 AVR Studio 4 Connect dialog s 97 Figure 8 3 Atmel AVR Studio 4 Select AVR Programmer dialog 97 Figure 8 4 AVR Studio 4 Select JTAGICE
8. 39 4 4 5 ASSOCIATION REQUEST CONFIRM 39 4 4 6 DISASSOCIATION BASIC 40 4 4 7 DISASSOCIATION _ 0 41 4 4 8 MAC scan components ssssssssseeeeeee 41 4 4 9 MAC ORPHAN INDICATION 41 8412D AVR 5 12 Atmel AVR2025 4 4 10 MAC START REQUEST 2 42 4 4 11 ENABLE 43 418 MAC SYNC REQUEST ico do i toits 44 4 4 13 SYNC LOSS INDICATION ect 44 4 4 14 MAC BEACON NOTIFY ren 45 4 4 15 MAC GET 0 0 4 0 45 4 4 16 PAN ID CONFLICT AS PO 46 4 4 17 PAN ID CONFLICT NON PO ettet tens 46 4 5 Support of AVR platforms larger than 128Kbyte program memory 46 4 5 1 Gene Pal visors 46 4 5 2 Stack implementation nennen nennen nnne 46 4 5 3 Application Support iin Eee CE 48 4 6 Application security 48 4 7 High density network configuration 22 49 48 High data rate
9. 8412D AVR 5 12 AMEL pal_timer_start TIMER_TX_DATA DATA_TX_PERIOD IMEOUT_RELATIVE void app timer cb NULL else Something went wrong restart wpan mlme reset req true If MAC SUCCESS is returned the coordinator has assigned a short address to this device and the application is ready for data transmissions An application timer is started with two seconds timeout If the timer triggers the following callback function is executed It initiates the data transmission and restarts the timer again static void app timer cb void parameter Send some data and restart timer uint8 t src addr mode wpan addr spec t dst addr uint8 t payload static uint8 t msduHandle 0 Src addr mode WPAN ADDRMODE SHORT dst addr AddrMode WPAN ADDRMODE SHORT dst addr PANId DEFAULT PAN ID dst addr Addr coord addr short addr payload uint8 t rand any dummy data msduHandle c increment handle wpan mcps data req src addr mode amp dst addr 1 amp payload msduHandle WPAN TXOPT ACK pal timer start TIMER TX DATA DATA TX PERIOD RELATIVE void app timer cb NULL 1410 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 The usr_mcps_data_conf callback function is a stub indicating the status of the data transmission It can be adapted to the user s needs vo
10. B File Project Build Edit View Tools Debug Window Help eee eee ee ee fA c su gt 1 1 2 Trace Disabled X de To AN MB e eom Gbrief Main Name Value Typi int main void 29 Program Counter 09000386 Initiali M 4 gt W XWatch 1 Watcha Watch 3 Welch 4 Stack Pointer Dx21FD if wpan in X pointer 0x0896 vx Y pointer x21FF x ANALOG COMPARATOR Z namtar N7014 Stayy c Value 4 Project Processor B cAAtmelAVR202 4 gt CONVERTER 3 12 ANALOG COMPARA ge E BDOT LOAD Loaded plugin 5 500 B cru Loaded plugin AYR GCC E EEPROM xl Loaded partFile C Atmel Tools A RStudio PartDescriptionFiles ATmega1281 Loaded objectfile c Atmel AYR2025 MAC_v_2_x_y Applications MAC_Examples Name Address Value Bits Loaded partfile C Atmel Tools AVRStudio PartDescriptionFiles ATmegal281 Loaded objectfile C Atmel AVR2025 MAC_v_2_x_y Applications MAC_Examples KI 2 Elsuild Message Find in Files Lj Breakpoints and Tracepoints ATmegal281 JTAGICE mkII Auto Stopped Lniii Col1 CAP NUM C 3 e n case the IEEE address of the node is stored in the internal EEPROM of the microcontroller perform as follows 8412D AVR 5 12 Atmel AVR2025 o Check whether valid IEEE address different from OxFFFFFFFFFFFFFFFFand 0x0000000000000000 is stored in the
11. 17 4 1 1 Frame transmission 17 4 1 2 Frame reception mener 21 4 2 Frame buffer 23 4 2 1 Application on top of 4 2 0 0 0 1 0 23 4 2 2 Application on top of 28 43 Configuration files ennt enne nnne nennen 33 4 8 1 Application resource configuration app 35 4 3 2 Stack resources configuration stack 35 4 3 3 PAL resource configuration pal 35 4 3 4 TAL resource configuration tal_config h 35 4 3 5 MAC resource configuration 36 4 3 6 NWK resource configuration nwk 36 4 3 7 Build configuration file build 1 36 4 3 8 User build configuration file mac user build config h 36 4 4 37 4 4 1 MAC INDIRECT 4 4424414 000 00000 38 4 4 2 MAC INDIRECT DATA 38 4 4 3 MAC PURGE REQUEST 2 0 4 10 00 39 4 4 4 ASSOCIATION INDICATION
12. 915 7 256 I Boards _5_0_ ARM REV 3 L REB 2 3 REX ARM REV 2 L REB 4 0 2 REX ARM REV 3 Hinc srce L startup Hinc L sre 5 3 915 354 I Boards L SAM3 RFEKO1 L SAM3 RFEKO02 Hinc src AT91SAM3S4C L RZ600 212 SAM3SEK L RZ600 230 SAM3SEK L RZ600 231 SAM3SEK Hinc src Hinc L sre I Libraries I usb L common L cdc L core AIMEL amp 8412D AVR 5 12 12 Atmel AVR2025 320 3 3256 L Rz600_212 L nRz600 230 L RzZ600 231 Hinc srce 320 31 064 I 8oards L RZ600 212 UC3LEK L RZ600 230 UC3LEK L RZ600 231 UC3LEK Hinc srce AT32UC3B1128 I Boards L REB 2 3 STK600 L REB 4 0 STK600 L REB 5 0 STK600 L REB 7 0 STK600 Hinc src Hinc L sre I Libraries I usB L cdc serial L Src 1281 I 8oards I RCB 3 2 PLAIN L RCB 3 2 SENS TERM BOARD I RCB 4 0 PLAIN L RCB 4 0 SENS TERM BOARD I RCB
13. INTERRUP Set SEL as output pin AT91C BASE gt OER SEL AT91C BASE gt PER SEL Used peripheral interface is SPIO PIN The clock to the utilized SPI 0 peripheral is enabled AT91C BASI to P PMC PMC PCER BV AT91C ID SPIO brief Initializes the transceiver interface This function initializes the transceiver interface This board uses 5 1 Ef 8412D AVR 5 12 AIMEL 211 AIMEL EEE void trx_interface_init void Peripheral B R AT91C BASE gt BSR MISO MOSI SCK AT91C BASE gt PDR MISO MOSI SCK AT91C BASE gt ASR TRX INTERRUPT PIN AT91C BASE gt PDR TRX INTERRUPT PIN Set SEL as output pin AT91C BASE gt OER SEL AT91C BASE gt PER SEL Used peripheral interface is 5 1 The clock to the utilized SPI 1 peripheral is enabled AT91C BASE gt PCER BV AT91C ID SPI1 11 8 2 8 Step 8 File pal config h This header file contains configuration parameters for the target platform such as CPU frequency for this particular board IRQ pins pins between transceiver and MCU LED pins button pins timer clock source definitions debug macros etc The following i
14. mkII 71 1281 JTAG gt Apply Ox1E 0x97 0x04 Read 1 3 3 Read Interface settings Device Tool information Erase Device Device information Verify device after programming Memories a E Fuses Lock bits Program Verify Read e The image will be downloaded onto the target and the status will be indicated AIMEL 105 amp 8412D AVR 5 12 AMEL Figure 8 19 AVR Studio 5 AVR Programming dialog with Memories tab JTAGICE mkII 070000004DF6 AYR Programming 2 x Tool Device Interface Device ID Target Voltage JTAGICE mkII 1281 gt Apply 0x1E 0x97 0x04 Read 3 3 Read Interface settings p Device Tool information Erase Device Device information IV Verify device after programming Memories Flash Fuses Lock bits Erase device before programming Program Verify Read EEPROM Verify Read Erasing device OK Programming Flash OK Verifying Flash OK Verifying Flash OK e Close the AVR Programming dialog This starts the application No further feedback within AVR Studio 5 can be seen In order to verify the proper functioning of the application check the corresponding outputs LED status Sniffer output Terminal Window output etc e In case the application does not work as desired and esp
15. 8412D AVR 5 12 20 21 AIMEL amp Tool Chain section is updated for AVR32 SAM Build Switches WATCHDOG SLEEPING_TIMER for AVR32 XMEGA Platforms added 15 6 Rev 2025I MCU Wireless 10 10 Released with AVR2025 MAC Version 2 5 3 22 Build switch ENABLE_RC_OSC_CALIBRATION for Mega RF platforms added 15 7 Rev 2025H MCU Wireless 08 10 Released with AVR2025 MAC Version 2 5 2 23 24 25 26 MAC Example Star_High_Rate added High Data Rate support added Platform description for RZ600 on top of Xplain board added Platform description for ATZB ZigBit Modules on top of MeshBean2 board added 15 8 Rev 2025G MCU Wireless 08 10 Released with AVR2025 MAC Version 2 5 1 Description of new design of TAL and MCL added Description of Tiny TAL added Support for ZigBit 212 added New compiler switches added Support for ATxmega256A3 added Migration Guide from 2 4 x to 2 5 x added High density Network Configuration added Frame transmission and reception procedure added Buffer handling description added 15 9 Rev 2025F MCU Wireless 02 10 Released with AVR2025 MAC Version 2 4 2 36 37 38 39 40 Support of program code larger than 128KByte added PAN Id conflict detection handling added Support for AT91SAM7XC added Description of application security added Description of security build switches updated 15 10 Rev 2025E MCU Wireless 01 10 Released with AVR2025 MAC Versio
16. 95 8 3 1 Using AVR Studio 4 95 8 3 2 Using AVR Studio 4 after command line build of application 96 8 3 3 Using AVR Studio 5 sse 103 8 3 4 Using IAR Embedded 109 8 3 5 Using IAR AVR 32 Embedded 116 8 3 6 Using AVR32 GCC commandline 122 8 3 7 Using IAR ARM Embedded 123 8 3 8 Using Atmel SAM BA programming for Atmel SAMSS devices 127 9 Example applications itia pt kns aiia t inen a Rari A bdo 132 9 1 Walking through a basic application 132 9 1 1 Implementation of the 132 9 1 2 Implementation of the 2 136 9 2 Provided examples 141 9 2 1 MAG examples tin eee resi E ia ea 141 9 2 2 I Ecl 156 9 2 3 STB examples iced te ote rte fiae 173 9 3 Common SIO Nandler aaa anaia 178 9 4 Handling of callback 180 9 4 1 MAG callbacks 2 Ft adde ire Read 180 9 4 2 TAE callbacks uir ct echa de e R EAER E i 181 9 4 3 Example for MAC callbacks
17. Get the next available short address for this device uintlo6o_t associate short addr macShortAddress_def if get next short addr DeviceAddress amp associate short addr true wpan mlme associate resp DeviceAddress associate short addr ASSOCIATION SUCCESSFUL else wpan mlme associate resp DeviceAddress associate short addr PAN AT CAPACITY As soon as the usr mlme comm status ind callback function is called by the coordinators MAC layer with status MAC SUCCESS the device is associated successfully with the coordinator and will periodically that is about every two seconds send data to the coordinator Received data packets are indicated by the MAC layer to the application by calling the usr mcps data ind callback function Further handling of the received dummy data can be implemented by the user as desired 9 1 2 Implementation of the device The source code of the device is located in Applications MAC Examples Nobeacon Applicatoin Device Src main c and the header file in Applications MAC Examples Nobeacon Application Device Inc app config h 16 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Platform related project Makefiles files for AVR GCC AVR Studio and IAR Workbench are located in the corresponding subdirectories Applications MAC_Examples Nobeacon Device lt platform gt The example application can be opened using the AVR Studio the IAR EWW o
18. include mac user build config h else The standard feature definitions for an FFD or RFD configuration are by passed and instead the user defined feature set from mac_user_build_config h is used This features set needs to be defined entirely that is each feature needs to be either enabled or disabled An example for a basic MAC application that only needs minimum features and thus only requires minimum resources can be found at Applications MAC_Examples Basic_Sensor_Network Example 1 An end device that does neither use association nor disassociation functionality but still wants to poll indirect data from its parent may set the following the build switches in file mac user build config h define MAC ASSOCIATION INDICATION RESPONSE define MAC ASSOCIATION REQUEST CONFIRM define MAC DISASSOCIATION BASIC SUPPORT define MAC DISASSOCIATION FFD SUPPORT define MAC INDIRECT DATA BASIC 1 define MAC INDIRECT DATA FFD Example 2 A network whose nodes read their fixed network parameters from a persistent store and thus never perform scanning or start a network may set the following build switches in file mac user build config h define MAC SCAN ACTIVE REQUEST CONFIRM define MAC SCAN ED REQUEST CONFIRM define MAC SCAN PASSIVE REQUEST CONFIRM 0 0 define MAC
19. AIMEL amp 10 Supported platforms This chapter describes which hardware platforms are currently supported with the Atmel AVR2025 software package A platform usually comprises of three major components e An MCU e A transceiver chip this may be integrated into the MCU for Single Chips e A specific Board or even several boards that contain the MCU or the transceiver chip The supported software for each platform can be found in the directory PAL 10 1 Supported MCU families 10 2 Supported MCUs Currently the following generic MCU families are supported AVR32 Atmel AVR32 platforms e SAM3 Atmel SAMSS platforms ARMT Atmel ARM7 platforms e AVR Atmel AVR 8 bit ATmega platforms e MEGA_RF Atmel AVR 8 bit ATmega RF Single Chip platforms e XMEGA Atmel AVR 8 bit ATxmega platforms The dedicated code for each platform family can be found in the corresponding subdirectories Within each platform family a number of MCUs are supported These are for example the Atmel AT32UC3X Atmel 1281 Atmel 128 1 Atmel ATmega128RFA1 Atmel 905 7 256 Atmel AT91SAM3SAX etc For a complete list of the actually supported MCUs please refer to the Atmel AVR2025 release notes MAC Release Notes txt in directory MAC_v_x_y_z Doc or directly look into the various subdirectories as mentioned in Section 10 1 10 3 Supported transceivers 10 4 Supported boards 184 Atmel AVR2025 For a complete lis
20. Atmel AT86RF230B and 1281 See PAL AVR ATMEGA1281 BOARDS RCB_3_2_ PLAIN Figure 10 1 V3 2 with AT86RF230B and 1281 2 FFETTYTTE 10 4 1 3 Plain radio controller board RCB231 V4 0 e Atmel AT86RF231 with and 1281 See PAL AVR ATMEGA1281 BOARDS RCB_4_0 PLAIN Figure 10 2 V4 0 with AT86RF231 and 1281 AMEL 185 8412D AVR 5 12 AIMEL 10 4 1 4 Plain radio controller board RCB231ED V4 1 1 e Atmel AT86RF231 with Antenna Diversity and Atmel ATmega1281 See PAL AVR ATMEGA1281 BOARDS RCB_4_1_ PLAIN Figure 10 3 RCB V4 1 with AT86RF231 and 1281 10 4 1 5 Plain radio controller board RCB231SMA V5 3 2 Atmel AT86RF212 with 1281 See PAL AVR ATMEGA1281 BOARDS RCB_5_ 3 PLAIN Figure 10 4 V5 3 with AT86RF212 and ATmega1281 10 4 1 6 Plain radio controller board RCB V6 3 with Atmel ATmega128RFA1 Atmel ATmega128RFA1 Single Chip only See PAL MEGA_RF ATMEGA128RFA1 Boards RCB_6_3_PLAIN 16 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 10 5 V6 3 with Atmel ATmega128RFA1 J6 3 1 060425 FF ami 10 4 1 7 Plain radio controller board RCB V6 3 2 with Atmel ATmega256RFR2 Atmel ATmega256RFRe Single Chip only See PALMEGA RFATMEGA256RFR2 Boards 6 3 2 SENS TERM BOARD Figure 10 6 RCB V6 3 2 with Atmel ATmega256RFR2 10
21. MMACNSrcNusr mlme associate conf c MMACNSrcNusr mime associate ind c MAACNSrcNusr mlme beacon notify ind MMACNSrcNusr mime comm status ind c MMACNSrcNusr mlme disassociate conf MNMACNSrcNusr mlme disassociate ind MMACNSrcNusr mlme get conf c name MAC Srce usr_mlme_orphan_ind c lt nam MAC Src usr_mlme_poll_conf c lt name 231 AIMEL fee en lt file gt lt name gt SPROJ_DIRS name gt lt file gt lt file gt lt name gt SPROJ_DIR gt lt file gt lt file gt lt name gt SPROJ_DIR e gt lt file gt lt file gt lt name gt SPROJ_DIR name gt lt file gt MAC Srce usr_mlme_rx_enable_conf c lt Ves SHG USt_ mime scan_cont c lt name Nes Vou WMAC Sre USst mine start cont c lt nam MAC Srce usr_mlme_sync_loss_ind c lt e Add the sio_handler source files in file Promiscuous_Mode_Demo ewp to lt file gt lt name gt SPROJ_DIRS lt file gt lt file gt lt name gt SPROJ_DIR lt file gt lt file gt lt name gt PROJ_DIRS ler c name file file name PROJ DIRSN write c lt name gt lt file gt 11 5 4 Step 4 Update the Atmel AVR Studio project files The AVR Studio project file that is aps file of the target application is located in the directory of the target platform that is 232 Applic
22. 206 11 2 Bring up of a new 206 11 3 Bring up of a new hardware 206 11 3 1 Implementation of PAL for target 206 11 3 2 Example implementation of PAL for Atmel AT91SAM7X256 based platform 208 11 3 8 Bring up of an existing MAC application on the target platform 215 11 4 Bring up of anew MCU based on a supported MCU family 218 11 4 1 Implementation of PAL for target 218 11 4 2 Example implementation of PAL for Atmel 256 220 11 4 3 Bring up of an existing application on the target 222 11 5 Bring up of a new application on an existing platform 225 11 5 1 Step 1 Identify a matching base application 225 11 5 2 Step 2 Update the GCC 226 11 5 8 Step 3 Update the IAR project 229 11 5 4 Step 4 Update the Atmel AVR Studio project 232 11 6 Customizing the platform clock 233 11 6 1 Customizing Atmel 128 1 platforms 233 12 Protocol imple
23. AT91SAM7XC EK is handled similar to the AT91SAM7X EK 10 4 5 ATmega128RFA1 EK1 evaluation kit The Atmel ATmegai28RFA1 EK1 Evaluation Kit provides an Atmel 5 600 ATmega128RFA1 Top Card that can be used in conjunction with the STK600 board No further Routing Cards are required See PAL MEGA_RF ATMEGA128RFA1 Boards EK1 It provides currently three LEDs and one button for user interaction similar to RCBs The buttons and LEDs from the STK600 base board are not supported Both UARTO and UART1 are supported UART1 is default in provided example applications The following picture depicts an Atmel ATmega128RFA EK1 Top Card placed on Atmel STK600 base board and the board setup connected to an Atmel AVR JTAGICE and setup for utilization of UART1 8412D AVR 5 12 AMEL 197 AMEL Figure 10 23 ATmega128RFA1 EK1 on STK600 ony ly d ANR g 99900 005952 29900 2 iia 08 20009 le I 1 1 1 58 00000 ocked 44 position 7 Ai NE A TT Please note that jumper J11 see red circle in Figure 10 needs to be placed as shown in Figure 10 if no current measurements are done in order to provide the proper voltage to the board Figure 10 24 ATmega128RFA1 EK1 on STK600 with JTAGICE using UART1 18 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 10 25 Atmel ATmega128RFA1 EK1 wiring fo
24. Debugger gt Plugins Options for node Wireless Touch Category Factory Settings General Options C C Compiler Assembler Java to Custom Build Build Actions Setup Extra Options Select plugins to load AYR ONE JTAGICE mkII Simulator Description Enables the Stack window in the debugger a memory windt Location C Program Files IAR SystemsXE mbedded Workbench 5 64 Originator Systems Version 5 6 0 1356 OK e Press e Press the button Download and Debug 8 3 5 2 Starting the debug build The debug build can simply be started as follows e Make sure that only the JTAGICE of the node where the current build shall be downloaded to is switched on Switch off all other JTAGICE e Open IAR Embedded Workbench by double clicking the desired eww file e Select the Debug Workspace e Open the Options window for the Debug Workspace Select the Debugger window and within this window select the Setup tab 15 Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 Figure 8 36 IAR AVR32 Embedded Workbench Options gt Debugger gt Setup Options for node Wireless Touch E Category Factory Settings General Options C C Compiler Assembler Jaya to C Extra Options Plugins Driver Run to main Custom Build Build Actions L
25. Hinc L sre Hinc L sre Hinc L sre Basic Sensor Network Hinc Promiscuous Demo LI AT86RF230B 1281 ATZB 24 MN2 Hinc AIMEL 9 amp 10 STB TA 1 L Build Hece Atmel AVR2025 A MEL SEE Hinc _ Examples I L ATMEGA128RFA1 6 3 PLAIN I inc L sSrc L star Nobeacon secure Remote Control L secure Sensor Sink Hinc L sre Hinc sensor dee EGA128RFA1 6 3 SE NS Hinc L sre L src L secure Star Network I coordinator o I AT86RF231 AT91SAM7X256 RI Hinc L sre L pevice I RM BOARD EB 402R EX ARM REV 3 Hinc L Examples Hinc L Src L__avR L AVR32 L IAR H ARM L AVR L AVR32 Performance EVK 8412D AVR 5 12 Atmel AVR2025 1 ication_Guide Manual mac L PAL ATMEGA128RFA1 6 3 PLAIN L__uUser Guide Include I Ac Hinc L Src I PAL 7
26. Only two devices are allowed connecting each other communicating A switch on the board is required to enter into Range Measurement mode and configuration mode In case of the ATREB231FE2 EK two nodes should be kept at least 50cm apart to avoid the distortion due to high TX Power levels 9 222 Accelerometer Display App The TAL example Accelerometer Display App demonstrates the LCD and accelerometer present on the key remote controller board The application is targeted to demonstrate the capabilities of Atmel Transceivers on chip peripherals such as LCD and accelerometer This application requires two or one of the key remote controller board s The following observations user has to keep in mind before testing this application e During application startup the LCD will display the ATMEL logo e Then the user will get the message calibrating e Now remote controller board must be placed on a flat surface undisturbed so that the application can take the current accelerometer reading as reference and output the values accordingly e After the application has finished the calibration the LCD will display calibration done e After this the user can make use of the remote and tilt it to any position to see the logo slide across the LCD e f two or more remotes are used the user can see the transition in all of them A sniffer is suggested in order to check the proper association and the data transfer between
27. Usage in IAR ewp files CHINESE_BAND enables the channel page for the Chinese band as default For more information please check fal_constants h directory TAL AT86RF212 Inc Example applications using this build switch in Makefiles or IAR project files can be found in directory Applications TAL_Examples Wireless_UART AT86RF212_780_MHZ_ATMEGA128 1 RCB 5 3 SENS ERM BOARD 6 1 4 5 RSSI LQI MAPPING This build switch is used to control the mechanism for calculation of the normalized LQI value of received frames The normalized LQI value that is provided to the higher layer of the MAC as parameter ppduLinkQuality is e based on the RSSI ED value switch RSSI TO LQI MAPPING is used where only the ED value signal strength is mapped to a LOI value or is e based on the ED signal strength and the measured LQI value quality of received packet switch RSSI TO LQI MAPPING is not used For further information about the LOI value see IEEE 802 15 4 2006 Section 6 9 8 The build switch RSSI MAPPING reflects the and or relation described in the first paragraph of the mentioned section If RSSI TO LOI MAPPING is set signal strength is only used for measurement Usage in Makefiles CFLAGS DRSSI LQI MAPPING enables the calculation of the normalized LQI value based on RSSI ED value Usage in IAR ewp files RSSI TO LOI MAPPING enables the calculation
28. e serial connection for typing messages and displaying the received data from the other device Depending on the available Serial I O interface for each board this can be either UART or USB In order to start the application and to see the output of the application please start a terminal application on your host system and press any key for the application to begin The node acting as data sink PAN Coordinator starts a non beacon enabled PAN at channel DEFAULT CHANNEL with the PAN ID DEFAULT PAN ID The sensor Device scans for this network and associates to the data sink PAN Coordinator Once the sensor Device is associated it uses a timer that fires every two seconds to transmit a random payload sensor measurement data to the data sink The frames are secured according to ZigBee CCM network layer security e The network header is omitted only the auxiliary security header is constructed 14 byte long e The applied security level is 0x06 that is encrypted payload authentication applied MIC 8 byte long e The random payload has 13 byte length The LEDs signal the following status Sensor Device e LED 0 on Application is running e LED 1 on Sensor Device is associated to Data Sink Coordinator e LED 2 blinking slowly Data frames are sent one every two seconds Data Sink Coordinator e LED 0 on Application is running e LED 1 on Network is started e LED 2 blinking slowly Data frames are received one eve
29. is set in the corresponding project files e Number of transceiver interrupts NO_OF_TRX_IRQS This is set to 1 for all Atmel AT86RF230B platforms and remains unchanged Add the following comment Number of used TRX IRQs in this implementation Even if the 231 transceiver generally provides an additional interrupt for convenient timestamping it is not used for this board s define NO_OF_TRX_IRQS 1 e Macros for handling transceiver interrupts enabling disabling clearing of transceiver interrupts Remain unchanged e Macro for critical region with respect to transceiver interrupts Remain unchanged e PAL_USE_SPI_TRX Remains unchanged since Atmel AT91SAM7X256 uses SPI as interface to the transceiver e SPI registers and pins In case the transceiver is connected differently than on the base platform these SPI registers and pins used on the MCU need to be updated Change SPI Base Register SPIO is used with REX ARM Rev 2 f define AT91C BASE SPI USED AT91C BASE SPIO RESET pin is pin 9 of PIOA define RST 91 9 Sleep Transceiver pin is 8 of PIOA AIMEL 213 amp 8412D AVR 5 12 214 to AMEL define SLP_TR AT91C_PIO_PA8 Slave select pin is PA14 define SEL AT91C 14 SPIO NPCS2 SPI Bus Master Output Slave Input pin is 17 ul define MOS
30. 5 Additional queues and buffers can be used by higher layers like application such as the MAC NHLE Queue 2 2 2 Security abstraction layer 2 2 3 Security toolbox The SAL Security Abstraction Layer provides an API that allows access to low level AES engine functions abstraction to encrypt and decrypt frames These functions are actually implemented dependent on the underlying hardware for example the AES engine of the transceiver The API provides functions to set up the proper security key security scheme ECB or CBC and direction encryption or decryption For more information about the SAL API see file SAL Inc sal h For information about the usage of the SAL for application security see Section 4 6 The STB Security Toolbox is a high level security abstraction layer providing an easy to use crypto API for direct application access It is placed on top of the SAL and abstracts and implements transceiver or MCU independent security functionality that encrypts or decrypts frames using CCM according to 802 15 4 ZigBee For more information about the STB API see file STB Inc stb h For information about the usage of the SAL for application security see Section 4 6 2 2 44 Transceiver feature access 8412D AVR 5 12 2 2 4 1 Introduction The current 802 15 4 stack is designed to be fully standard compliant On the other hand Atmel transceivers provide a variety of additional hardware features that are not reflecte
31. 9 2 2 1 3 4 Configuration mode 168 Atmel AVR2025 AIMEL SSE acknowledgement for Peer Response from Transmitter node Reflector node enters into WAIT FOR PEER CONF state and timer called PEER CONF WAIT TIMER T2 is started with a timeout value of 200ms If the Peer confirm is not received within this time the node goes to the WAIT FOR EVENT state again Peer Response payload consists of a random generated 16 bit number used as source address rand addr2 of the receiving node i e Transmitter and the mode byte to indicate in which mode PER Range this Peer Response has been sent 3 On receipt of the Peer Response packet the Transmitter node assigns itself the address received in the frame rand addr2 as its source address IEEE 802 15 4 protocol and the node sends a Peer Confirm M3 which is a unicast to Reflector source address rand addr2 and destination address rand addr1 Peer Confirm frame consists of the address rand addr2 sent to the Transmitter node in the payload of Peer Response After receiving the acknowledgement for Peer confirm from Reflector Transmitter node enters into PEER SEARCH SUCCESS state 4 On receipt of the Peer Confirm Reflector node stops the timer T2 checks the packet and verifies the address is the same as the address it sent to the Transmitter node in the Peer Response rand addr2 If it is the same Reflector node enters into PEER SEARCH SUCCESS and the nodes are connected each other
32. ATMEGARF SAL 14 Utilization of hardware AES in ATxmega MCUs such as Atmel 128 1 by using the STB on top of the SAL SAL TYPE ATXMEGA SAL This combination can be used in conjunction with any transceiver even with Atmel AT86RF230 15 Unitization of the ARM hardware crypto engine by using STB ARMCRYPTO without any SAL This combination is supported for Atmel SAM7XC MCUS and can be used in conjunction with any transceiver even with AT86RF230 4 7 High density network configuration The IEEE standard 4 provides knobs to adjust the MAC layer to the application needs These knobs are the PIB attributes that allow configuring the behavior of the MAC In particular in high density networks where many nodes access the network at the same time it might be necessary to tweak the MAC to achieve better performance This applies to non beacon enabled and beacon enabled networks The following PIB attributes can be used to tweak the in this regard e Back off exponent The PIB attributes macMinBE and macMaxBE determine the potential length of the back off exponent used for the CSMA algorithm By default macMinBE 3 and macMaxBE 5 In order to reduce the probability that different nodes use the same back off period it is recommend changing the PIB attribute values from the default values Example macMinBE 6 and macMaxBE 8 The macMaxBE value needs to be increased before the macMinBE is increase e Frame retries
33. Atmel AVR2025 IEEE 802 15 4 MAC Software Package User Guide Features Portable and highly configurable MAC stack based on IEEE 802 15 4 Atmel MAC architecture and implementation introduction Support of several microconiroller families Support of all Atmel IEEE 802 15 4 transceivers and single chips that is Atmel ATmega128RFA1 Atmel ATmega256RFR2 Atmel AT86RF212 Atmel AT86RF230 Atmel AT86RF231 Atmel AT86RF232 and Atmel AT86RF233 Example application description e o 1 Introduction This document is the user guide for the Atmel MAC software for IEEE 802 15 4 transceivers The mechanisms and functionality of the IEEE 802 15 4 standard is the basis for the entire MAC software stack implementation Therefore it is highly recommended to use it as a reference Basic concepts that are introduced by the IEEE standard are assumed to be known within this document The user guide describes the Atmel AVR 2025 MAC software package release 2 8 0 The software contains the 27 generation MAC which e Allows a highly flexible firmware configuration to adapt to the application requirements e Supports different microcontrollers and platforms boards e Supports different IEEE 802 15 4 based transceivers and single chips e Allows easy and quick platform porting e Provides project files for two supported IDEs IAR Embedded Workbench Atmel AVR Studio WinAVR e Supports star networks and peer to peer communication e Suppo
34. C 16 bit 32 bit infos _ 0 20000000 xCDCDCDCD xCDCDCDCD xCDCDCDCD xCDCDCDCD A 0x20000010 OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD 0x20000020 OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD 0x20000030 OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD 0x20000040 OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD fvonnnnnsn Avyenenencn Ayenenencn Avyenenencen Ayenenencn lt Flash NandFlash SRAM Download Upload File Send File Name gt Send File Receive File Name gt Receive File Address 0 400000 Size For Receive File 0 1000 byte s Compare sent file with memory SAM BA v2 10 1 96 Board at91sam3s4 ek AIMEL 131 e AIMEL EEE 9 Example applications The MAC package includes a variety of example applications which can be flashed on the supported hardware platforms and be executed immediately On the other hand the complete source code is provided to help the application developer to more easily understand the proper utilization of the stack and to be able to build its own applications as fast as possible The provided example applications can categorized in three main groups being located in the corresponding subdirectories of directory Applications e MAC examples e TAL examples e STB examples These applications will be explained in more detail in the subsequent sections see Section 9 2 If the example application makes use of
35. e usr mlme sync loss ind These callback functions are declared in file MAC Inc mac api h Each MAC based application HIGHEST STACK LAYER MAC needs to implement these usr callback functions For example an application that uses data transmission mechanisms will call a function wpan mcps data request which in return requires the implementation of the corresponding asynchronous callback function usr mcps data conf to indicate the status of the requested data transmission But the same application might for example not want to use the MAC primitive MLME SYNC LOSS indication Nevertheless the callback function usr mlme sync loss ind needs to be available or the linker generates a build error This can be solved by either implementing an empty stub function in the application or more conveniently use an already existing stub function All required MAC stub 8412D AVR 5 12 9 4 2 TAL callbacks Atmel AVR2025 functions are already implemented in the files usr_mcps_ c or usr mlme in directory MAC Src So whenever such a callback is not used by the application simply add the required usr_ c stub files to your Makefiles or IAR project files The TAL requires the following callback functions e tal ed end cb e tal rx frame cb e tal tx frame done cb These callback functions are declared in TAL Inc tal h Each TAL based application HIGHEST STACK LAYER TAL needs to implement these t
36. if status MAC_SUCCESS amp amp PIBAttribute macShortAddress 77 Allow other devices to associate to this coordinator uint8_t association_permit true wpan_mlme_set_req macAssociationPermit amp association permit else if status MAC SUCCESS amp amp PIBAttribute macAssociationPermit Initialize active scan over all channels to determine which channel to use wpan mlme scan req MLME SCAN TYPE ACTIVE SCAN ALL CHANNELS SCAN DURATION COORDINATOR else something went wrong restart wpan mlme reset req true Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Depending on the status information the application will proceed either with the request to set the association permit PIB attribute see macAssociationPermit for further details The MAC layer will process the request and executes the function usr_mlme_set_conf Now the PIBAttribute parameter is equal to macAssociationPermit and the scan procedure will be initiated with wpan mlme scan Next time the main loop is running this request is processed by the MAC layer and the usr_mlme_scan_conf callback function will be called with the result of the scan After the scan procedure has finished a new network is started by invoking the function wpan mlme start req void usr mlme scan conf uint8 t status uint8 t ScanType uint8 t ChannelPage
37. 1281 185 V4 0 with AT86RF231 and 1281 185 V4 1 with AT86RF231 and 1281 186 V5 3 with AT86RF212 and 1281 186 V6 3 with Atmel 28 1 187 REB V2 3 with Atmel AT86RF230B 190 REB V4 0 1 with 6 231 44 00000 190 REB231ED V4 1 1 with Atmel 86 231 191 Figure 10 9 REB V7 1 0 with 6 232 191 Figure 10 10 REB 8 1 0 with AT86RF2338 sssssssssseeeeneens 192 Figure 10 11 REB212 V5 0 2 with Atmel 86 212 192 Figure 10 12 REB to STK600 193 Atmel AVR2025 8412D AVR 5 12 AIMEL T Atmel Corporation Atmel Asia Limited Atmel Munich GmbH Atmel Japan 2325 Orchard Parkway Unit 01 5 amp 16 19F Business Campus 9F Tonetsu Shinkawa Bldg San Jose CA 95131 BEA Tower Milennium City 5 Parkring 4 1 24 8 Shinkawa USA 418 Kwun Tong Road D 85748 Garching b Munich Chou ku Tokyo 104 0033 Tel 1 408 441 0311 Kwun Tong Kowloon GERMANY JAPAN Fax 1 408 487 2600 HONG KONG Tel 49 89 31970 0 Tel 81 3523 3551 www atmel
38. If Reflector node does not receive any Peer Confirm within timeout the node goes into WAIT FOR EVENT state This process is followed to connect only a pair of nodes if two nodes are in the powered on state The boards are assigned random addresses and if the Peer Search process is successful then the test commences and the nodes operate in the respective operation modes Configuration mode is the startup mode in which two nodes i e Transmitter and Reflector can connect each other if they are only within in the vicinity of one meter approximately This is to restrict the distance range for connecting devices This is used generally in seminars where there are no of participants may start the Performance test at the same time With configuration mode provided each individual participant can make sure that his her two devices are only getting connected without disturbing the other devices Once the Peer Search is done successfully the nodes shall come to the normal mode where the nodes can be kept afar User can enter into configuration mode by pressing the button T1 while Power on reset The serial terminal prompts Button press while power on CONFIGURATION Then user can initiate Peer Search by key press for PER measurement or button press for Range measurement Then the device transmitter shall go to the low TX level TX PWR OxOF and sends the peer request with the config mode bit set to true On the other device reflector
39. Node two e Switch on the other node AMEL us 9 2 1 6 4 9 2 1 7 9 2 1 7 1 9 2 1 7 2 9 2 1 7 3 150 Limitations Introduction Requirements Implementation Atmel AVR2025 AIMEL quM e LED 0 indicates that the node has started properly Flashing of LED 1 indicates that the node is scanning its environment Scanning is again done three times on each available channel depending on the radio type f a proper network is discovered the node joins the existing network and indicates a successful association by switching on LED 1 e Every two seconds this node sends out a dummy data packet If the packet is acknowledged by the other node the LED 2 is flashing e The current channel is coded within the application In order to run the application on another channel change the default channel in file main c and re built the application e n order to see the further data frame exchange using High Data Rate a special sniffer is required being capable to except frames at 2Mbit s Star Push Button The application Star Push Button provides a simple start network application based on IEEE 802 15 4 2006 The application uses two nodes a PAN Coordinator 1 and an End Device 2 The firmware is implemented as such that a node can either act as a PAN Coordinator or an End Device This application demonstrates how MCU sleep modes can be utilized in the wireless networks inorder to save more power By default End D
40. Rx unknown frame without security Security on Rx unknown frame without security e The current channel is coded within the application In order to run the application on another channel change the default channel in file main c and re built the application e t is not recommended operating more than two nodes with the application simultaneously 9 2 3 2 Secure Sensor The STB example Secure Sensor deploys a nonbeacon enabled network with encrypted and authenticated frames It is using ZigBee CCM security The application consists of Sensor that is End Devices and a Data Sink that is a PAN Coordinator collecting data from the sensors This example application uses both STB and MAC API as interface to the stack The STB is used to secure and unsecure application data and the MAC is used to set up a nonbeacon enabled network perform scanning and network association and to transmit or receive secured or unsecured frames ATMEL ive 9 2 3 2 2 9 2 3 2 3 176 Requirements Implementation Atmel AVR2025 AIMEL oey The application and all required build files are located in directory Applications STB_Examples Secure_Sensor The source code of the application can be found in the subdirectory Data_Sink Src and Sensor Src This application requires e Up to three LEDs on the board in order to indicate the proper working status A sniffer is suggested in order to check frame transmission between the nodes
41. actual implementation of the code for reading the address from an external EEPROM is board dependent and might be adapted by the end user depending on their hardware If the IEEE address is stored within the internal EEPROM of the MCU located in the first eight octets of the internal EEPROM this build switch should to be omitted Usage in Makefiles CFLAGS DEXTERN EEPROM AVAILABLE enables reading the IEEE address from the external EEPROM Usage in IAR ewp files EXTERN EEPROM AVAILABLE enables reading the IEEE address from the external EEPROM 6 1 3 8 NON BLOCKING SPI Currently for all transceivers connected to the microcontroller via SPI the SPI frame download or upload is done blocking that is while the controller is access the transceiver no other action can be on the microcontroller Since more powerful microcontroller may require performing other application or stack tasks while accessing the transceiver via SPI an option to perform non blocking SPI access has been implemented This access makes use of interrupt driven SPI access for downloading frames In between the microcontroller is able to do other tasks as required AMEL s 8412D AVR 5 12 AIMEL ae The non blocking SPI can be controlled via the build switch NON BLOCKING SPI Usage in Makefiles CFLAGS DNON BLOCKING SPI enables non blocking SPI frame download Usage in IAR ewp files NON BLOC
42. finternal 0x80000000 e r v R elf e For AT32UC3B1128 avr32program exe p jtagicemkii part UC3B1128 program finternal 0x80000000 eu run R cint elf 122 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 8 3 7 Using ARM Embedded Workbench When using IAR ARM Embedded Workbench directly by double clicking the corresponding eww file the application can be downloaded onto the desired hardware platform as described below 8 3 7 1 Starting the release build The release build can simply be started as follows e Make sure that only the JTAGICE of the node where the current build shall be downloaded to is switched on Switch off all other JTAGICE e Open IAR Embedded Workbench by double clicking the desired eww file e Select the Release Workspace e Open the Options window for the Release Workspace Select the Debugger window and within this window select the Setup tab Figure 8 40 IAR ARM Embedded Workbench Options gt Debugger gt Setup Options for node Coordinator Category Factory Settings General Options C C Compiler Assembler Output Converter Download Images Extra Options Plugins Custom Build Build Actions Simulator Setup macros Angel Use macro file s GDB Server IAR ROM monitor J Link J Trace LMI FTDI E Device description file ST Link Override default Third Party Driver TOOLKIT DIRS SCONFIG debugge
43. further utilization within the application the compile switch needs to be set amp Usage Makefiles CFLAGS DENABLE TSTAMP enables the timestamping Usage in IAR ewp files ENABLE TSTAMP enables the timestamping 6 1 2 Standard and user build configuration switches 6 1 3 62 Platform switches Atmel AVR2025 The standard and user build configuration switches are described in detail in Sections 6 2 1 and 6 2 2 The PAL Platform Abstraction Layer contains all platforms that is MCU and board based functionality and provide an API to the TAL which is independent from the underlying platform 6 1 3 1 PAL GENERIC TYPE Certain portions of the PAL are generic to a specific microcontroller family Examples for such generic code are transceiver access via SPI for 8 bit AVR controller see file AVR GenericiSre pal trx access c or using Event System of the Atmel AVR XMEGA controller This code is separated from the non generic code in special directories In order to make sure that the correct code belonging to the proper microcontroller family is used for the application the build switch PAL GENERIC TYPE needs to be set accordingly The currently defined microcontroller families are e Atmel AVR e Atmel AVR32 e Atmel SAM3 e Atmel XMEGA e Atmel ARM7 For more information check file PAL Inc pal_types h Usage in Makefiles CFLAGS DPAL GENERIC TYPE XMEGA selects th
44. or 20 The sensor nodes gather their battery status and another sensor value like temperature value Every 10s the node transmits the gather data to its parent All data is routed forwarded to the ROOT node where it is printed via UART USB to a terminal program An example network topology is shown in Figure 9 1 Figure 9 1 Tree network example ROOT ROUTER LEAF This example application uses MAC API as interface to the stack This application uses the user build configuration feature described in Section 6 2 2 In order to achieve the proper functionality in conjunction with minimal footprint the actually supported MAC features that is MAC primitives are defined in a 8412D AVR 5 12 9 2 1 3 3 Network setup 9 2 1 3 4 Configuration 8412D AVR 5 12 Atmel AVR2025 corresponding header file mac_user_build_config h in subdirectory Inc of this application In order to use this header file the build switch MAC USER BUILD CONFIG needs to be set in the corresponding Makefiles or IAR project files The application and all required build files are located directory Applications MAC Examples Basic Sensor Network The source code of the application can be found in the subdirectory Src The static tree network topology is established by first starting the ROOT node and after that connecting one or more other nodes ROUTER or LEAF The node type ROOT ROUTER or LEAF is defined during power up using the
45. primitive message is assembled e The formatted MCPS DATA indication message is pushed into the MAC NHLE Queue G The dispatcher extracts the indication message and calls the corresponding callback function mcps data conf in MAC Src mac callback wrapper c if the application is residing on top of the MAC layer In case the stack utilizes another stack on top of the MAC layer the callback functions are implemented inside the higher stack layers G G H H Finally the application is notified about the reception of a Data frame data by means of the callback function usr mcps data ind if the application resides on top of the MAC layer to be implemented inside the application itself Once the received frame content is uploaded from the hardware into software during the further process of the reception of a MAC Data frame the actual payload of the Data frame only needs to be copied once within the receiving application on top of the MAC layer or on top of another Highest Stack Layer Within the stack itself the payload handling is very efficient and the content never needs to be copied 22 Atmel AVR2025 8412D AVR 5 12 4 2 Frame buffer handling 4 2 1 Application on top of MAC API Atmel AVR2025 8412D AVR 5 12 This section explains the buffer handling for applications residing on top of the MAC API HIGHEST_STACK_LAYER MAC 4 2 1 1 Frame transmission buffer handling The following
46. push button If the push button is pressed during power up the node is operated as a ROOT node or as a ROUTER node To determine that a node acts as a ROOT or ROUTER node hold the push button pressed during power up If the node does not receive any broadcast messages from another node It configures itself to ROOT node after 10s and switches LED 0 on If the node receives a broadcast message within the first 10s after power up the node stores its parent address and operates as ROUTER node Once the ROOT node has started the network ROUTER nodes or LEAF nodes can be connected to the ROOT node Connecting a node to a parent for example a ROUTER node to the ROOT node during application start broadcast messages need to be received by the child node containing the parent s address Broadcast messages can be sent by a ROOT or ROUTER node by pressing the button The next node that might be added to the network could be a LEAF node that gets connected to the ROUTER A node becomes a LEAF node if the push button is not pressed during power up To connect a LEAF node to a parent the parent node needs to send broadcast messages by pressing the push button at the parent node within the first 10s after start up of the LEAF node Once a LEAF node is connected to a parent every TX INTERVAL S seconds by default every 10s the node transmits the sensor data to its parent An LED is switched on shortly indicating the active period Also RO
47. AVR2025 8412D AVR 5 12 Atmel AVR2025 e Change all occurrences of ATXMEGA128A1 which are used as path names for directories and files to ATXMEGA256A3 This can be done using an XML editor or a regular text editor 11 5 Bring up of a new application on an existing platform The task of bringing up a new application on an existing platform is explained by the MAC example application Promiscuous_Mode_Demo for a supported platform based on the Atmel ATxmega256A3 The same steps are to be performed for all other MCUs that shall be used or all other applications respectively Each step is first described generally and then specifically explained in detail for bringing up the Promiscuous_Mode_Demo Please note that the opposite task of bringing up a new platform on an existing application is explained in Section 11 4 3 e Step 1 Identify a matching base application already supported for this platform Duplicate the directory of the base application for this platform to the corresponding target platform e Step 2 Update the GCC Makefiles Independent from whether the target application is built from command line using make or Atmel AVR Studio Project file APS files which also use external Makefiles themselves the Makefile needs to be updated to cope with the target application This includes the following steps o Replace occurrences of the name of base application with the target application for example replace Sta
48. Ansicht Anrufen bertragung App started with security off Security off Rx plaintext Toggle light Security off Rx plaintext Toggle light Security off Rx plaintext Toggle light 17 Atmel AVR2025 8412D AVR 5 12 9 2 3 1 4 Limitations 9 2 3 2 1 Introduction 8412D AVR 5 12 Atmel AVR2025 Figure 9 19 Secure remote control application transmitter in secure mode receiver in unsecure mode 21515 Datei Bearbeiten Ansicht Anrufen bertragung Ole 215 ala App started with security on Security on TX secured ok Security on TX secured ok Security on Tx secured ok Com4 9600 HyperTerminal E la xi Datei Bearbeiten Ansicht Anrufen bertragung 2158 2 3 soe App started with security off Security off Rx unknown frame with security Security off Rx unknown frame with security Security off Rx unknown frame with security Figure 9 20 Secure remote control application transmitter in unsecure mode receiver in secure mode Datei Bearbeiten Ansicht Anrufen bertragung Dias 213 sole l App started with security off Security off Tx plaintext ok Security off Tx plaintext ok Security off Tx plaintext ok Com4 9600 HyperTerminal inl xi Datei Bearbeiten Ansicht Anrufen bertragung 215 218 soie l App started with security on Security on Rx unknown frame without security Security on
49. Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 the new target board type gets a unique reasonable number in its definition The actually selected number for the board definition itself can be deliberately selected as long as it is unique in this particular board definition header file Example Boards for AT86RF230B define REB_2_3_REB_TO_SAM7EK 0x01 define REB 2 3 REX ARM REV 2 0x02 Boards for AT86RF231 define REB 4 0 2 REB TO SAM7EK3 0x11 AT91SAM7X EK and AT91SAM7XC EK boards with Radio Extender board REB231 V4 0 on REX ARM adapter Revision 3 define REB 4 0 2 REX ARM REV 3 0x12 The actual numerical value of each define is not important as long as each board within a specific TYPE has a unique value Alternatively create a new board type in a customer specific board type file called vendor boaratypes h see 11 3 1 1 11 8 2 3 Step 3 Identify an already supported board that best fits the new board as base platform From all currently supported boards based on the Atmel AT91SAM7X256 MCU the board REB 2 3 REX ARM REV 2 Atmel AT91SAM7X EK boards with Radio Extender board REB230B V2 3 on REX ARM adapter Revision 2 is selected as base platform to start the porting to the target platform REB 4 0 2 REX ARM REV 3 11 8 2 4 Step 4 Copy the board directory of the base platform Example Copy the entire board dire
50. Corea at31sam 3151 ek 122 Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Figure 8 48 Atmel SAM BA enabling flash access 2 SAM BA 2 10 at91sam3s4 ek File ScriptFile Link at81sam3s4 Memory Display Start Address 0520000000 Refresh Display format Size in byte s 0 100 0x20000000 0x20000010 0x20000020 0x20000030 0x20000040 nvonnnnnsn lt OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD nvononocnon Flash NandFlash SRAM Download Upload File Send File Name Receive File Name Address Scripts C ascii C 8 amp bit C 16 bit 32 bit xCDCDCDCD xCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD Ayencnencn AIMEL e 0400000 Size For Receive File 0 1000 byte s OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD Ayenencncn gt Receive File Compare sent file with memory Atmel AVR2025 Send File Applet traces on DBGU nts Apply 0 Board at81sam3s4 ek 129 AMEL Figure 8 49 Atmel SAM BA downloading executable file SAM BA 2 10 at91sam3s4 ek DER Fie ScriptFile Link Help at81sam3s4 Memory Display StarAddress 0x20000000 Refresh Display format Applet traces on DBGU Size in byte s 0x100 C asci Bit 16bit 32bit
51. For an example implementation of this features see MAC example application Basic Sensor Network in Section 9 2 1 1 5 4 TAL power management API 8412D AVR 5 12 The MAC power management mechanisms as described in the within this chapter are only valid if the application is residing on top of the MAC layer or a higher layer on top of the MAC In case the application is only residing on top the TAL layer the application needs to take care for transceiver power management itself Therefore the TAL provides a Power Management API which is generally used by the MAC layer but can also be used by an application residing on top of the TAL Nevertheless an application residing on top of any higher layer than the TAL must not use this TAL explicitly otherwise this may lead to undefined behavior The TAL Power Management API consists of two functions tal trx sleep tal trx wakeup For more information see talh in directory TAL Inc and the various implementations for each transceiver in tal pwr mgmt c in directories TAL TAL TYPE NAMEY SIc AIMEL 55 AIMEL amp 6 Application and stack configuration 6 1 56 Build switches Atmel AVR2025 The MAC and its modules are highly configurable to adapt to the application requirements The utilized resources can be configured and adjusted according to the application needs This allows a drastic footprint reduction During build process the required featur
52. PAN Id is found the node establishes a new network at the pre defined channel channel 20 for 2 4GHz radio This node now becomes the PAN Coordinator of this network The successful start of a new network is indicated by switching LED 1 on Node two 9 2 1 5 4 Limitations 148 Atmel AVR2025 Switch on the other node LED 0 indicates that the node has started properly Flashing of LED 1 indicates that the node is scanning its environment Scanning is again done three times on each available channel depending on the radio type If a proper network is discovered the node joins the existing network and indicates a successful association by switching on LED 1 Every two seconds this node sends out a dummy data packet If the packet is acknowledged by the other node the LED 2 is flashing The current channel is coded within the application In order to run the application on another channel change the default channel in file main c and re built the application Currently only two devices are allowed to associate to the PAN Coordinator This can be easily extended by increasing the define MAX_NUMBER_OF_DEVICES The current implementation only provides direct data transmission from device to coordinator In order to save as much power as possible the device periodically enters sleep mode between its data transmissions During these sleeping periods the receiver of the device is not enabled It is therefore not possible to simply extend the appl
53. Search unsucceessful unsucceessful Peer Search 3 4 Peer Search unsucceessful PEER SEARCH RANGE TX PEER SEARCH PER TX unsucceessful 5 6 PEER_SEARCH_RANGE_RX PEER_SEARCH_PER_RX User Aborted Peer Search successful Peer Search successful Peer Search Peer Search successful Peer Search successful 10 PER_TEST_INITIATOR timed out 11 PER_TEST_RECEPTOR 9 SINGLE_NODE_TESTS 7 8 RANGE_TEST_TX_OFF RANGE_TEST_TX_ON Button Press Periodic timer triggered packet transmission b d utton Press 9 2 2 1 2 Requirements The Packet Error Rate measurement requires a serial connection for controlling the application and displaying the results Depending the available serial I O interface for each board this can be either UART or USB In order to see the output of the application please start a terminal application on your host system 9 2 2 1 3 Implementation 9 2 2 1 3 1 Range Measurement mode During Range measurement the transmitter node will initiate a sequence to find a peer node Once peer node is found packet transmission is initiated by the transmitter to the receiver The Receiver node acknowledges each packet received The procedure used for finding the peer node is explained in detail in the Section 9 2 2 1 3 3 158 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 9 6 Sequence diagram of Range measurement Peer Request adcast Pe
54. Status Register c le Counter 909 ex 3 5 53 imb wu aa Fl gt lets C3 si OS SS 2 IGS FP dl apii brief Main function of the promiscuous mode demo application s Flint main void 4 Initialize the MAC layer and its underlying layers like PAL TAL BMM if wpan init MAC SUCCESS ja Stay here we need a valid IEEE address Check kit documentation how to create an IEEE address and to store it into the EEPROM t pal alert Initialize LEDs pal led init f8 05 Oc 94 17 06 Oc 94 17 06 17 06 94 17 06 94 17 06 17 06 94 17 06 94 17 06 17 06 Oc 94 17 06 Oc 94 17 06 17 06 Oc 94 17 06 Oc 94 17 06 17 06 94 e9 94 15 dj 94 17 0 5 Output e In case the IEEE address of the node is stored in the internal EEPROM of the microcontroller please perform the following steps o Check whether a valid IEEE address different from OxFFFFFFFFFFFFFFFFand 0x0000000000000000 is stored in the internal EEPROM From the Debug menu go to Windows item and sub item Memory o Ifthe IEEE address is not set properly add the correct IEEE address to the first 8 octets of the EEPROM see section 8 3 1 e Start the application debug session by pressing F5 or clicking the Run button 8 3 4 Using IAR Embedded Workbench When using IAR Embedded Workbench directly by double clicking the correspondi
55. TYPE PAL TYPE CFLAGS DBOARD TYPE BOARD TYPE CFLAGS DHIGHEST STACK LAYER HIGHEST STACK LAYER e Update the used and or unused include directories in the Makefile The base example application Star Nobeacon did not use SIO support so this needs to be added to the target application in order to allow for the inclusion of sio handler h Add the following include path by changing Include directories for application INCLUDES I S APP DIR Inc Include directories for general includes INCLUDES I MAIN_DIR Include to Include directories for application INCLUDES I APP_DIR Inc Include directories for SIO support INCLUDES I PATH_SIO_SUPPORT Inc Include directories for general includes INCLUDES I MAIN_DIR Include Update the used and or unused object files to the list of OBJECTS in the Makefile Since the Promiscuous Mode Demo application only uses three MAC callback functions itself usr_mcps_data_ind usr_mlme_reset_conf and usr mlme set conf all other callbacks need to be added as stubs by adding the following lines For more information about MAC stub functions see Section 9 4 Change Objects that must be built in order to link OBJECTS TARGET_DIR main o TARGET DIR pal_uart o 5 TARGET DIR mac api o TARGET DIR usr purge c
56. The PIB attribute macMaxFrameRetries defines the maximum number of re transmissions if a requested ACK is not received The default value defined by the IEEE standard and used by the MAC implementation is three The IEEE standard allows increasing the number of retries up to seven e Maximum CSMA back offs The PIB attribute macMaxCSMABackoffs defines the number of back offs that are allowed before the channel is finally determined as busy and no transmission happens The MAC implementation uses the default value of four Increasing the value to five also increases the probability of successful transmission of a big number of nodes trying to access the channel at the same time 4 8 High data rate support The Atmel transceivers except for the AT86RF230 are capable of transmitting frames at higher data rates than the standard data rates within the given band The supported data rates are currently up to 2Mbit s These higher data rates are rates not defined within the IEEE standard see 4 For more information about high data rate support please refer to the data sheet for the corresponding transceiver AIMEL P 8412D AVR 5 12 AIMEL In order to enable higher data rates than the standard rates the following two items needs to be done 16 Enable the build switch HIGH DATA RATE SUPPORT within the corresponding Makefile or project file see Section 6 1 4 3 17 Set the PIB attribute phyCurrentPage to the corresponding value f
57. The function prototypes can be found in MAC Inc mac api h file If the build switch ENABLE TSTAMP is not used within an application the corresponding implementation in the application needs to be adjusted accordingly An example of this can be found mainc the directory Applications MAC_Examples Star_Nobeacon Src AdarList parameter MLME BEACON NOTIFY indication primitive The MLME BEACON NOTIFY indication primitive implemented the MAC callback function usr_mlme_beacon_notify_ind function has an updated type of the included parameter AddrList The callback function definition has been changed from void usr mlme beacon notify ind uint8 t BSN wpan pandescriptor t PANDescriptor uint8 t PendAddrSpec void AddrList uint8 t sduLength AMEL s 7 2 2 7 2 2 1 86 AIMEL amp uint8 t to void usr mlme beacon notify ind uint8 t sdu BSN wpan pandescriptor t PANDescriptor uint8 t uint8 t wants t uint8 t PendAddrSpec Add List sduLength sdu The function prototype can be found at MAC Inc mac api h TAL API Changes In order to reduce code size and complexity of the entire stack and to allow the development of TAL based applications the design and the API of the TAL have been simplified significantly The API changes within the TAL API can be classified into the following groups e Simplification of structure frame info t used wi
58. Tx frame buffer needed to be freed additionally by calling function buffer free 4 2 2 2 Frame reception buffer handling using TAL API The following section describes how buffers are used inside the stack during the procedure of the reception of a Frame using the TAL API AIMEL 31 AMEL Figure 4 8 Frame buffer handling during frame reception using TAL API 1 9AI9291 1 owed Atmel 2025 TAL Step 1 msg_type buffer_header msduHandle persistence_time only for indirect transmission indirect_in_transit only for indirect transmission time_stamp mpdu Free Area Frame length uploaded from TRX MPDU PHY frame uploaded from TRX FCS uploaded from TRX Lal uploaded from TRX ED value read from TRX register handle_received_frame_irq and process incoming_frame in tal_rx to buf_header array y Step 2 msg_type buffer_header msduHandle persistence_time only for indirect transmission indirect_in_transit only for indirect transmission time_stamp mpdu Free Area Frame length MPDU FCS Lal ED value tal rx frame cb to buf header array 8412D AVR 5 12 4 3 Configuration files 8412D AVR 5 12 Atmel AVR2025 Step 1 The proc
59. atmel com dyn products tools_card asp tool_id 4373 2 Dresden Elektronik Wireless data transmission 802 15 4 Website http www dresden elektronik de shop cat4 html language en 3 Atmel Wireless Support avr atmel com 4 IEEE Std 802 15 4 2006 Part 15 4 Wireless Medium Access Control MAC and Physical Layer PHY Specifications for Low Rate Wireless Personal Area Networks WPANs 5 AVR2025 IEEE 802 15 4 MAC Reference Manual MAC_readme htm located in the AVR2025 top directory 6 RZ600 Evaluation Kit Website http www atmel com dyn products tools_card asp tool_id 4702 7 ATAVRXPLAIN Evaluation and Demonstration Kit Website http www atmel com dyn products tools_card asp tool_id 4506 amp source xplain_ page 8 ATZB ZigBit Module Website http www atmel com products zigbee zigbit_modules asp family_id 676 200 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 15 User guide revision history Please note that the referring page numbers in this section are referring to this document The referring revisions in this section are referring to the document revision 15 1 Rev 2025M MCU Wireless 06 12 Released with AVR2025 MAC Version 2 8 0 1 AT86RF233 TAL support and demonstrated with TAL and MAC Examples 2 ATMEGARFR2 TAL support and demonstrated with TAL and MAC Examples 3 Platform support added for ATmega1281_REB 4 1 5 600 and ATZB 24 MN2 MAC examples and TAL examples added for ATZB 24 MN2 Pal nvm multi wri
60. baud rates is depending on the current system clock speed see build switch F_CPU and the error in the used Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 oscillator frequency As a rule of thumb the error of the oscillator frequency shall not be more than 2 For example in case the Atmel ATmega1281 is used with F CPU 8MHz the error for 38400 bps is 0 2 which is perfectly fine but for 115200 bps the error is 3 5 which may lead to improper functioning of the UART For more information about the UART oscillator frequency error please check the data sheet of the utilized MCU type 6 1 3 11 VENDOR_BOARDTYPES This build switch allows for the support of customer specific hardware boards which are directly supported within this software package without the need to change any single file If this switch is set in the application the known boards defined in the corresponding files pal boaratypes h are ignored Instead a file vendor boaratypes h searched in the current include path If such a file is found the boards defined in vendor boardtypes h are used during the build process For example see file PAL AVR ATMEGA1281 Boards pal_boardtypes h where the following code is included if defined VENDOR BOARDTYPES amp amp VENDOR BOARDTYPES 0 include vendor boardtypes h else Use standard board types as defined below In order to enable the utilization for customer specific
61. beacon enabled network by first attempting to synchronize with the coordinator to be able to receive each beacon frame Once it has successfully synchronized with the coordinator the device associates with the coordinator The connected devices wake up whenever a new beacon frame is expected extract the received payload of each beacon frame from its coordinator This received payload is printed on the terminal and sent back to the coordinator by means of a direct data frame transmission to the coordinator After successful beacon reception and data transmission the devices enter sleep mode until the next beacon is expected The coordinator indicates each received data frame from each device on its terminal Whenever a device looses synchronization with its parent it initiates a new synchronization attempt Also in this application the coordinator periodically tries to transmit broadcast data frames to all children nodes in its network When ever broadcast frames are pending at the coordinator it sets the Frame Pending Bit of the next beacon frame The connected devices wake up whenever a new beacon frame is expected Once it receives a beacon frame that has the Frame Pending Bit set it remains awake until a broadcast data frame is received After successful reception of the expected broadcast data frame the devices enter sleep mode until the next beacon is expected Once the device is associated when it receives a beacon frame that has
62. board types the compile switch must be set in the corresponding project files If this Usage in Makefiles CFLAGS DVENDOR BOARDTYPES or CFLAGS DVENDOR BOARDTYPES 1 enables the utilization of customer specific board types Usage in IAR ewp files VENDOR_BOARDTYPES or VENDOR_BOARDTYPES 1 enables the utilization of customer specific board types If this build switch is omitted or set to zero in the corresponding project files the board definitions from the current file pal_boardtypes h are used as usual AMEL AIMEL Figure 6 3 Inclusion of vendor_boardtypes h amp pal_boardtypes h vendor_boardtypes h board types vendor n For more information about how to use this switch and how to enable customer specific boards please refer to Section 11 3 1 1 6 1 3 12 VENDOR STACK CONFIG This advanced build switch can be used by customer that want to add another stack layer on top of the MAC layer which shall not access the MAC layer via the MAC API but rather via the queuing mechanism similar to other network layers such as RFACE By this the stack layer can utilize the provided buffers and queues In order to enable a customer specific stack on top of the MAC the build switch VENDOR STACK CONFIG needs to be added to the project files In this case a file called vendor stack config h is included while parsing the common stack configurat
63. channel in file main c and re built the application 9 2 3 1 Secure Hemote Control The STB example Secure Remote Control is an application demonstrating application security for a remote control acting as a light switch It deploys a nonbeacon enabled network using ZigBee CCM security This example application uses both STB and TAL API as interface to the stack The STB is used to secure and unsecure application data and the TAL is used to transmit or receive secured or unsecured frames The application and all required build files are located in directory Applications STB Examples Secure Remote Control The source code of the application can be found in the subdirectory Src This application requires e Up to three LEDs on the board in order to indicate the proper working status A sniffer is suggested in order to check frame transmission between the nodes e One button on the board in order to determine whether the node starts in secure or unsecure mode and in order to initiate an action by the remote control e A serial connection for typing messages and displaying the received data from the other device Depending on the available Serial I O interface for each board this can be either UART or USB In order to start the application and to see the output of the application please start a terminal application on your host system and press any key for the application to begin The application involves exactly two nodes Both nodes o
64. channels 0 3 For a MAC example using a high data rate of 2Mbit s please refer to Section 9 2 1 4 5o Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 5 MAC power management The MAC stack provide built in power management that allows to put the transceiver into power save state as often as possible in order to save as much energy as possible This allows for example End Devices which are usually battery powered to use a sleeping state of the transceiver as default state The entire power management is inherent in the MAC itself and works without any required interaction from the application On the other hand there exist means for the application to control the power management scheme in general as desired 5 1 Understanding MAC power management 8412D AVR 5 12 The following section is only valid for MAC applications or applications on higher layers but not for TAL applications For TAL applications please refer to Section 5 4 Once a node running an application on top of the MAC stack has finished its initialization procedure the MAC layer decides whether the node stays awake or enters SLEEP state This is controlled by the MAC PIB attribute macRxOnWhenldle Whenever this PIB attribute is set to True the MAC keeps the radio always in a state where the default state of the receiver is on that is the transceiver is able to receive incoming frames whenever there is nothing else to do for the stack Since this is a non s
65. com Tel 852 2245 6100 Fax 49 89 3194621 Fax 81 3523 7581 Fax 852 2722 1369 2012 Atmel Corporation All rights reserved Atmel Atmel logo and combinations thereof AVR AVR Studio XMEGA STK SAM BA QTouch ZigBit and others are registered trademarks of Atmel Corporation or its subsidiaries Windows and others are registered trademarks or trademarks of Microsoft Corporation in U S and or other countries ARM is a registered trademark of ARM Ltd Other terms and product names may be trademarks of others Disclaimer The information in this document is provided in connection with Atmel products No license express or implied by estoppel or otherwise to any intellectual property right is granted by this document or in connection with the sale of Atmel products EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTY OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE OR NON INFRINGEMENT IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT INDIRECT CONSEQUENTIAL PUNITIVE SPECIAL OR INCIDENTAL DAMAGES INCLUDING WITHOUT LIMITATION DAMAGES FOR LOSS AND PROFITS BUSINESS INTERRUPTION OR LOSS OF INFORMATION ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT EVEN IF ATMEL HAS BEEN ADVISED OF THE POS
66. common to all ATxmega128A1 MCU platforms The entire code that is dedicated to a specific hardware platform based on a specific MCU and on a specific board with specific settings is located in the board directory for this particular hardware configuration All supported platforms that is boards with specific settings can be found in directory PALIXMEGA ATXMEGA 128A 1 Boards The selectable clock speed will be explained for the board REB 4 1 STK600 which implements the platform abstraction for a Radio Extender Board version 4 1 with AMEL as 8412D AVR 5 12 11 6 1 2 1 MCU clock setting 11 6 1 3 1 SPI speed selection 11 6 1 3 2 Small blocking delays 234 Atmel AVR2025 AIMEL SEE Atmel AT86RF231 with Antenna Diversity placed on an Atmel STK600 with 128 1 The explanations given for this board apply for each board configuration and can easily be adapted to other boards as well The directory for the specific board implementation for REB_4_1_STK600 contains three files e pal_board c pal irq c e pal config h Whenever a configuration parameter such as system clock speed is changed only these files shall be adapted All other files generally remain unchanged In the case of the selectable system clock speed only pa board c and pal config h are customized Depending on the selected system clock the MCU clock needs to be set As described for Atmel ATxmega128A1 based platforms c
67. data frames The remaining callbacks e usr mcps purge conf e usr mlme beacon notify ind e usr mlme disassociate conf e usr mlme disassociate ind e usr mlme get conf e usr mlme orphan ind e usr mlme poll conf AMEL 5 AIMEL pu M e usr mlme rx enable conf e usr mlme sync loss ind are not used by the application since this example does not deal with this functionality In order to avoid implementing empty stubs in the application the way of using the delivered stub functions in the files usr c shall be used This is done by adding these stub files to the GCC Makefiles or IAR project files In the corresponding GCC Makefile Applications MAC_Examples Star_Nobeacon any platform GCC Makefile the following lines can be found in order to add the required object files to the link process Objects that must be built in order to link OBJECTS TARGET_DIR main o TARGET DIR pal_uart o TARGET DIR mac_api o TARGET_DIR usr_mcps_purge_conf o 5 TARGET_DIR usr_mlme_beacon_notify_ind o S TARGET DIR usr mlme disassociate conf o S TARGET DIR usr mlme disassociate ind o TARGET DIR usr mlme get conf o TARGET DIR usr mlme orphan ind o 5 TARGET DIR usr mlme poll conf o DIR usr mlme rx enable conf o DIR usr mlme sync loss ind o In the corre
68. do require more advance security features for example securing a complete frame with a specific key Such functionality is implemented in the Security Toolbox To incorporate the Security Toolbox features for system requiring the STB layer on top of an SAL implementation see Section 4 6 during the build process the switch STB ON SAL needs to be set Usage in Makefiles CFLAGS DSTB ON SAL enables the Security Toolbox features Usage in IAR ewp files STB ON SAL enables the Security Toolbox features 6 1 5 3 STB ARMCRYPTO The ARM hardware crypto engine residing in the Atmel SAM7XC is very powerful and thus does not require the implementation of an additional SAL layer for such systems Therefore the utilization of security for SAM7XC systems allows for the easy handling of security features by only relying on a special STB implementation called STB_ARMCRYPTO To incorporate the Security Toolbox features using the ARM crypto engine during the build process the switch STB_ARMCRYPTO needs to be set see Section 4 6 Usage in IAR ewp files AMEL rs 8412D AVR 5 12 AIMEL STB_ARMCRYPTO enables the Security Toolbox features for SAM7XC systems 6 1 6 Test and debug switches NOTE 6 2 Build configurations 6 1 6 1 DEBUG This build switch enables further debug functionality and additional sanity checks within the software package but also increased code size or changes run time behavior since the optim
69. e Start Atmel AVR Studio 4 e Display the Open File dialog Figure 8 9 AVR Studio Open File dialog AYR Studio 10 x i File Project Build view Tools Debug Help Open file led plugin 5 500 Address Value Bits E Find in Files Lg Breskpoints and Tracepoints E Build Message CAP NUM A e Select the proper elf file 10 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 8 10 AVR Studio 4 select elf file Suchen in Dat sf Ed Zuletzt verwendete D Desktop Sensor Network elF Sensor Network hex gt Eigene Dateien e sschneid auf DREDT1540 erm Dateiname Sensor Network elf ung Dateityp Object Files hex d90 a90 190 obj cof v Abbrechen Open as Auto e In case a window pops up asking whether to save changes to a specific project press Yes and select the proper place to store the existing project file e The Select device and debug platform window opens Select the proper Debug platform for example Atmel AVR JTAGICE mkll and Device for example Atmel ATmega1281 Make sure that Open platform options next time debug mode is entered is selected Figure 8 11 Atmel AVR Studio Select debug platform and device window Select device and debug platform E _ Select debug platform and device Debug platform Device AVR Dragon
70. fore most boards for the Atmel AVR and Atmel XMEGA MCU family Since the Atmel AT91SAM7X256 provides on a limited number of external interrupts this approach is not followed in this example The AT86RF231 is only used with one transceiver interrupt enabled The Timestamp interrupt based on DIG2 pin from the transceiver is not used Timestamping is done similar for AT86RF230B systems Because of this limitation for this particular board no changes within file pal_irq c during the porting from the base platform to the target platform are to be done except the board name change explained in Section 11 3 2 5 11 3 2 7 Step 7 File pal board c This source file contains board specific functions to initialize and handle peripherals such as LEDs buttons GPIO to the transceiver The following items within this file need to be updated according to the target board s needs or at least checked for correctness e Function pal generate rand o Each board needs a random seed value for random seed for the CSMA CA algorithm generation of a random IEEE address for demo applications in case no valid IEEE address is provided for this board for example by means of an external EEPROM o While the AT86RF230B does not provide a random number generator and thus this random seed needs to be generated for the corresponding board by different means the AT86RF231 provides such a feature that is automatically enabled within
71. frame for each associated device into its Indirect Data Queue If the coordinator receives a data request frame from a particular device it transmits the pending data frame to the device Device after receiving the data from the Coordinator sends back the data to the Coordinator itself by direct data transmission While the device is idle when the timer is running the transceiver enters sleep in order to save as much power as possible e The current channel is coded within the application In order to run the application on another channel change the default channel in main c and re built the application e Currently only two devices are allowed to associate to the PAN Coordinator This can be easily extended by increasing the define MAX NUMBER OF DEVICES Beacon Application The basic MAC Example Beacon Application deploys a beacon enabled network consisting of PAN Coordinator and up to 100 associated Devices The application shows how basic MAC features can be utilized within an application using beacon enabled devices such as announcement of pending broadcast data at the coordinator within beacon frames that is whenever the coordinator has pending broadcast data to be delivered in a beacon enabled network it sets the Frame Pending Bit in the transmitted beacon frame and synchronization with the coordinator and utilization of beacon payload by the coordinator Also the Coordinator in this example wants to send data to the Device u
72. frames from other PAN Coordinators and being able to initiate the transmission of PAN Id Conflict Notification Command frames from its parents if required The following components are required as well e MAC SYNC LOSS INDICATION e Either ASSOCIATION REQUEST CONFIRM or SYNC REQUEST 4 5 Support of AVR platforms larger than 128Kbyte program memory 4 5 1 General NOTE 4 5 2 Stack implementation 4 Atmel AVR2025 In order to support applications larger than 128KByte program memory that are using function pointers such as callbacks in the stack special implementation support both by the stack and the application is required Function pointers are usually 16 bit pointers which can address only 64Kbyte of program memory Functions located in the memory between 64Kbyte and 128Kbyte can still be addressed by 16 bit function pointers since all addresses start on an even address in program memory which increases the addressable space of a 16 bit pointer to 127Kbyte So no special care is required for code up to 128Kbyte In case function pointers shall be used for builds which are larger than 128Kbyte when using for instance the Atmel ATxmega256A3 MCU the function pointers need to be declared as large pointers that is pointers which are 24 bit The Section 4 5 2 describes the current implementation used for IAR compilers Currently AVR GCC does not provide a clean method to support such constructs Therefore program c
73. function e sio_getchar_nowait read one character via SIO without blocking The helper functions in return make use of the PAL related SIO functions such as pal_sio_tx and pal_sio_rx This allows for easy implementation of SIO functionality in the application The SIO handler is located in directory Applications Helper Files SIO Support The implementation is located in file sio handler c in the Src directory whereas the corresponding function declaration is located in file sio handler h in the Inc directory For the IAR compiler the write c located in the Support needs to be added as well In order to use these helper functions the application needs to do the following things e Include the header file in its source files include sio handler h e Extend the include search path for GCC Makefiles for example PATH SIO SUPPORT 5 DIR Applications Helper Files SIO Support Include directories for SIO support INCLUDES I PATH_SIO_SUPPORT Inc e Extend the include search path for IAR project files for example lt name gt newCClncludePaths lt name gt lt state gt SPROJ_DIRS Helper_Files SIO_Support Inc lt state gt Add file sio handler c to the list of source and object files in GCC Makefiles for example TARGET_DIR sio_handler o TARGET_DIR sio_handler o PATH SIO SUPPORT Sre sio_handler c CC c CFLAGS INCLUDES o lt Add file sio_handler
74. if the peer request received with config mode bit true it checks the ED level and if it is above defined threshold it will connect with the transmitter device This ED threshold is defined to allow connecting with the devices which are approximately below one meter range In configuration mode Transmitter node works with lowest TX power and the Reflector sends the received packets to the application layer if it is above ED threshold After successful Peer Search devices shall come to the normal mode which means Transmitter node work with default TX power and the receiver node shall not do any filtering based on the ED threshold value 8412D AVR 5 12 Atmel AVR2025 Figure 9 200 Debug prints for Configuration mode followed by PER Measuremnt Button press while poweron CONFIGURATION MODE Character received PER Measurement mode ENTER to Abort Search for Peer Device and to start single node operation mode Search for Peer Device Initiated Figure 9 211 Debug prints for Configuration mode followed by Range Measuremnt Button press while poweron CONFIGURATION_MODE Key press detected Range Measurement mode Search for Peer Device 1 111 1 9 2 2 1 3 5 Application Contents Using the PAL and TAL package for the corresponding controller and radio transceiver the entire implementation of the Performance Test Application requires an additional set of following fi
75. information JTAG Daisy chain settings Memories 6 Target device is not part of JTAG daisy chain Foses Daisy chain Devices before 8 Instruction bits b Lock bits Devices after ction bits after Reading device 10 e Select the Fuses tab Within this tab make sure that the EESAVE fuse is selected This preserves the EEPROM through the chip erase cycle 14 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 8 17 AVR Studio 5 AVR Programming dialog with Fuses tab Tool Device Interface Device ID Target Voltage mkII ATmegal281 JTAG Apply Joxte 0x97 0 04 Read 1 3 3 Read Interface settings Fuse Name Value Tool information y BODLEVEL DISABLED Device information ocven 0 9 JTAGEN Memories SPIEN TE H WDTON Lock bits y 800757 4096W_FO00 cxorvs 9 r SUT_CKSEL 5 6 7 Fuse Register Value EXTENDED HIGH 0x91 Low OxE2 IV Auto read v Verify after programming Copy to clipboard Read fuses OK e Select the Memories tab Within this tab select the Flash section selection the proper Intel Hex File Afterwards press button Program Figure 8 18 AVR Studio 5 AVR Programming dialog with Memories tab JTAGICE mkII 070000004DF6 AVR Programming 21 Tool Device Interface Device ID Target Voltage
76. infos v Apply 0x20000000 O xCDCDCDCD O xCDCDCDCD xCDCDCDCD OxCDCDCDCD 5 0x20000010 OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD OxCDCDCDCD 0x20000020 OxCDCDCDCD O xCDCDCDCD 0 20000030 OxCDCDCDCD OxcDCDCDCD OxCDCDCDCD 0x20000040 xCDCDCDCD xCDCDCDCD fnvonnnnnsn Avycnenencn Avycnencncn Aycnencencn Ayenenencn lt Flash NandFlash SRAM Download Upload File Send File Name Send File Receive File Name gt Receive File Address 0 400000 Size For Receive File 0 1000 byte s Compare sent file with memory 3 4 Scripts 1 Erase All Flash Boot from Flash Enable Flash access loadEnable Security Bit GPN vMU fy Erase All Flash SAM BA v2 10 1 96 Board at81sam3s4 ek Step 1 Select the Erase All Flash before option Step 2 Select Execute in order to erase the entire flash contents Step 3 Browse for the executable file which is to be flashed Step 4 Select the send file in order to flash the executable file 130 Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 Figure 8 50 Atmel SAM BA boot from flash SAM BA 2 10 at91sam3s4 ek DAR File Script File Link Help at91sam3s4 Memory Display Heu rM ox20000000 Display format Applet traces DBGU Size in byte s 0x100 C ascii
77. instant by using an external sniffer tool Once the limit is reached 4294967295 then the counter resets itself to start again from 0 00000000 9 2 2 1 3 1 2 Debug message support for Range measurement Debug prints can be viewed if the node is connected to a UART terminal The node on which the key was pressed will display a print as shown in Figure 9 7 This node initiates the transmission and calls itself the TX node For details on Peer Search refer section Figure 9 7 Initializing Range measurement transmitter TX Key press detected Range Measurement mode Search for Peer Device Initiated Peer device found Starting TK in Range Measurement mode The node connected to the TX node will display a print as shown in Figure 9 8 This node receives the packets and calls itself the RX node Figure 9 8 Initializing Range measurement receiver RX Frames Rec on air Range Measurement Peer device found On input of any character in the UART Terminal it prints the statistics of the messages received and messages sent as shown in Figure 9 9 Two way communications can be enabled if the button is pressed on both the nodes Figure 9 9 Statistics of Range measurement No of Frames RK 50 No of Frames TK 52 No of Frames RK 54 No of Frames TK 56 No of Frames RK 58 No of Frames 59 No of Frames RK 61 9 2 2 1 3 2 PER Measurement mode The primary intent of this application is PER
78. internal EEPROM Select menu View item Memory o If the IEEE address is not set properly add the correct IEEE to the first eight octets of the EEPROM see Section 8 3 1 e Start the application by pressing F5 or clicking the Run button 8 3 8 Using AVR Studio 5 When the application has been built in Atmel AVR Studio 5 see Section 8 2 3 the application can be started following the steps described below 8 3 3 1 Starting the Release Build The release build can simply be started as follows e Open AVR Studio 5 by double clicking on the corresponding AVR Studio 5 solution file avrsin file e Select Release configuration from the Configuration Manager Figure 8 14 AVR Studio 5 Build gt Configuration Manager Release Configuration Manager 2 xj Active solution configuration Active solution platForm Project contexts check the project configurations to build or deploy Project Configuration Promiscuous Mode Demo Close e Rebuild the application in AVR Studio 5 e Open the AVR Programming Dialog from the Tools menu bar AIMEL 103 amp 8412D AVR 5 12 AIMEL Ey Figure 8 15 AVR Studio 5 Tools gt AVR Programming Promiscuous Mode Demo AVR Studio ioj x File Edit View VAssistX Project Build Debug Tools Window dd 5 32 2 AVR Tools Firmware Upgrade ie 3 1 Aaron s a gt
79. interrupt is handled in function handle tx end irq located in file TAL tal type Src tal tx c In case timestamping is enabled the time stamp parameter is written into the proper location of the frame into f structure of the frame buffer This happens in the context of the Interrupt Service Routine Afterwards function tx done handling located in TAL tal type Src tal tx c is called in the main execution context Here the timestamp is updated and the corresponding callback function tal tx frame done cb inside the MCL is called Step 5 Function tal tx frame done cb residing in file MAC Src mac process tal tx frame status c calls a number of other functions inside the MCL which in the case of a processed Data frame finally will end up in function mac gen data conf in file mac data c AIMEL 25 Ey 2 26 Atmel AVR2025 AIMEL Here the structure of type mcps_data_conf_tis overlaid over the actual buffer body amp mcps data conf t mdc mcps data conf t BMM BUFFER POINTER buf For more information about the data conf t structure see file MAC Inc mac msg types h The data conf t structure is filled accordingly and the entire buffer is then queued as an MCPS DATA CONFIRM message into the MAC NHLE Queue Step 6 Once the MCPS DATA message has been de queued and the dispatcher has called the corresponding function mcps data conf see file
80. is provided in the software package see deRFusbXXEXxX inf inf in directory PAL Board_Utils SAM3S_USB_Stick_Driver Figure 10 30 SAM3S USB sticks Atmel AT91SAM3S4B connection details AMEL as 8412D AVR 5 12 AMEL 10 4 11 ZigBit Modules on Top of Meshbean2 Board The ZigBit Modules are supported on top of a MeshBean2 board based on ATmega1281 10 4 12 Peripherals 24 Atmel AVR2025 See PAL AVR ATMEGA1281 Boards ATZB_24_MN2 for the ZigBit 2 4 GHz support based on AT86RF230B Images need to be flashed using JTAG ICE and the JTAG connector An installation programm for the USB driver providing a virtual COM port for the MeshBean2 board is provided in the software package see CP210x_VCP_Win2K_XP_S2K3 exe in directory PAL Board_Utils MeshBean2 For more information about the ATZB ZigBit Modules refer to 8 The following picture depicts an ATZB ZlgBit Module on top of the MeshBean2 board conntected to a JTAG_ICE Figure 10 31 ATZB ZlgBit Module on Top of MeshBean2 Board with JTAG ICE and USB li pwes won Each board or combination of boards provides a variety of peripherals that determine which application can be executed to which extent of this board This section provides an overview about the differences for the various platforms for the following peripherals e Buttons e LEDs e SIO support UART USB Table 10 2 Peripherals supported by platform type Buttons SIO support Plain
81. it is not reasonable for such small delays to call the function pal timer delay these delays are implemented as macros in file config h PAL WAIT 1 US and PAL WAIT 500 NS These macros are based on nop 8412D AVR 5 12 11 6 1 3 3 UART baud rate 8412D AVR 5 12 Atmel AVR2025 operations which depend on the MCU clock This is implemented in file pa config h as well The UART baud rate is selected by properly setting the USART baud rate register which in return is depending on the MCU clock speed This is implemented in file pal_uart h in macro UART_BAUD This macro does not have to be updated if the clock speed changes 11 6 1 4 Selecting the proper system clock speed The desired clock speed can be selected at compile time by using the build switch F_CPU It is not intended to change the clock during operation since this would add additional code size The currently supported clock speed is 32MHz 16MHZ 8MHz or 4MHz The standard frequency of the system clock is 16 2 If the build switch F_CPU is not set during the build process the clock speed of 16 2 will be applied In case other clock speed shall be selected the build switch needs to be set accordingly For the GCC tool chain example Makefiles for changing the system clock are provided for the MAC application Star_Nobeacon for the above described hardware platform Please check directory MAC_v_x_y_zlApplications MAC_Examples Star_Nobeacon AT8
82. layer of the stack the application is actually based on that is which API it is using the build switch HIGHEST STACK LAYER needs to be set properly Depending on this switch only the required resources from the stack are used for the entire application For further information about the usage of HIGHEST STACK LAYER please see Section 6 1 1 1 HIGHEST STACK LAYER The following picture shows which layers of the stack are available for the application depending on the build switch HIGHEST STACK LAYER Obviously a trade off needs to be found between required functionality on one hand and the footprint on the other hand Figure 2 2 Stack usage User defined Stack Layer HIGHEST HIG HEST_ HIGHEST_ HIGHEST_ HIGHEST_ STACK_LAYER STACK LAYER STACK LAYER STACK LAYER STACK LAYER PAL TAL nas 2 2 Other stack components 2 2 4 Resource management The Resource Management provides access to resources to the stack or the application These resources are 1 Buffer Management large and small buffers provides services for dynamically allocating and freeing memory buffers 2 Queue Management provides services for creating and maintaining the queues The following queues are used by the software 3 Queue used by MAC Core Layer a NHLE MAC Queue b TAL MAC Queue c Indirect Data Queue d Broadcast Queue 4 Queue used by TAL a TAL Incoming Frame Queue 6 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025
83. means to change the standard MAC power management scheme the MAC primitive MLME_RX_ENABLE request can be used to change the behavior more temporarily The receiver be enabled by calling function wpan mlme rx enable req with the 2 parameter RxOnDuration larger than zero Switch receiver on for 10000 symbols wpan_mlme_rx_enable_req false 0 10000 This wakes up the transceiver independent from the current value of the PIB attribute macRxOnWhenldle if required and switches the receiver on After the timer with the specified time RxOnDuration symbols expires the receiver is disabled automatically if the current value of macRxOnWhenldle is false or remains in receive mode if macRxOnWhenldle is true 54 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 The receiver can be disabled explicitly by calling woan_mlme_rx_enable_req with the 8 parameter RxOnDuration equal to zero Disable receiver now wpan_mlme_rx_enable_req false 0 0 This disables the receiver if the current value of the PIB attribute macRxOnWhenldle is false and puts the transceiver to SLEEP mode For more information about function wpan mlme rx enable req see files and mac rx enable c in directory MAC Src For more information about the interaction of MLME ENABLE macRxOnWhenldle see file mac misc c in directory MAC Src and check the following function mac sleep trans
84. never acknowledge any received frame etc Instead the node will be able receive any proper IEEE 802 15 4 frame on its channel within range and present it to the application The application can reside on top of the MAC layer using MAC API callback function usr_mcps_data_ind or on top of the TAL layer using TAL callbacks Switching promiscuous mode on or off is controlled by the standard MAC PIB macPromiscuousMode see IEEE 802 15 4 2006 Section 7 5 6 5 Promiscuous Mode The payload contained in the usr mcps data ind callback function is the MAC Header MHR of the received frame concatenated with the original payload of the received frame An example application presenting all received frames on a serial terminal can be found in the directory Applications MAC Examples Promiscuous Mode Demo see Section 9 2 1 4 Promiscuous mode can be switched on or off by setting or resetting the PIB attribute macPromiscuousMode If the radio is awake and in receive mode on the current channel the node will present all received frames to the upper layer In order to work properly the receiver needs to be enabled This can be done for example by setting MAC PIB attribute macRxOnWhenldle to 1 before turning promiscuous mode on Generally the transceiver state can be controlled similar to normal operation see Chapter 5 Once the PIB attribute macPromiscuousMode is reset the node switches back to normal operation It will be in the same state as b
85. received frame should be adapted to the end user s requirements 9 2 1 5 Star Nobeacon The application Star Nobeacon provides a simple start network application based on IEEE 802 15 4 2006 The application uses two nodes a PAN Coordinator 1 and an End Device 2 The firmware is implemented as such that a node can either act as a PAN Coordinator or an End Device This application works very similar to the MAC Example Nobeacon Application see Section 9 2 1 1 but the same source code is used for both types of devices The type of device is detected by the firmware during run time This example application uses MAC API as interface to the stack The application and all required build files are located directory Applications MAC_Examples Star_Nobeacon The source code of the application can be found in the subdirectory Src AIMEL tar 9 2 1 5 2 Requirements AIMEL BRA Xo The application requires up to three LEDs on the board in order to indicate the proper working status A sniffer is suggested in order to check frame transmission between the nodes 9 2 1 5 3 Implementation The application works as described subsequently Node one Switch on node one LED 0 indicates that the node has started properly Flashing of LED 1 indicates that the node is scanning its environment Scanning is done three times on each available channel depending on the radio type If no other network with the pre defined channel and
86. scanning energy detect active passive or and orphan scanning e Starting of networks e Support of transmitting or receiving indirect data including polling of data e Purging of indirect data e Enabling of the receiver e Synchronization in beacon enabled networks e Presentation of loss of synchronization e Handling of orphan notifications e Handling of beacon notifications Each feature can be used independently from each other It is also possible to deselect all of the above features which leads to a minimum application in terms of resource utilization In this case only the following basic MAC features are available s Atmel AVR2025 8412D AVR 5 12 6 2 2 2 1 8412D AVR 5 12 Atmel AVR2025 e Direct data transmission and reception e Initiation of a MAC reset e Reading and writing of PIB attributes An example application implementing the proper utilization of this feature can be found in Applications MAC Examples Basic Sensor Network In this example only RX ENBALE is used in addition to the standard features For more information about this example application please refer to Section 9 2 1 1 6 2 2 2 File mac user build config h If the switch MAC USER BUILD CONFIG is activated the C pre processor looks for a file mac user build config h in the current include path usually in the Inc directory of the application See file Include mac build config h ifdef MAC USER BUILD CONFIG
87. significant improvements have been achieved by introducing design changes throughout the PAL TAL and MCL layer and by introducing the Tiny_TAL layer Although these design changes do not significantly change the MAC API both the TAL API and partially the PAL API have been changed This is based on the fact that large portions of the code formerly residing inside the TAL layer have been shifted up to the MCL layer This leads to an overall code size reduction as well as to the much simpler TAL API which can be used more easily for simple applications PAL API was changed mostly for handling transceiver related interrupts with the focus of reducing the overall code size and excluding functionality not used per default In order to better understand the impact of these design improvements on the end user applications or stack layers the following sections will describe the most important changes in detail The API changes within the MAC API can be classified into the following groups e Handling of Timestamp parameter in MCPS DATA primitives e Type of AddrList parameter in MLME BEACON NOTIFY indication primitive Handling of timestamp parameter MCPS DATA primitives According to 4 both the MCPS DATA confirm and the MCPS DATA indication primitive contain a Timestamp parameter This is implemented in the MAC callback functions usr_mcps_data_conf usr_mcps_data_ind In many cases the timestamping functionality is not
88. t timeout type FUNC PTR timer cb void param cb 4 5 2 8 Usage of function pointers as function parameters These functions containing function pointers need to be called with the corresponding FUNC type Examples are e File mac data c in directory MAC Src Start the indirect data persistence timer now Status pal timer start T Data Persistence persistence int us IMEOUT RELATIVE FUNC t persistence cb NULL e File tal init c in directory TAL AT86RF231 Src Configure interrupt handling Install a handler for the transceiver interrupt pal trx init TRX MAIN IRQ HDLR IDX FUNC PTR trx handler cb AIMEL 47 amp 8412D AVR 5 12 4 5 3 Application support NOTE AIMEL amp Applications that are built for Atmel AVR MCUs with more than 128Kbyte flash and thus potentially need large function pointers shall use the same way of calling these specific PAL API functions containing functions pointers Therefore all applications are updated within this software package as described in Section 4 5 2 3 As an example see file main c of the MAC example application Star_Nobeacon in directory Applications MAC_Examples Star_Nobeacon Src pal_timer_start TIMER_TX_DATA DATA_TX_PERIOD IMEOUT_RELATIVE FUNC_PTR app_timer_cb NULL It is strongly recommended to follow this scheme in all componen
89. the Network layer which requires the cooperation of the transceiver is received This could be the request to transmit a new frame wpan mocps data req the request to set a PIB attribute that is mirrored in transceiver registers the request to poll for pending data at the node s parent etc Once such request has been received at the MAC API the MAC performs a check whether the radio is currently in SLEEP state and wakes up the transceiver if required Afterwards the MAC can us the transceiver to perform whichever action is required After the ongoing transaction is finished the MAC will put the transceiver back to SLEEP if allowed AMEL s AIMEL EEE This complete MAC controlled power management implies that a node being in idle periods in SLEEP is not able to receive any frame during these time periods that is a PAN Coordinator would not be able to send a direct frame to its sleeping child being and End Device This can be reproduced using the provided MAC example applications Nobeacon Application see Section 9 2 1 1 and Star Nobeacon see Section 9 2 1 5 In both of these applications all directed traffic goes from the End Device to the PAN Coordinator If these applications where changed so that the PAN Coordinator sent traffic to the End Device the End Device would not accept these frames since it is in SLEEP most of the time Of course there is variety of means defined within IEEE 802 15 4 to allow a reasonable co
90. the TAL for AT86RF231 o This implies the mechanism used for the base platform to generate a random seed by utilizing the ADC of the MCU is not required for the target platform o Therefore function pal_generate_rand_seed can be removed entirely for this platform e Functions o handler 210 Atmel AVR2025 8412D AVR 5 12 adc get data adc is channel irq status set adc initialize These functions are helper functions for the obsolete function pal generate rand seed and can be removed completely as well e Function timer init non generic e Function trx interface init While the board of the base platform connects the transceiver to the MCU via SPIO the target platform uses SPI1 The pins of the Atmel AT91SAM7X256 used for SPI1 are still controlled via PIO A but used as Peripheral A For more information about the used pins for the SPI see Section 11 3 2 8 In order to use SPI change Atmel AVR2025 brief Initializes the transceiver interface This function initializes the transceiver interfac This board uses SPIO void trx_interface_init void Peripheral A SCK SCK PIN Ef AT91C BASE gt ASR MISO MOSI AT91C BASE gt PDR MISO MOSI AT91C BASE gt ASR INTERRUP AT91C BASE gt PDR
91. the UART interface the UART is set to 9600 8 1 9 1 Walking through a basic application This section describes one basic example application provided with this MAC release see Section 9 2 1 1 more thoroughly to allow better understanding of all other examples The example serves as a first introduction on how to control the MAC API and how to start an 802 15 4 compliant network It can be used by a developer as a starting point for further designs The example implements a network with star topology There are two types of nodes in the network PAN Coordinator and device A PAN Coordinator can be understood as the central hub of a network It handles association requests from devices and assigns a short address if appropriate In this example the PAN Coordinator does not initiate any data transmissions it receives data from the associated devices The usr_mcps_data_ind callback function is provided only as stub and can be extended by user The Devices scan all channels for the PAN Coordinator If the Coordinator with the default PAN ID is located on the default channel that is channel 20 the Device will initiate the association procedure If the association is also successful the Device periodically that is every two seconds sends out a data packet to the Coordinator The data packets contain a random payload As already mentioned earlier this example can be extended by the user The following sections describe the applic
92. the devices The application works as described subsequently e Each remote will transmit its current position and will update it on the LCD as well If the other remote is used its position is also updated on the LCD Since a remote updates its own position as well as the other remotes position on the LCD the following effects can be observed on the LCD 1 If only one remote is used the LCD will update its position 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 2 If two remotes are used and if one is kept undisturbed and the other is used both the remotes will update the position of the active remote on the LCD 3 If both the remotes are positioned in the same direction the logo will move twice as fast in that direction than it normally would 4 But if the remotes are positioned in opposing direction like one positioned left and the other towards the right these two actions will cancel eachother The logo will not move in either of directions but will remain stationary AIMEL AIMEL Figure 9 222 Accelerometer Display Application 5 IAAL 12 Atmel AVR2025 8412D AVR 5 12 9 2 2 2 4 Limitations 9 2 3 STB examples 9 2 3 1 1 Introduction 9 2 3 1 2 Requirements 9 2 3 1 3 Implementation 8412D AVR 5 12 Atmel AVR2025 The current channel is coded within the application In order to run the application on another channel change the default
93. to derive the selected system clock The event system is always selected as source for the hardware timer used by software Since the hardware timer requires tick of 1 that is timer runs at speed of 1MHZ the event system channel used as timer source is divided to the proper speed by means of the event system Prescaler The SPI speed is derived from the system clock with the constraint that the SPI speed in asynchronous mode that is the MCU is not clocked by the CLKM from the transceiver see the data sheet for the corresponding transceiver must be smaller than 8MHz This implies that the largest usable SPI speed is 4MHz So based on this design and depending on the selected clock speed the following hardware blocks need to be initialized accordingly e MCU clock setting e Event System initialization and thus setting proper timer source e SPI speed between MCU and transceiver e UART baud rate In order to change the implementation of the 128 1 platform and to select specific system clock the Platform Abstraction Layer PAL for this platform needs to be customized 11 6 1 2 Customizing the 128 1 platform abstraction The PAL for all ATxmega128A1 based platforms can be found in directory v x ZIPALXMEGAMATXMEGA 12841 The directory PAL XMEGA contains the code that is common to all Atmel ATxmega family based systems The directory PALUXMEGA ATXMEGA 128A1 contains the code that is
94. transceivers Atmel 64 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 AT86RF231 or Atmel AT86RF212 this hardware timer is not required for Energy Detect scanning since additional hardware support is provided On the other hand the provided standard software timers have limited accuracy since several software timers share one hardware resource An application may want to use this timer if desired for their own purpose In this case this build switch has to be set But the application has to make sure that it is not using this hardware timer concurrently with the stack All provided example applications within the MAC package do not use this feature so in order to save code space this timer is not enabled Usage in Makefiles CFLAGS DENABLE HIGH PRIO TMR enables the code for the high priority timer Usage in IAR ewp files ENABLE HIGH PRIO TMR enables the code for the high priority timer 6 1 3 7 EXTEHN AVAILABLE Each node needs to have a unique 64 bit IEEE address extended address to identify itself within the network All example applications delivered within the MAC software package are only working if the node has such an IEEE address This address is usually stored in an EEPROM either in the internal EEPROM of the MCU or in an external chip on the board If the hardware board has such an external EEPROM where the IEEE address is stored this build switch has to be enabled The
95. tx frame done cb tat coo b TAL PAL HW a b Once the MAC frame has been transmitted either successfully or unsuccessfully by means of using PAL functions and the provided hardware the TAL calls the frame transmission callback function tal tx frame done cb residing inside the MAC see MAC Src mac process 1 tx frame status c c d Inside the MCL the corresponding callback message is generated including the frame transmission status code for the MAC DATA frame and queued into the MAC NHLE Queue which handles all MAC layer confirmation and indication messages e The dispatcher extracts the confirmation message and calls the corresponding callback function mcps data conf in file MAC Src mac callback wrapper c if the application is residing on top of the MAC layer In case the stack utilizes another stack on top of the MAC layer the callback functions are implemented inside the higher stack layers ff Finally the application is notified about the status of the attempt to transmit a data frame by means of the callback function mcps data if the application resides on top of the MAC layer to be implemented inside the application itself 22 Atmel AVR2025 8412D AVR 5 12 4 1 2 Frame reception procedure Atmel AVR2025 This section shall explain the stack layer interworking by for the reception of a MAC data frame As already
96. usage of the TFA 6 1 4 3 HIGH DATA HATE SUPPOHT All 802 15 4 Atmel transceivers supported with this software package beyond AT86RF230 provide high data modes not defined within the IEEE 802 15 4 standard In order to enable these high speed transmission modes the build switch HIGH_DATA_RATE_SUPPORT needs to be set An example application where this switch is used to gain a significantly higher data throughput is the Performance Test Application see Applications TAL_Examples Performance_Test If only standard rates are used or code size is important this switch should not be set Usage in Makefiles CFLAGS DHIGH DATA RATE SUPPORT enables support of high speed data rates Usage in IAR ewp files HIGH DATA RATE SUPPORT enables support of high speed data rates 6 1 44 CHINESE BAND This build switch is used in conjunction with a Sub GHz transceiver chip that is capable of working properly within the Chinese 780MHz radio band for example the AMEL n 8412D AVR 5 12 AIMEL EEE Atmel AT86RF212 Within the stack this switch is solely used to set the proper default value for the channel page So any application that per default is required to operate within this particular band and uses the proper TAL type may use this build switch to set the channel page to a proper default value Usage in Makefiles CFLAGS DCHINESE BAND enables the channel page for the Chinese band as default
97. 00 0x8000 association permit Store the coordinator s address if coordinator CoordAddrSpec AddrMode WPAN ADDRMODE SHORT coord addr short addr Atmel AVR2025 eee Atmel AVR2025 uintl6 t coordinator CoordAddrSpec Addr else if coordinator CoordAddrSpec AddrMode WPAN ADDRMODE LONG coord addr ieee addr coordinator CoordAddrSpec Addr else Something went wrong restart wpan mlme reset req true return Associate to our coordinator wpan_mlme_associate_req coordinator gt LogicalChannel coordinator ChannelPage amp coordinator CoordAddrSpec WPAN CAP ALLOCADDRESS return Get the next PAN descriptor coordinator If the pre configured coordinator is part of the scan result list the device s application issues an association request to the coordinator The association procedure is finished once the callback usr mlme associate conf is invoked the corresponding status information is checked void mlme associate conf uintl16 t AssocShortAddress uint8 t status if status MAC SUCCESS Store own short address own_short_addr AssocShortAddress Stop timer used for search indication same as used for data transmission pal timer stop TIMER LED OFF pal led LED 1 LED Start a timer that sends some data to the coordinator every 2 seconds AIMEL 139
98. 00 See ARM7 AT91SAM7X256 Boards REB_2 3 REX ARM REV 2 AMEL s 8412D AVR 5 12 AIMEL Figure 10 6 REB V2 3 with Atmel AT86RF230B 10 4 2 3 Radio extender board REB231 V4 0 1 e Atmel transceiver Atmel AT86RF231 e The REB231 V4 0 is supported on several platforms PAL AVR32 AT32UC3B1128 Boards REB_2 3 STK600 See PAL XMEGA ATXMEGA256A3 Boards REB_4_0 CBB Figure 10 7 REB V4 0 1 with AT86RF231 E e aceceao0aeeo 522 10 4 2 4 Radio extender board REB231ED V4 1 1 e Atmel transceiver AT86RF231 using Antenna Diversity e The REB231ED V4 1 is supported on several platforms 10 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 See PAL XMEGA ATXMEGA256A3 Boards REB_4_1_CBB Figure 10 8 REB231ED V4 1 1 with Atmel AT86RF231 2125551 551 10 4 2 5 Radio extender board REB232 V7 1 0 e Atmel transceiver Atmel AT86RF232 e The REB232 V7 1 is supported on several platforms See PAL XMEGA ATXMEGA256A3 Boards REB_7_1_CBB Figure 10 9 REB V7 1 0 with AT86RF232 s REB232ED 07 1 0 10 4 2 6 Radio extender board REB233 8 1 0 e Atmel transceiver Atmel AT86RF233 e The REB233 V8 1 is supported on several platforms See PAL XMEGA ATXMEGA256A3 Boards REB_8_1_CBB AMEL 11 8412D AVR 5 12 AIMEL Figure 10 10 REB V8 1 0 with AT86RF233 10 4 2 7 R
99. 025 MAC Version 2 2 0 66 8412D AVR 5 12 Initial Version AIMEL 243 16 Table of contents 24 Atmel 2025 AIMEL amp Atmel AVR2025 IEEE 802 15 4 MAC Software Package User 1 acci 1 1 A OGUCUON E 1 2 General architecture 2 2 1 Main stack steterit edt eret 2 2 1 1 Platform abstraction layer emen 3 2 1 2 Transceiver abstraction layer TAL 3 2 1 3 MAG core layer MOL i eR entere ee chine 4 2 1 4 Usage of the stack nennen nennen nnns 5 2 2 Other stack 6 2 2 1 Resource management nnn nennen enne 6 2 2 2 Security abstraction layer sessi 7 2 2 3 Security LOOIDOX 2 E 7 2 2 4 Transceiver feature 7 3 Understanding the software package 9 3 1 package directory 9 3 2 Header file naming 15 4 Understanding the 17 4 1 Frame handling
100. 2 2 and sends a data frame to the Coordinator indicating it is alive for a certain amount of time The Coordinator in return either answers with direct data to the Device directly in case it has something to deliver to the Device or simply does nothing After the device has received a frame from the PAN Coordinator the End Device disables its receiver again This can be done by simply letting the RxEnable timer expire depending on the original value of RxOnDuration at the first call of wpan mlme rx enable req by directly calling by calling wpan mlme rx enable req with parameter RxOnDuration set to zero If the End Device does not receive a frame from its Coordinator the device automatically goes to sleep depending on the original value of RxOnDuration at the first call of wpan mlme rx enable req If this scheme is used handling of power management is done by the device itself When the RxEnable timer expires or if parameter RxOnDuration is zero the MAC will initiate its standard power management scheme and put the transceiver again into SLEEP if allowed that is in case macRxOnWhenldle is False 5 2 4 Indirect transmission from coordinator to end device NOTE 8412D AVR 5 12 Another option is to use indirect data transmission from the Coordinator to the End Device and let the Device poll the Coordinator periodically for pending data When this scheme is applied the Coordinator sets the parameter TxOptions of the
101. 2 2 3 2 MAC SYNC HEQUEST MAC SYNC LOSS INDICATION Whenever the feature MAC SYNC REQUEST is used also the feature MAC SYNC LOSS INDICATION is required to be included in the build If the requirement is not met the C pre processor will indicate an error 6 2 2 3 3 Dependency from MAC INDIRECT DATA BASIC Whenever one of the subsequently listed features is used also the feature MAC INDIRECT DATA BASIC is required to be included in the build e MAC ASSOCIATION INDICATION RESPONSE e MAC ASSOCIATION REQUEST CONFIRM e MAC DISASSOCIATION BASIC SUPPORT MAC DISASSOCIATION FFD SUPPORT e MAC INDIRECT DATA FFD e MAC PURGE REQUEST CONFIRM If this requirement is not met the C pre processor will indicate an error 6 2 2 3 4 Dependency from MAC INDIRECT DATA FFD Whenever one of the subsequently listed features is used also the switch MAC INDIRECT DATA FFD is required to be included in the build e MAC ASSOCIATION INDICATION RESPONSE e MAC DISASSOCIATION FFD SUPPORT e MAC PURGE REQUEST CONFIRM 82 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 6 2 2 3 5 MAC PAN ID CONFLICT AS PC Whenever the feature PAN ID CONFLICT AS is used also the following features are required to be included in the build e MAC START REQUEST CONFIRM e MAC SYNC LOSS INDICATION 6 2 2 3 6 PAN ID CONFLICT NON PC Whenever the feature MAC PAN ID CONFLICT PC is used also the following features are required to be incl
102. 2 Bit AVR Series of devices please press any key other than Enter Key from the keyboard The application works as described subsequently e The node performs a reset of the stack wpan mlme reset req e After successful processing of the reset the channel for operation can be entered by the user e n case the build switch HIGH DATA RATE SUPPORT is set within in the Makefiles or IAR project files the channel page can also be entered by the user This allows for using the application also for high rates e Afterwards the promiscuous mode is switched on immediately e n the serial terminal on the host system printouts indicate the detected hardware radio and microcontroller set channel and channel page and the status of promiscuous mode e Now the application will print each received frame that has a valid CRC on the terminal In order to limit the load on the serial connections currently only the following items are displayed o Number of received frame o Type of frame o Content of frame received octets in hexadecimal format this includes the MAC Header MHR of the original frame and the payload within this frame e n the application itself the received frame is already parsed so that the variable app parse data contains all information for the MAC header that is addressing information of the received frame already in structure of type prom_mode_payload_t 8412D AVR 5 12 9 2 1 4 4 Limitations
103. 2 Control of PHY receiver O X MLF2 3 Timestamp of incoming data X Beacon management M X FD1 M X MLF3 1 Transmit beacons FD2 0 FFD only MLF3 2 Receive beacons M X MLF4 Channel access mechanism X MLE5 Guaranteed time slot GTS X management MLF5 1 GTS management allocation O X MLF5 2 GTS management request X MLF6 Frame validation M X MLF7 Acknowledged frame delivery M X MLF8 Association and disassociation M X X MLF9 Security M data frames MLF9 1 Unsecured mode M X MLF9 2 Secured mode X MLF9 2 1 Data encryption 0 4 X MLF9 2 2 Frame integrity 0 4 X FD1 M X eevee zr FD2 O FFD only FD1 M MLF10 2 Active scanning FD2 O X MLF10 3 Passive scanning M X MLF10 4 Orphan scanning M X MLF11 Control define determine declare FD1 0 X superframe structure FFD only MLF12 Follow use superframe structure O X X MLF13 Store one transaction FD1 M FFD only 237 12 3 2 MAC frames Item description O4 At least one of these features shall be supported Support Yes Table 12 4 MAC frames Transmitter Receiver description Support Support number Status N A Status N A Yes No Yes No Yes MF1 Beacon FD1 M FFD only M Yes MF2 Data M Yes M Yes Acknowledgment M Yes M Yes MF4 Command M Yes M Yes MF4 1 Association request M Yes FD1 M i ssocia q FFD only MF4 2 Association response FD1 M Yes M Yes i i FFD only MF4 3
104. 4 1 8 Sensor terminal board The Sensor Terminal Board can be used as baseboard for a Plain RCB to enable SIO capabilities via USB It provides one button and two LEDs for user interaction It can be used for existing RCBs mentioned in Section 10 4 1 The following pictures depict a Sensor Terminal Board with and without an RCB and also indicate how the Sensor Terminal Board is connected to the Atmel AVR JTAGICE AMEL 17 8412D AVR 5 12 Figure 10 7 Sensor terminal board without RCB 188 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 10 9 Sensor terminal board connected to Atmel AVR JTAGICE and USB The Sensor Terminal Board can be powered with USB although it is recommended to use a powered hub in case the board is not directly connected to a PC 10 4 2 Radio extender boards REB The Radio Extender Board REB is a radio module containing an Atmel transceiver REBs cannot be used stand alone but require an additional baseboard for the MCU such as Atmel STK600 Atmel AT91SAM7X EK Atmel AT91SAM7XC EK etc 10 4 2 1 Radio extender board REB230 V2 1 For more information about earlier versions of the Radio Extender Boards prior to V2 3 please contact Atmel support 3 10 4 2 2 Radio extender board REB230 V2 3 e Atmel transceiver Atmel AT86RF230B e The REB230B V2 3 is supported on several platforms See PAL XMEGA ATXMEGA256A3 Boards REB_2_ 3 CBB See PAL AVR32 AT32UC3B1128 Boards REB_2_3_ STK6
105. 4 1 PLAIN I RCB 4 1 SENS TERM BOARD I RCB 5 3 PLAIN 8412D AVR 5 12 Hinc L Atmel AVR2025 NS ERM BOARD _5_3_5 Inc L Src Generic Hinc RF L ATMEGA128RFA1 I Boards I RCB 6 3 PLAIN I RCB 6 3 PLAIN OR STB L RCB 6 3 SENS TERM BOARD Hinc L cGeneric Hinc EGA256A3 I Resources SAL 1 HaT TX L Src a 8412D AVR 5 12 M Management Hinc L Src L Queue Management Hinc 86 2 L Src GARF SAL EGA SAL 13 AIMEL Ey 1 86 212 Hinc L sre AT8 6RF230B Hinc L sre I AT86RF231 Hinc L sre AT8 6RF232 Hinc L sre I AT8 6RF233 Hinc L sre 1 r L sre Hinc L srce 86 212 L Ssre 86 230 L sre I AT86RF231 L Src L AT86RF233 L Src 1 L sre L tne These directories contain the following items in alphabetical order e Applications o The MAC package comes with a variety of applications which comprise MAC ap
106. 5 2009 Loaded debugee c Atmel MAC_v_2_2_0 Applications MAC_Examples StarNobeacon ATs6RF231_ATMEG4 e In case the IEEE address of the node is stored in the internal EEPROM of the microcontroller perform as follows only for 8 bit IAR o Check whether valid IEEE address different from OxFFFFFFFFFFFFFFFF and 0x0000000000000000 is stored in the internal EEPROM Select menu View item Memory In this window select EEPROM If the IEEE address is not set properly add the correct IEEE to the first eight octets of the EEPROM AMEL ns AMEL Figure 8 33 IAR Embedded Workbench verifying and setting of IEEE address Embedded Workbench IDE 2 ni xl File Edit Project Debug JTAGICE mkII Tools Window Help 15 Selo 4 Y X x 516152555251 Release il O03BEE 0803 0 8135 0803 2 8106 003 4 8117 003 6 EF4F 0803 8 8740 Lata MAC zl Star Messages Building configuration Star Release Updating build tree bmm c mac c mac api c mac associate c mac beacon c Errors Warnings 0 pos 00000000 e Start the application by pressing the F5 or the Go button 8 3 5 Using IAR AVR 32 Embedded Workbench When using AVR32 Embedded Workbench directly by double clicking the corresponding eww file the ap
107. 642 IAR Embedded Workbench for Atmel AVR V5 51 0 see http www iar com IAR Embedded Workbench for Atmel AVR32 V3 31 0 see http www iar com IAR Embedded Workbench for Atmel ARM V6 20 0 see http www iar com 8 2 Building the applications All example applications contain precompiled hex files that can be downloaded and run out of the box In order to rebuild any of the applications for any desired hardware platform one of the following three ways described in the subsequent sections can be chosen generally 8 2 1 Using GCC makefiles Each application can be rebuilt using the provided Makefiles Please follow the procedure as described 2 Atmel AVR2025 Change to the directory where the Makefile for the desired platform of the corresponding application is located for example cd Applications MAC_Examples Promiscuous_Mode_Demo cd AT86RF212_ATMEGA1281_RCB_5_3_SENS_TERM_BOARD cd GCC Run the desired Makefile for example make f Makefile Or mak f Makefile Debug 8412D AVR 5 12 8 2 Using AVR Studio 4 8 2 3 Using AVR Studio 5 Atmel AVR2025 Makefile builds a binary optimized for code size without Serial I O support whereas Makefile Debug builds a version for better debug support without optimization but with additional Serial I O support e After running one of the Makefiles the same directory contains both a hex file and an elf file which can be downloaded on
108. 6RF231 ATXMEGA128A1 REB 4 1 STK600 for the following Makefiles e Makefile Standard clock speed of 16MHz e Makefile 32 8 4 MHZ Makefiles for customized clock speed with proper build switch F CPU For the IAR tool chain Example project files for changing the system clock are provided for the MAC application Star Nobeacon for the above described hardware platform Please check directory MAC_v_x_y_z Applications MAC_Examples Star_Nobeacon AT86RF231 ATXMEGA128A1 REB 4 1 STK600 for the following IAR project files e Star eww Standard clock speed of 16MHz e Star 32 8 4 MHZ eww ewp IAR project files for customized clock speed with proper build switch F CPU In order to review the changes for the selectable clock speed feature search for occurrences of this build switch in the corresponding files pa board c and pal config h Other clock speeds than the currently supported speed such as 1MHz or 2MHz could be implemented easily by updated the dedicated code snippets pointed out by F CPU AMEL 235 AIMEL amp 12 Protocol implementation conformance statement PICS This chapter lists the conformance of the Atmel AVR2025 MAC implementation with the requirements and optional features as defined by the standard specified in 4 in Section D 7 12 1 Major roles for devices compliant with IEEE Std 802 15 4 2006 Table 12 1 Functional device types 12 2 Major capabilitie
109. 9 2 1 5 1 Introduction 8412D AVR 5 12 Atmel AVR2025 Figure 9 2 Promiscuous Mode Demo terminal program snapshot x Datei Bearbeiten Ansicht Anrufen bertragung Dies 5 5 sole 3 3 3 3 JE X JE JE JE JE CC M X JE JE JE JE JE JE JE JE X JE JE JE JE JE JE JE JE JE JE JE JE JE JE JE JE JE 9 JE JE JE 0 JE JE JE FE Promiscuous mode demo application RT86RF230B ATxmega128A1 Current channel 24 Current channel page 0 Promiscuous mode is on 22 FF FF FF FF 07 14 FF FF FF FF 07 80 7C 78 56 00 00 FF CF 00 00 15 78 56 00 00 FF FF 12 13 14 15 16 17 18 19 01 82 16 78 56 00 00 12 13 14 15 16 17 18 19 04 23 78 56 12 13 14 15 16 17 18 19 A1 R2 A4 AS AG AT AB 02 FE 1 2 3 4 6 8 0 0 29 23 10 Cmd 63 88 17 78 56 00 00 FE CA 04 11 Ack 12 00 17 12 Data 61 88 24 78 56 FE CA 00 00 AA BB CC DD 13 Ack 02 00 24 verbunden 00 03 02 Auto Erkenn 9600 8 N 1 RF GROSS Aufzeichnen Druckerecho e The current channel is coded within the application In order to run the application on another channel change the default channel in file main c and re built the application e The processing of each received frame within the application and the corresponding serial output is the limiting factor of this application in terms of throughput e The actual processing and output implemented within the application for each
110. AIMEL SEE A matching base application for this MAC application is the Star_Nobeacon application The platform ATxmega256A3 MCU based on REB231ED V4 1 1 is already supported for this base application All required build files for GCC and IAR for this particular base application are located in directory Applications MAC_ AT86RF231 ATXMI Examples Star Nobeacon EGA256A3 REB 4 1 CBB This entire directory is copied to the target application directory Now the following directory exists Applications MAC AT86RF231_ATXMI Examples Promiscuous_Mode_Demo EGA256A3 REB 4 1 CBB This directory now contains the following entries e GCC Makefile GCOC Makefile Debug e Star aps e Star ewp e Star eww Now rename the project files as required for the target application that is rename all files Star to Promiscuous Mode Demo 11 5 2 Step 2 Update the GCC Makefile The Makefiles of the target application which was duplicated from the base application is now located in the GCC directory of the target application that is Applications MAC AT86RF231 ATXMI Examples Promiscuous Mode Demo EGA256A3 REB 4 1 CBB GCC In order to support the target application these Makefiles need to be updated as follows e Replace occurrences of the name of base application Star with the name of the target application Promiscuous Mode Demo Promiscuous Mode Demo This is required in co
111. API function bool wpan mcps data req uint8 t SrcAddrMode wpan addr spec t DstAddrSpec uint8 t msduLength uint8 t msdu uint8 t msduHandle uint8 t TxOptions to WPAN_TXOPT_INIDIRECT_ACK indirect but acknowledged Transmission value 5 instead of WPAN TXOPT ACK direct acknowledged Transmission value 1 as it is currently see file api h in directory MAC Inc This requires an additional check which device type the node is currently since data from the Device to the Coordinator is still only transmitted directly Additionally the Device needs to implement a polling scheme in its application during which it periodically calls function wpan mlme poll req This will initiate a data request frame to the Coordinator In case the Coordinator does have pending data for the Device it initiates the direct transmission of those frames Otherwise Coordinator sends a null data frame data frame with empty payload The Device both receives the response from the Coordinator and if there is no further action to be done returns to standard power management procedures For more information see Sections 4 4 1 and 4 4 2 AIMEL sa AIMEL SEE If this scheme is used handling of power management is done by the device itself 5 3 Application control of MAC power management As indicated throughout the previous sections there are several means for the application to control the general power management scheme applied
112. Alt E Toolchain r Selected debugger eP d app config h j bmm c m 0 eP into el d Estep over F10 5 pp Toggle Breakpoint 9 amp mac apih New Breakpoint dj mac_associate c Debugging H E J beacon c The JTAG Clock De Il Breakpoints Ctrl Shift F9 1 mac callback wrapper c Advanced mac data ind c ase dj mac data req c Use external reset Use external rese Import DataTips Device JTAG Clock All DataTips Export DataTips Properties Daisy chain sel Options and Settings Target device is not part of a JTAG daisy chain Daisy chain Devices before Instruction bits before 0 Devices after o Instruction bits 0 r Memory Settings Output Show output from Debug EDI 3 The program Promiscuous Mode Demo elf has exited with code 0 0 0 1019 Output e The image will be downloaded and the download status is indicated within AVR Studio 5 e Now AVR Studio 5 looks like below 8412D AVR 5 12 Atmel AVR2025 Figure 8 24 AVR Studio 5 after successful debug build download File AssistX Project Build Debug Tools Window Pale ly 3 id i 4 cacA o DP 109 IFRA a S1 iT XS ae mbl yt Ox21FD X Register Ox0B1D Y Register Ox21FF Z Register
113. Build Actions Linker elect plugins to load CCR ICE200 JTAGICE JTAGICE mkII Dragon Simulator Third Party Driver Description pC 0S ll Kernel Awareness Location C NProgramme MARS ystemsXE mbeddedw orkbench53 avr Originator Micripm Version 10 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Within the Options window for the Release Workspace select now the JTAGICE window and within this window select the JTAGICE 2 tab Figure 8 27 IAR Embedded Workbench Options gt JTAGICE gt JTAGICE 2 Options for node Star Category Factory Settings General Options C C Compiler Assembler Custom Build JTAGICE 1 JTAGICE mkll 2 Serial Port Extra Options Build Actions Linker Debugger CCR Preserve EEPR M contents even if device is reprogrammed ICE200 sek JTAGICE Aun timers in stopped mode Restore fuses when ending debug session Dragon Enable software breakpoints Simulator Third Party Driver System breakpoints exit JV putchar getchar Within the JTAGICE mkII 2 tab check the items as shown above Especially make sure that the EEPROM will be preserved if the device is reprogrammed Press OK Press the button Download and Debug Within the Setup tab select the Driver JTAGICE mkll and deselect Run to main Change to t
114. D The node is able to handle requests to transmit data frames to its children indirectly once being polled by those nodes This requires that the switch MAC INDIRECT DATA BASIC is also set e MAC ORPHAN INDICATION RESPONSE The node is able to accept and process a received orphan indication frame by one of its children and respond appropriately e MAC PAN ID CONFLICT AS PC The node is able to detect a PAN Id conflict situation while acting as a PAN AMEL 8412D AVR 5 12 AIMEL quM Coordinator by checking received beacon frames from other PAN Coordinators and being able to act upon the reception of PAN Id Conflict Notification Command frames from its children MAC PAN ID CONFLICT NON PC The node is able to detect a PAN Id conflict situation while NOT acting as a PAN Coordinator by checking received beacon frames from other PAN Coordinators and being able to initiate the transmission of PAN Id Conflict Notification Command frames from its parents if required e MAC PURGE REQUEST CONFIRM The node is able to purge indirect data frames from its Indirect Data Queue upon request by its upper layer e MAC RX ENABLE SUPPORT The node is able to switch on or off its receiver for a certain amount of time upon request by its upper layer This is required in order to allow for the upper layer to receive frames in case the node is generally in a power safe state MAC SCAN ACTIVE REQUEST CONFIRM The node is able to perform an active sca
115. Disassociation notification M Yes M Yes MF4 4 Data request M Yes FD1 M Yes MF4 5 igentinier contet M Yes FD1 M Yes notification Orphaned device Yes MENS notification M Mes FROM FFD only MF4 7 Beacon request FD1 M Yes FD1 M Yes Yes MF4 8 Coordinator realignment FD1 M FFD only M Yes MF4 9 GTS request MLF5 O No MLF5 O No Atmel AVR2025 8412D AVR 5 12 13 Abbreviations API BMM GPIO IRQ MAC MCL MCPS MCU MHR MIC MLME MPDU MSDU NHLE NWK PAL PAN PIB QMM RCB REB SAL SIO SPI STB TAL TFA TPS TRX WPAN 8412D AVR 5 12 Atmel AVR2025 Application Programming Interface Buffer Management Module General Purpose Input Output Interrupt Request Interrupt Service Routine Medium Access Control MAC Core Layer MAC Common Part Sub layer Microcontroller Unit MAC Header Message Integrity Code MAC Sub layer Management Entity MAC Protocol Data Unit MAC Service Data Unit Next Higher Layer Entity Network Layer Platform Abstraction Layer Personal Area Network PAN Information Base Queue Management Radio Controller Board Radio Extender board Security Abstraction Layer Serial I O Serial Peripheral Interface Security Toolbox Transceiver Abstraction Layer Transceiver Feature Access Transceiver Programming Suite Transceiver Wireless Personal Area Network AIMEL AIMEL amp 14 1 Atmel Wireless MCU Software Website http www
116. EN 0 output pins DIG3 DIG4 are pulled down to analog ground If AT86RF231 is connected with RF front end module i e REB231FE2 EK kit default TX power is 20dBm To ensure FCC compliance TX Power of CH26 has to be limited to 13dBm TX PWR 0 0 5 if user changes the channel to 26 and the default TX power is more than 13dBm it shall be automatically changed to 13dBm For CH26 the allowed range of TX power is 4dbm to 13dBm for other channels it is 4dBm to 21dBm 9 2 2 1 3 2 3 Diversity feature testing 8412D AVR 5 12 In a multi path environment several versions of the same signal with different phases delays and attenuations will be added together at the receiver location so there is always the possibility that at some locations the signals could cancel each other out almost entirely One way to overcome the multi path issue is to use the receiver antenna diversity technique In this method two antennas are used instead of one in the receiver This way if one antenna is in a multi path null also known as deep fading region the other antenna has a good chance of being outside the deep fading region The receiver can switch between these two antennas to escape from a multi path null Enable Diversity in the radio by using the main menu Diversity can also be configured in the reflector node by using the main menu By default diversity is enabled AT86RF231 has a built in antenna diversity feature Upon reception of a fr
117. ER Range 78 PEER_RSP_SENT CONF WAIT TIMER 2 2 PEER_CONF M3 WAIT_FOR_PEER_CONF rand addr2 Dest rand addr1 payload rand addr2 i o lt X PEER_SEARCH_SUCCESS 1 On pressing the button T1 or receiving a valid character on UART which is shown as an event E1 the node becomes Transmitter and sends a Peer Request M1 as broadcast at a constant period Then the node enters into PEER_REQ_SENT state A timer PEER_RSP_WAIT_TIMER T1 is started to send the Peer Requests with 50ms time interval A counter is started to count the no of Peer Requests sent On every expiry of the timer T1 count value is incremented by one The Transmitter stops sending the Peer Request if the count reaches to Oxff and the node goes to the WAIT_FOR_EVENT state again The Peer Request packet payload consists of a 16 bit random number and used as source address rand addr1 of the receiving node and the mode byte to indicate in which mode PER Range this Peer Request has been sent 2 If any other node is in power on state and it receives this Peer Request packet it becomes Reflector assigns itself this address rand addr1 as its source address IEEE 802 15 4 protocol and sends a Peer Response M2 which is a unicast to Transmitter as destination address using extended MAC address The Reflector node then enters into PEER RSP SENT state After receiving the AMEL 17 8412D AVR 5 12
118. Frame using the TAL API While the application on top of the TAL needs to free buffers received by the frame reception callback function since these buffers are always allocated inside the TAL automatically for frame transmission two different approaches are available 10 Application uses buffer management module provided by stack including allocation and freeing of buffers for frame transmission or 11 Application uses static frame transmission buffer without the need for allocating or freeing buffers dynamically Approach 2 will be used subsequently similar to the source code based on example application in Section 9 2 2 1 Independent from the selected approach regarding the buffer management it is important that the frame finally presented to the TAL for transmission follows the scheme in Figure 4 7 The frame needs to be stored at the end of the buffer right in front of the space for the FCS This is required in order to fit a frame using the maximum frame length according to 4 into a buffer of size LARGE BUFFER SIZE If this scheme is not proper applied memory corruption may occur AIMEL 29 AIMEL ey Figure 4 7 Frame buffer handling during frame transmission using TAL API Appl TAL Step 1 Step 2 msg type msg type gt 5 buffer_header 5 5 2 buffer header a o0 3 ao ad msduHandle x ie msduHandle o0 5 5 5 42 persiste
119. I AT91C 17 SPIQ MOSI SPI Bus Master Input Slave Output pin is PA16 define MISO 91 16 SPI serial clock is 18 define SCK 91 18 5 0 5 SPI Base Register SPI1 is used with REX ARM Rev 3 define AT91C BASE SPI USED AT91C BASE 5 11 RESET pin is pin 9 of PIOA define RST 91 9 Sleep Transceiver is 8 of PIOA define SLP_TR AT91C_PIO_PA8 Slave select pin is PA21 define SEL AT91C_PA21_SPI1_NPCSO SPI Bus Master Output Slave Input pin is PA23 define MOSI 91 23 MOST SPI Bus Master Input Slave Output pin is PA24 f define MISO 91 24 SPI1_MISO SPI serial clock pin is PA22 define SCK AT91C 22 SPII SPCK in order to reflect the utilization of SPI as transceiver interface e TRX GPIO pins Remain unchanged Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 e Short PAL waiting delays WAIT 65 NS PAL WAIT 500 NS PAL WAIT 1 US Remains unchanged e Timeout macros MIN TIMEOUT MAX TIMEOUT MIN DELAY VAL Remains unchanged since this platform uses the same timer implementation as the base platform e Timer source macros o TIMER SRC DURING TRX AWAKE SRC DURING TRX SLEEP o These macros specify which timer source is used on this system when the transceiver is awake or sleeping o R
120. IAR project files The IAR project files for an ARM7 based project Star ewd Star ewp Star eww and flash icf of the target board which were duplicated from the base platform board are now located in the application build directory of the target platform that is Applications MAC Examples Star Nobeacon AT86RF231 AT91SAM7X256 REB 4 0 2 REX ARM REV 3 In order to support the target platform the file Star ewp needs to be updated as follows e Change the TAL TYPE from state TAL TYPE AT86RF230B state to state TAL TYPE AT86RF231 state e Change the BOARD TYPE from state BOARD TYPE REB 2 3 REX ARM REV 2 state to state BOARD TYPE REB 4 0 2 REX ARM REV 3 state e Since the target board does not use the Timestamp interrupt from the Atmel AT86RF231 add the following build option state DISABLE 5 IROQ state e Change all occurrences of REB 2 3 REX ARM REV 2 to REB 4 0 2 REX ARM REV 3 e Change all occurrences of AMEL 2 8412D AVR 5 12 D to AIMEL SEE T86RF230B AT86RF231 Since the MCU type is note changed the build switches PAL_GENERIC_TYPE and PAL_TYPE remain unchanged 11 4 Bring up of a new MCU based on a supported MCU family 11 4 1 218 Implementation of PAL for target platform The task of bringing up a new MCU target MCU within an already suppor
121. KING SPI enables non blocking SPI frame download 6 1 3 9 CPU formerly SYSTEM CLOCK MHZ Currently each supported platform that is each supported board has a specific clock speed set for the system clock This clock speed might need to be changed for certain applications For the platform Atmel ATxmega128A1 with Atmel AT86RF231 on REB 4 1 600 the clock speed can be changed at compile time 4 32MHz The current system clock speed can be controlled via the build switch F CPU If the build switch is omitted the standard system clock speed is used Usage in Makefiles CFLAGS DF CPU 4 8 32 configures the system clock to 4 8 22MHz Usage in IAR ewp files F CPU 4 8 321 configures the system clock to 4 8 22MHz Example Makefiles and IAR project files are provided for the MAC example application Star Nobeacon For more information please see Section 11 1 6 1 3 10 BAUD This build switch allows for changing the used UART baud rate The default UART baud rate is 9600 bps This may be changed by setting this build switch to a different meaningful value Usage in Makefiles CFLAGS DBAUD RATE 38400 configures the UART baud rate to 38400 bps Usage in IAR ewp files BAUD_RATE 38400 configures the UART baud rate to 38400 bps Omitting this build switch sets the default baud rate of 9600 bps For USB this build switch has no meaning Pease note that the proper working of the UART with certain
122. M e LED control or button access support These components are implemented as software blocks and are ported based on the target microcontroller The transceiver access module provides interface to the registers and frame buffer of the transceiver The timer module implements software timer functionality used by the MAC TAL and application layer The serial stream I O module provides communication services for transmission and reception of serial data for example UART USB communication The GPIO module controls the general purpose I O pins of the microcontroller The interrupt module handles the transceiver interrupt s Hardware timer interrupts and other interrupts are handled internally by the PAL The function prototypes for all PAL API functions are included in file PAL Inc pal h 2 1 2 Transceiver abstraction layer TAL 8412D AVR 5 12 The Transceiver Abstraction Layer TAL contains the transceiver specific functionality used for the 802 15 4 MAC support and provides interfaces to the MAC Core Layer which is independent from the underlying transceiver Besides that the TAL API can be used to interface from a basic application There exists exactly one implementation for each transceiver using transceiver embedded hardware acceleration features The TAL on top of PAL can be used for basic applications without adding the MCL The following components are implemented inside the TAL e Frame transmission unit including
123. MAC Src mac callbcak wrapper c the structure of type mcps data conf t is again overlaid over the message which is the actual buffer body pmsg mcps data conf t BMM BUFFER POINTER buffer t m Finally the corresponding parameters of the callback function inside the application function usr mcps data conf are filled by the corresponding members of the mcps data conf t structure and the buffer is freed again by calling function bmm buffer free The buffer is now free for further usage Through all steps from 1 to 6 the same buffer is used 8412D AVR 5 12 Atmel AVR2025 4 2 1 2 Frame reception buffer handling Figure 4 6 Frame buffer handling during data frame reception TAL MCL MAC API Step 2 Step 3 dow sdow not used for Rx persistence_time only for indirect transmission indirect_in_transit only for indirect transmission M Y ojur owes Y pul ipu Y pur eyep s Free Area Free Area Free Area Frame length uploaded from TRX Congo EOD Length of MPDU MPDU PHY frame uploaded from TRX MPDU MPDU FCS uploaded from TRX Lal uploaded from TRX ED value read from TRX register FCS ED value mac process tal data ind mcps data ind in in mac data ind c mac callback wrapper c mac process data frame in mac mcps data c handle
124. N_SUPPORT Example 3 A node that shall be able to tranmit secured data frames has to use an application built with MAC_SECURITY_ZIP Please refer to file Include mac build config h for more information about the supported functionality 6 2 1 1 FFD feature set The following features are enabled if FFD is set during the build process e MAC_ASSOCIATION_INDICATION_RESPONSE The node is able to accept and process association attempts from other nodes Also this node can provide Short Addresses to other nodes if desired e MAC_ASSOCIATION_REQUEST_CONFIRM The node is able accept and process a request from its upper layer for example the network layer to associate itself to another node that is its parent e MAC_BEACON_NOTIFY_INDICATION The node is able to present received beacon frame to its upper layer in case the beacon frame contains a beacon payload or the MAC PIB attribute macAutoRequest is set to false e MAC_DISASSOCIATION_BASIC_SUPPORT The node is able to accept and process a request from its upper layer to disassociate itself from its network or disassociate one of its children or to process a received disassociation frame from another node e MAC_DISASSOCIATION_FFD_SUPPORT The node is able to transmit an indirect disassociation notification frame This requires that the switch MAC_DISASSOCIATION_BASIC_SUPPORT is also set e MAC_INDIRECT_DATA_BASIC The node is able to poll its own parent for indirect data e MAC_INDIRECT_DATA_FF
125. ON NOTIFY INDICATION This feature is usually required for any node both RFD and FFD that may need to present received beacon frame to its upper layer This could be caused by the fact that the received beacon frame contains a beacon payload or the MAC PIB attribute macAutoRequest within the node is set to false 4 4 15 MAC GET SUPPORT This feature allows reading the current values of MAC PIB attributes by means of using function wpan mlme get req AMEL i 8412D AVR 5 12 AIMEL amp 4 4 16 MAC PAN ID CONFLICT AS This feature is a typical FFD feature that allows a PAN Coordinator node to detect a PAN Id conflict situation and report this to its higher layer allowing the higher layer or application to initiate the proper PAN Id conflict resolution The node is able to detect a PAN Id conflict situation while acting as a PAN Coordinator by checking received beacon frames from other PAN Coordinators and being able to act upon the reception of PAN Id Conflict Notification Command frames from its children The following components are required as well MAC START REQUEST CONFIRM e MAC SYNC LOSS INDICATION 4 4 17 MAC PAN ID CONFLICT NON PC This feature is usually required for any node both RFD and FFD that may need to detect a PAN Id conflict situation while acting not as a PAN Coordinator node The node is able to detect a PAN Id conflict situation while NOT acting as a PAN Coordinator by checking received beacon
126. R main o DIR Src main c CC INCLUDES CFLAGS lt TARG PATH to DIR pal uart o PAL S PAL GENERIC TYPE Generic Src pal uart c c CFLAGS INCLUDES o 508 lt Compile 5 TARG DIR main o APP_DIR Src main c S INCLUDES S CFLAGS c o lt TARG PATH TARG PATH 28 Atmel AVR2025 DIR sio handler o STIO SUPPORT Sre sio handler e CC S INCLUDES CFLAGS c o lt ET_DIR pal_uart o PAL _PAL_GENERIC_TYPE Generic Src pal_uart c c CFLAGS INCLUDES o 50 lt 8412D AVR 5 12 Atmel AVR2025 11 5 3 Step 3 Update the IAR project files The IAR project files Promiscuous_Mode_Demo eww and Promiscuous Mode Demo ewp of the target application are now located in the directory Applications MAC_Examples Promiscuous_Mode_Demo AT86RF231 ATXMEGA256A3 REB 4 1 CBB GCC In order to support the target application these project files need to be updated as follows e Replace occurrences of the name of base application Star with the name of the target application Promiscuous Mode Demo Promiscuous Mode Demo This is required in both project files e Enable SIO support for this application via the supported SIO channel In this example UART1 is used Also update the used and or u
127. RCB 1 3 No 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 Buttons LEDs SIO support Sensor terminal board RCB 1 2 USB Atmel STK600 REB to STK600 Adapter REB 8 8 UART Atmel AT91SAM7X C EK REX_ARM REB Joystick 4 UART Atmel ATmega128RFA1 EK1 1 3 UART Atmel AT32UC3LEK RZ600 1 4 USB RZ600 0 2 USB STK600 AVR32 REB 8 8 UART amp USB Atmel AT91SAM3S EK RZ600 Radio 2 3 UART amp USB Atmel SAM3S USB sticks 0 3 USB 205 AMEL 11 Platform porting AIMEL amp 11 1 Porting new platform In case new platform that is supported yet needs to be utilized the task to bring up the new platform can be performed as described in the following section Generally this task can be split into different subtasks 35 Bring up of a new PAL or of a board within an already existing PAL 36 Bring up of an existing application on the new platform 37 Bring up of new applications on the new platform if required Each of these subtasks will be explained subsequently and described on an example Before the actual porting is described a number of terms need to be defined 11 2 Bring up of a new PAL Target MCU MCU that is not yet supported and shall be utilized within a new platform Base MCU MCU that is already supported within the MAC package and it s PAL implementation is used as base code for the target MCU Target board Board based on the target MCU
128. RT1 enables the SIO Hub and uses UART Channel 1 6 1 3 5 ENABLE SHAM In general there are two different ways of accessing the memory of the transceiver either by frame buffer access 1 or by direct SRAM access 2 Please check the data sheet for more information When a frame needs to be uploaded or downloaded into or from the transceiver this can be done by using the corresponding frame buffer functions or transceiver SRAM access functions It is always recommended to use the frame buffer functions For more information please see file PAL Inc pal h or file PAL AVR Generic Src pal_trx_access c 24 Functions for frame buffer access always enabled void pal_trx_frame_read uint8_t data uint8_t length void pal_trx_frame_write uint8_t data uint8_t length 25 Functions for direct transceiver SRAM access only enabled if ENABLE TRX SRAM is set void pal trx sram read uint8 t addr uint8 t data uint8 t length void pal trx sram write uint8 t addr uint8 t data uint8 t length For transceivers providing AES security the SRAM functions are required if transceiver security is used For Atmel AT86RF230 it is recommended not using this switch in order to save code space 6 1 36 ENABLE HIGH PRIO AT86RF230 transceivers need to have an ED sampling timer running in case Energy Detect scanning is used This timer is implemented by means of a unique and very accurate hardware timer High priority timer In other
129. RX IRQO RX E RX IRO TX E P gle chips D D RX_IRQ_CCA_ED Clearing of further optional transceiver interrupt flags for MEGA RF single chips only available if ENABLE_ALL_TRX_IRQS is used RX IRQ AMI trx irq flag clr awake EAR RX_IRQ_BATMON trx irg flag_clr pll lock EAR RX AWAKI trx irq flag clr pll unlock CLEAR IRQ PLL UNLOCK For more information see PAL Inc pal h file and the corresponding pal config h file for each platform implementation AIMEL RX IRO PLL LOCK 91 8 Toolchain AIMEL SSE The following sections describe the used toolchain for the development and build process and how the provided example applications can be built 8 1 General prerequisites The following tool chain is used for building the applications from this MAC package Atmel AVR Studio 4 18 see http www atmel com dyn products tools_card asp tool_id 2725 AVR Studio 5 see http www atmel com dyn products tools_card asp tool_id 17212 WinAVR 20100110 including AVR GCC for Windows see http sourceforge net projects winavr Atmel AVR32 GNU Toolchain for Windows see http http www atmel com dyn products tools_card asp tool_id 41 18 ARM Code Sorcery GCC Toolchain for Windows IA32 Windows Installer see http www codesourcery com sgpp lite arm portal release
130. SCAN ORPHAN REQUEST CONFIRM 0 0 0 define MAC START REQUEST CONFIRM The other features are omitted in the examples but have to be set according to the application need AMEL a AIMEL 6 2 2 3 Implications and Internal Checks amp There are number of dependencies between several of the features mentioned above In order to keep the burden for the end user low certain required internal checks or further implicit settings are done while configuring the build These checks and implications can be seen in file Include mac build config h 6 2 2 8 1 MAC COMM STATUS INDICATION Communication systems usually follow the approach to implement primitives in pairs This is 1 Request Confirm for example MLME ASSOCIATE request and MLME ASSOCIATE confirm or 2 Indication Response for example MLME ASSOCIATE indication and MLME ASSOCIATE response Whenever such an Indication Response scheme is applied the corresponding node needs a confirmation that its last transaction has finished successfully for example the last transmitted frame has been acknowledged by its receiver This confirmation is done within IEEE 802 15 4 by creating an MLME COMMUNICATION STATUS indication message to the upper layer This implies that whenever MAC ASSOCIATION INDICATION RESPONSE or ORPHAN INDICATION RESPONSE is used both is valid for an FFD only the feature COMM STATUS INDICATION is enabled automatically 6
131. SIBILITY OF SUCH DAMAGES Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice Atmel does not make any commitment to update the information contained herein Unless specifically provided otherwise Atmel products are not suitable for and shall not be used in automotive applications Atmel products are not intended authorized or warranted for use as components in applications intended to support or sustain life 8412D AVR 5 12
132. Since some board may not necessarily have a valid IEEE address stored in either internal or external EEPROM for example Atmel AT91SAM7X EK boards the applications cannot run properly For the purpose of proper example demonstration a check for this IEEE address is implemented If the IEEE address is not correct that is it is 0 or OXFFFFFFFFFFFFFFFF a random IEEE address is assigned to this node Some applications do not require this specific IEEE check In this case the code can be significantly smaller by setting the build switch DISABLE IEEE ADDR CHECK Also this build switch gives a very good indication which portions or the TAL need to be changed or removed for smaller code size by simply searching for build switch DISABLE IEEE ADDR CHECK This switch is currently not enabled in any example application since all example applications require a valid IEEE address Boards providing a valid IEEE address always use their original unique IEEE address during operation 6 1 4 8 DISABLE TSTAMP This build switch is used to disable the Timestamp interrupt that is the second transceiver interrupt for Atmel AT86RF231 Atmel AT86RF232 and Atmel AT86RF212 on systems which do not utilize this transceiver interrupt This is for example valid for boards based on Atmel ARM AT91SAM7X256 MCUs in conjunction with AT86RF231 The TAL for AT86RF231 AT86RF232 and AT86RF212 is designed to utilize the Timestamp interrupt as default for generat
133. Tmega1281 E ioj xi Main Program Fuses LockBits Advanced Hw Settings HW Info Auto Device Erase Device Erase device before flash programming IV Verify device after programming r Flash Use Current Simulatar Emulator FLASH Memory InpuHEXFie F231 1281 REB 4D 231 IAR Exe Star 230 vw oma m EEPROM Use Curent Simulator Emulator EEPROM Memory Input HEX File Program Verify Read Production File Format Input ELF File Fuses and lockbits settings Program Save must be specified before saving to ELF Erasing device OK Programming FLASH OK Reading FLASH FLASH contents is equal to file OK Leaving programming mode ATMEL 99 AMEL e Close the JTAGICE dialog This starts the application No further feedback within AVR Studio can be seen In order to verify the proper functioning of the application check the corresponding outputs LED status Sniffer output Terminal Window output etc e In case the application does not work as desired and especially if the three standard LEDs are blinking fast check first the proper IEEE address setting see Section 8 3 1 or Section 8 3 2 2 or whether the proper binary has been selected selection of transceiver type microcontroller type and board type 8 3 2 2 Starting the debug build The debug build can simply be started as follows
134. Transmitter node starts here e Nodes shall go into different sub states like INIT PEER REQ SENT PEER RCVD PEER SEARCH SUCCESS 4 SEARCH PER TX 8412D AVR 5 12 Atmel AVR2025 e Enters after receiving a character on UART event from user Peer Search process in PER mode as Transmitter node starts here e Nodes shall go into different sub states like PEER_INIT PEER SENT PEER _RSP_RCVD PEER SEARCH SUCCESS 5 PEER SEARCH RANGE RX e Enters after receiving a valid frame Peer Request from Transmitter Peer Search process in Range Measurement mode as Reflector node starts here e Nodes shall go into different sub states like PEER INIT PEER SENT WAIT FOR PEER CONF SEARCH SUCCESS 6 PEER SEARCH PER RX e Enters after receiving a valid frame Peer Request from Transmitter Peer Search process in PER Measurement mode as Reflector node starts here e Nodes shall go into different sub states like PEER INIT PEER SENT WAIT FOR PEER CONF SEARCH SUCCESS 8 RANGE TEST TX ON e Starts Range Measurement mode as Transmitter e Enters after successful Peer Search on key press event e Continuous packet transmission with a period of 200 ms time interval e Enters from RANGE TEST TX 7 state on button press 7 RANGE TEST TX OFF e Starts Range Measurement mode as Reflector e Enters after successful Peer Search on a valid frame Peer Request in Range Measurement mode r
135. UC3L EK 20 Atmel 2025 8412D AVR 5 12 Atmel AVR2025 10 4 7 Atmel STK600 Atmel AT32UC3B1128 with REB 10 4 8 RZ600 kit 8412D AVR 5 12 The STK600 is supported with REB in conjunction with an REB to Atmel STK600 Adapter can be used as a baseboard for an REB to create platforms using AVR 8 bit MCUs such as Atmel ATxmega or Atmel ATmega MCUs But for Atmel AVR32 AT32UC3B1128 the STK600 be connected to the REB by using the connection details given below that is Table 10 1 See PALAVRS2 AT32UCB1128 Boards REB X X STK600 e Images need to be flashed using Atmel AVR JTAGICE and the JTAG connector given on the STK600 e A USB driver providing a virtual COM port for the AT32UC3B1128 based on the CDC Driver is provided in the software package see at32uc3xxx_cdc inf in directory _ UtilsVAVR32 USB Driver It provides eight buttons and LEDs for user interaction Table 10 1 depicts the socket and routing card needed for Atmel AT32UC3B1128 MCU and Atmel REB231 to STK600 connection details Similar connection can be made for Atmel REB230B and Atmel REB212 Table 10 1 STK600 AT32UC3B1 128 with REB connection details The Atmel RZ600 Kit which is based on Atmel AT32UC3S3256S MCU is also supported on this release See PAL AVR32 AT32UC3A3256 Boards RZ600_2XX e Images need to be flashed using JTAGICE and the 10 pin JTAG connector AIMEL 201 AIMEL e A USB driver providing a virt
136. UOUS MODE o ENABLE TSTAMP 19 Standard or user build configuration switches SUPPORT FFD MAC USER BUILD CONFIG SECURITY ZIP 20 Platform switches o PAL TYPE PAL GENERIC TYPE 8412D AVR 5 12 Atmel AVR2025 BOARD_TYPE SIO_HUB UART0 UART1 USBO ENABLE_TRX_SRAM ENABLE_HIGH_PRIO_TMR EXTERN_EEPROM_AVAILABLE NON BLOCKING SPI F CPU formerly SYSTEM CLOCK MHZ BAUD RATE VENDOR BOARDTYPES VENDOR STACK CONFIG ENABLE ALL TRX IRQS MEGA RF only ENABLE RC OSC CALIBRATION MEGA RF only WATCHDOG o SLEEPING TIMER 21 Transceiver specific switches o TAL TYPE ENABLE TFA TFA BAT MON HIGH DATA RATE SUPPORT CHINESE BAND RSSI TO MAPPING ENABLE FTN PLL CALIBRATION o DISABLE IEEE ADDR CHECK 22 Security switches o SAL TYPE STB ON SAL formerly ENABLE STB o STB ARMCRYPTO 23 Test and Debug switches o DEBUG o TEST HARNESS The following picture shows an example how the various build switches lead to a particular configuration For simplicity reasons only the basic building blocks are included More advance blocks for example TFA or STB have been omitted The used build switches are explained in the subsequent sections coo 9 O O O AIMEL 57 8412D AVR 5 12 6 1 1 58 Global stack switches Atmel AVR2025 AIMEL Figure 6 1 Build configuration example amp
137. UTER nodes can be connected to already started ROUTER nodes A ROUTER node forwards all received data to its parent The ROOT node prints the received data to the UART USB output The ROOT and ROUTER nodes should be mains powered devices The current channel is coded within the application In order to run the application on another channel change the default channel in file main c and re built the application AMEL us 9 2 1 4 1 Introduction 9 2 1 4 2 Requirements 9 2 1 4 3 146 Implementation Atmel AVR2025 AIMEL EEE 9 2 1 4 Promiscuous Mode Demo The application Promiscuous Mode Demo provides a simple network diagnostic tool based on the promiscuous mode as described in IEEE 802 15 4 2006 Section 7 5 6 5 Promiscuous Mode During the build process the switch PROMISCUOUS_MODE is enabled This tool uses as interface to the stack The application and all required build files are located directory Applications MAC Examples Promiscuous Mode Demo The source code of the application can be found in the subdirectory Src This application requires a serial connection for proper demonstration of the promiscuous mode Depending on the available Serial I O interface for each board this can be either UART or USB In order to start the application and to see the output of the application please start a terminal application on your host system and press any key for the application to begin For UC3 3
138. X 3 JE JE JE JE JE JE JE JC Software Version 4 0 Performance test application AT86RF233 ATxmega256A3 Main menu 1 Transceiver Configuration 2 Transceiver State Selection 3 PER Test Configuration 4 Service Functions 5 Start_test gt e Press 1 on UART terminal program to configure the transceiver for PER Measurements Figure 9 12 Transceiver Configuration sub menu Software Version 4 0 Performance test application AT86RF233 ATxmega256A3 Main and Sub menu 1 Transceiver Configuration C IEEE Channel 20 P Channel page 0 R Reduced Power Consumption RPC enabled Receiver Desensitization disabled Tx power 4 dBm 0 0 ACK request true v 8 ta Frame retry enabled false CSMA enabled true Antenna diversity disabled and antenna selected is fl1 H2 Leave sub menu rt_test 5 5 gt AIMEL iet 8412D AVR 5 12 AMEL e Press 2 on UART terminal program to select the state of the transceiver in which user is interested This is useful to evaluate the ultra low power consumption capabilities of transceivers in different states with a specific feature enabled and disabled Figure 9 13 Transceiver State Selection sub menu Software Version 4 0 Performance test a
139. ac_api c lt name gt MAC Src usr_mcps_purge_conf c lt nam MAC Srce usr_mlme_beacon_notify_ind MAC Src usr_mlme_disassociate_conf MMACNSrcNusr mlme disassociate ind MMACNSrcNusr mlme get conf c name MAC Srce usr_mlme_orphan_ind c lt nam MAC Src usr_mlme_poll_conf c lt name MAC Srce usr_mlme_rx_enable_conf c lt MMACNSrcNusr mlme sync loss ind c 8412D AVR 5 12 8412D AVR 5 12 to lt file gt lt name gt MAC_API lt name gt lt file gt lt name gt SPROJ_DIRS lt file gt lt file gt name PROJ DIRSN gt lt file gt lt file gt lt name gt SPROJ_DIRS e gt lt file gt lt file gt name PROJ DIRSN name file file lt name gt PROJ_DIR name gt lt file gt lt file gt lt name gt PROJ_DIRS c name file file lt name gt SPROJ_DIRS lt name gt lt file gt lt file gt lt name gt PROJ_DIR c name file file lt name gt SPROJ_DIRS c lt name gt lt file gt lt file gt lt name gt SPROJ_DIRS lt file gt lt file gt lt name gt PROJ_DIRS e gt lt file gt lt file gt name PROJ DIRS N gt lt file gt AIMEL Atmel 2025 MAC Src mac_api c lt name gt MAC Src usr_mcps_data_conf c lt name MAC Src usr_mcps_purge_conf c lt nam
140. adio extender board REB212 V5 0 2 e Atmel transceiver Atmel AT86RF212 e The REB212 V5 0 is supported on several platforms See PAL AVR32 AT32UC3B1128 Boards REB_5 0 STK600 o See PAL XMEGA ATXMEGA256A3 Boards REB_5_ 0 Figure 10 11 REB212 V5 0 2 with Atmel AT86RF212 2900509 0 12 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 10 4 3 Radio extender boards REB based platforms 10 4 3 1 8412D AVR 5 12 STK600 and REB to STK600 Adapter The Atmel STK600 in conjunction with an REB to STK600 Adapter can be used as a baseboard for an REB to create platforms using AVR 8 bit MCUs such as Atmel ATxmega or Atmel ATmega MCUs It provides eight buttons and LEDs for user interaction It can be used for existing REBs mentioned in Section 10 4 2 The following pictures depict an REB to STK600 Adapter and an STK600 with an REB with REB to STK600 Adapter Figure 10 12 REB to STK600 adapter 10 4 3 2 The CBB conjunction with REB can be used as baseboard for an REB to create platforms using Atmel XMEGA MCUs such as Atmel ATxmega256A3 MCUs It provides currently three LEDs and two buttons for user interaction Currently supported are REB230B V2 3 with Atmel AT86RF230 in conjunction with CBB with ATxmega256A3 MCU REB231 V4 1 1 with Atmel AT86RF231 in conjunction with ATxmega256A3 MCU REB232 V7 1 0 with Atmel AT86RF232 conjuction with CBB with ATxme
141. ain s4 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 4 3 1 Application resource configuration app config h Each application is required to provide its own configuration file app config h usually located in nc directory of the application This configuration file defines the following items e Timers required only within the application domain independent from the timers used within the stack Here the number of application timers and their timer IDs are defined e Large and small buffers required only within the application domain independent from the buffers used within the stack e Additional settings regarding the buffer size of USB or UART buffers e Any other resources as required In order to allow for proper resource configuration for example to calculate the overall number of timers app config h includes the file stack config h which contains resource definitions from the stack domain without the application 2 This file can be adjusted by the end user according to its own needs 4 3 2 Stack resources configuration stack config h IMPORTANT The stack uses its own configuration file stack config h located in directory Include This configuration file defines the following items e 105 of the currently known stack layers PAL up to NWK e Size of large and small buffers e Total number of buffers and timers Depending on the setting of the build switch HIGHEST STACK LAYER the configuration file
142. al cb callback functions The MAC layer residing on top of the TAL has also implemented these callback functions In case these callbacks are not used within the TAL based application the existing stub functions can easily be used All required TAL stub functions are already implemented in the files ta cb c in directory TAL Src So whenever such a callback is not used by the TAL based application simply add the required tal c stub files to your Makefiles or IAR project files 9 43 Example for MAC callbacks 8412D AVR 5 12 The handling of callback stub functions shall be more illustrated by the example of the MAC based application Star Nobeacon When opening the main source file of this application Applications MAC Examples Star Nobeacon Src main c the source code indicates that the following used MAC callback functions are actually used and filled with dedicated application code e usr mlme reset conf Node can perform a MAC reset e usr mlme scan conf Node can perform scanning e usr mlme set conf Node can change PIB attributes e usr mlme start conf Node can set up a new network e usr mlme associate ind Node can accept associations from other nodes e usr mlme comm status ind Required to accept associations from other nodes e usr mcps data ind Node can receive data frames e usr mlme associate conf Node can perform association to other nodes e usr mcps data conf Node can transmit
143. al interrupt number Since most applications do not require all transceiver interrupts this approach has been changed starting from release 2 5 x Both the main transceiver interrupt and the timestamp interrupt are now enabled or disable by using a macro The original parameter specifying the dedicated transceiver interrupt is not used anymore The following macros are provided starting from release 2 5 x Enabling and disabling of the main transceiver interrupt define pal trx irq en ENABLE TRX IRQ define pal trx irq dis DISABLE TRX IRQ Enabling and disabling of the transceiver timestamp interrupt only available if ENABLE TSTAMP is used define pal trx irq en tstamp ENABLE TRX IRQ TSTAMP define pal trx irq dis tstamp DISABLE TRX TSTAMP Please note that the macro above are only available for non single chip transceivers since in single chip transceivers MEGA RF platforms there is no separation between enabling disabling transceiver interrupts at the transceiver and setting clearing the IRQ mask at the MCU Therefore the transceiver interrupts in single chips are enabled disabled by setting the MCU IRQ mask For more information see file PAL Inc pal h and the corresponding pal config h file for each platform implementation TRX IRQ Flag Clearing Clearing the interrupt flag of transceiver interrupts has been changed from release 2 4 x inline void pal t
144. ally required transceiver interrupts for MEGA RF single chips void pal trx init rx end FUNC trx cb void pal trx init tx end FUNC trx cb void pal trx init cca ed FUNC trx cb Initialization of further optional transceiver interrupts for MEGA RF single chips only available if ENABLE ALL TRX IRQS is used void pal trx init ami FUNC trx cb void pal trx init batmon FUNC PTR trx cb void pal trx init awake FUNC trx cb void pal trx init pll lock FUNC trx cb void pal trx init pll unlock FUNC trx cb void pal trx init aes ready FUNC trx cb For more information see file PAL Inc pal h and the corresponding pal irq c file for each platform implementation TRX IRQ Enabling and Disabling Enabling and disabling of transceiver interrupts has been changed from release 2 4 x inline void pal trx enable trx hdlr idx t trx num inline void pal trx disable trx hdlr idx t trx num AIMEL 89 7 2 3 222 Releaes 2 5 x 7 2 3 3 7 2 3 3 1 Releaes 2 4 x 7 2 3 3 2 Heleaes 2 5 x 9 Atmel AVR2025 AIMEL SEE The implementation comprised of exactly one inline function for enabling or disabling transceiver interrupts which required an ID for the actu
145. always included in a build These components are e MAC reset e Direct data transmission and reception e Writing MAC PIB attributes Supplementary components are components that provide standard MAC functionality that might not be required for some applications This is example association indirect data transmission scanning etc These components are also included in the standard build and can be used by any applications so the end application does not have to worry about the inclusion of any functionality On the other hand all supplementary components can be removed from the build in order to drastically reduce footprint For more information about how to add or remove components from the build please see Section 6 2 using build switch MAC_USER_BUILD_CONFIG Figure 4 10 Essential and supplementary MAC components The following sections describe some of these supplementary components especially the more complex ones in more detail AIMEL d 4 4 1 4 4 2 38 Atmel AVR2025 AIMEL amp MAC INDIRECT DATA BASIC This feature is usually required for any node both RFD and FFD that wants to receive indirect data This is for instance helpful if node is usually in power save mode and thus cannot receive direct frames from its parent The node could then periodically wake up and poll its parent for pending data This feature includes the following functionality e Initiation of explicit polling for pending of i
146. ame the AT86RF231 selects one antenna during preamble field detection The REB Rx path is shown in the Figure 9 17 The antenna diversity feature can be tested by doing the PER measurement on conductive medium AIMEL 165 AIMEL Y E Figure 9 17 REB Rx path ANTO AT86RF231 ANT1 9 2 2 1 3 2 4 Read Write Radio Registers The Atmel AT86RF231 provides a register space of 64 8 bit registers used to configure control and monitor the radio transceiver The PER measurement mode gives an option to write read or Dump the content of range of these registers Please note that when writing to a register any reserved bits shall be overwritten only with their reset value NOTE If the nodes are connected each other and registers related to channel selection 0x08 PHY_CC_CCA or channel page selection 0x0C TRX_CTRL_2 or transmission power setting 0Ox05 PHY_TX_PWR are changed the changes will be reverted to the old setting to prevent loss of connection with remote node To test these registers use the PER measurement mode with Peer Search aborted 9 2 2 1 3 2 5 Debug message support for PER Measurement mode Debug support is enabled on the receiver node which need not be connected to the PC If UART Terminal is connected debug logs are printed on the terminal as shown in Figure 9 188 Figure 9 188 Debug prints on reflector Frames Rec on air PER Measurement mode Peer device found Starting PER Measurement mode as Re
147. and the proper Programming Mode and Target Settings for example JTAG mode Figure 8 5 Atmel AVR Studio 4 JTAGICE dialog with Main tab JTAGICE mkII in JTAG mode with ATmega1281 4 E oj xj Main Program Fuses LockBits Advanced Hw Settings HW Info Auto Device and Signature Bytes A 281 Erase Device Signature not read Read Signature Programming Mode and Target Settings JTAG mode z Settings ISP Frequency Daisy Chain Disabled Changes to daisy chain settings are only valid from the next time the programming dialog is opened Detecting on Auto JTAGICE mkll found on USB Getting revisions Getting revisions OK zi e Select the Fuses tab Within this tab make sure that the EESAVE fuse is selected This preserves the EEPROM through the Chip Erase cycle Figure 8 6 AVR Studio 4 JTAGICE mkll dialog with Fuses tab Main Program Fuses LockBits Advanced Hw Settings HW Info Auto Fuse Value BODLEVEL Brown out detection disabled OCDEN JTAGEN SPIEN v wDTO 5 BOU Boot Flash size 4096 words start address F 000 v BOOTRST CKDIV8 CKOUT L SUT CKSEL Int RC Osc Start up time 6 CK 65 ms v EXTENDED xFF HIGH 0x91 LOW OxE2 Auto read Smart warnings Verify after programming Program Verify Setting device paramet
148. application in order to allow for the inclusion of sio handler h Add the following include path by changing AMEL 2s 8412D AVR 5 12 to AMEL lt name gt newCCIncludePaths lt name gt lt state gt PROJ_DIR Inc lt state gt lt state gt PROJ_DIR Include lt state gt lt name gt newCCIncludePaths lt name gt lt state gt PROJ_DIRS Inc lt state gt lt state gt SPROJ_DIRS Helper_Files SIO_Support Inc lt state gt lt state gt SPROJ_DIRS Include lt state gt e Update the used and or unused list of source files Add the following callback stub files in file Promiscuous_Mode_Demo ewp for more information about MAC stub functions see Section 9 4 lt name gt MAC_API lt name gt lt file gt name PROJ DIRS N N file file name PROJ DIRS N N e file file name PROJ DIRS N N c name file file name PROJ DIRS N N c name file file lt name gt SPROJ_DIRS c lt name gt lt file gt lt file gt lt name gt SPROJ_DIRS lt file gt lt file gt lt name gt SPROJ_DIRS e gt lt file gt lt file gt name PROJ DIRS N N gt lt file gt lt file gt lt name gt SPROJ_DIR name gt lt file gt lt file gt lt name gt SPROJ_DIRS name gt 230 Atmel AVR2025 MAC Src m
149. ar TAL implementation e The capacity of the TAL Incoming Frame Queue If the build switch HIGHEST_STACK_LAYER is set to TAL the proper tal_config h file depending on build switch TAL_TYPE is directly included into file stack_config h since there are no further stack layers defined These files must not be changed by the end user MAC resource configuration mac_config h IMPORTANT The MAC layer uses its own configuration file mac_config h located in directory MAC Inc This configuration file defines the following items e Timers and their IDs used within the MAC layer based on the current build configuration e The capacity of certain MAC specific queues If the build switch HIGHEST STACK LAYER is set to MAC mac config h is directly included into file stack config h since there is no upper stack layer defined This file must not be changed by the end user NWK resource configuration nwk config h IMPORTANT Once network layer NWK is provided as part of the stack on top to the MAC the network layer uses its own configuration file nwk config h located in directory NWK Inc If the build switch HIGHEST STACK LAYER is set to NWK nwk config h is directly included into file stack config h since there is no upper stack layer defined This file must not be changed by the end user Build configuration file mac build config h IMPORTANT File mac build config h located in directory Include defines the MAC feature
150. ard Data msdu msduHandle TxOptions all 802 15 4 2006 for request in hex and confirm details Data Refer section 7 1 1 4 and 7 1 1 5 of IEEE Standard PURGE purge PURGE lt lt msdu handle in hex 802 15 4 2006 for request request 5 and confirm details ASSOC LogicalChannel Refer section 7 1 3 1 and Send ChannelPage 7 1 3 4 of IEEE Standard ASSOC Associatio CoordAddrMode CoordPANId Coo dn 802 15 4 2006 for request n Request rdAddress CapabilityInformation and confirm details all in hex gt ASSOCRS Associatio 4ASSOCRSP DeviceAddr Refer section 7 1 3 3 of P AssocShortAddr status hex Standard 802 15 4 Response 2006 for details Disassoci DASSOC lt DeviceAddrMode Devi 7 1 4 3 of IEEE Standard DASSOC ate cePANId DeviceAddress Disassoci 802 15 4 2006 for request Request ateReason TxlIndirect all in hex 4 and confirm details Refer section 7 1 6 1 and Get or DM 7 1 6 2 of IEEE Standard lt gt read PIB PIB lt MAC PIB identifier in Hex 802 15 4 2006 for request and confirm details Refer section 7 1 8 2 of ORPHRSP 2 IEEE Standard 802 15 4 esponse ress AssociatedMember gt 2006 for details Refer section 7 1 9 1 and MAC 7 1 9 2 of IEEE Standard reset 802 15 4 2006 for request and confirm details Refer section 7 1 10 1 and RXEN RX RXEN lt DeferPermit RxOnTime R 7 1 10 2 of IEEE Sta
151. are supported 4 49 MAC ORPHAN INDICATION RESPONSE This feature is a typical FFD feature that allows a node to process a received orphan notification frame from any of its children initiated via an orphan scan request at the children and process them properly In response a realignment frame may be returned AIMEL a 8412D AVR 5 12 AIMEL Y E Figure 4 13 Provided functionality for MAC ORPHAN INDICATION RESPONSE and SCAN ORPHAN REQUEST CONFIRM orphan scan procedure Node using Node FFD using MAC SCAN ORPHAN MAC ORPHAN REQUEST CONFIRM INDICATION RESPONSE App MAC MAC App wpan mlme scan req Orphan scan Orphan Notification usr mlme orphan ind wpan orphan resp Standard Orphan Scan Procedure Coordinator Realignment Frame usr mlme scan conf 4 4 10 MAC START REQUEST CONFIRM This feature is a typical FFD feature that allows a node to start a new PAN network by means of using functions wpan mlme start req usr mlme start conf Depending on the setting of BEACON SUPPORT this can be either only a non beacon enabled network or also a beacon enabled network Consequently this also enables the ability of the node to e Transmitting beacon frames in case beacon enabled networks are supported e Respond to beacon request frames active scan by another node with proper beacon frames e Perform network realignment and transmit coordinator realignm
152. ation code in more detail 91 1 Implementation of the coordinator The source code of the coordinator is located in Applications MAC_Examples App_1_Nobeacon_Application Coordinator Src main c and the header file in Applications MAC_Examples App_1_Nobeacon_Application Coordinator Inc app_con fig h Platform related project Makefiles for GCC AVR AVR32 and ARM AVR Studio and IAR Workbench are located in the corresponding subdirectories Applications MAC_Examples App_1_Nobeacon_Application Coordinator lt platform gt 12 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 The example application can be opened using the Atmel AVR Studio the IAR EWW or any other editor To open the example application project from the AVR Studio select the Coordinator aps or from the IAR EWW select the file Coordinator eww If the AVR Studio is used the source code can be compiled from the menu Build gt Rebuild All If the IAR EWW is used the source code can be compiled from the menu Project gt Rebuild All The main function of the coordinator performs the following steps Initialize the MAC layer and its underlying layers like PAL TAL BMM if wpan init SUCCESS Stay here we need a valid IEEE address Check kit documentation how to create an IEEE address and store it to the EEPROM FJ pal alert Calibrate MCU s RC oscillator pal calibrate ro os
153. ations MAC_I AT86RF231 ATXMEGA256A3 RI NSrcNnain c c name Src main c lt name gt Helper_Files SIO_Support Src sio_hand se ea Files STO Support IAR Support Examples Promiscuous_Mode_Demo EB 4 1 CBB GCC In order to support the target application the file Promiscuous Mode Demo aps needs to be updated as follows e Replace all occurrences of the name of base application with the target application for example replace Star with Promiscuous Mode Demo All other items are already within the external Makefiles that are called during the build process Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 11 6 Customizing the platform clock speed 11 6 1 Customizing Atmel ATxmega128A1 platforms The following section describes how a specific ATxmega128A1 based platform can be customized to run at various clock speeds The default clock speed for these platforms is currently 16MHz but user may want to adapt this to their specific needs Due to the platform abstraction implemented within the MAC Software package this is very simple and straightforward 11 6 1 1 Introduction to the 128 1 platform software design The system clock that is the MCU clock frequency controls a variety of blocks within the MCU The MCU for the Atmel ATxmega128A1 platform is always clocked by the 32MHz internal RC oscillator in conjunction with the corresponding System Clock Prescaler
154. automatic frame retries e Frame reception unit including automatic acknowledgement handling e State machine e TAL PIB storage e CSMA module e Energy detect scan AMEL 2 1 3 core layer MCL Atmel AVR2025 AIMEL e Power management e Interrupt handling e Initialization and reset The Transceiver Abstraction Layer uses the services of the Platform Abstraction Layer for its operation The Frame Transmission Unit generates and transmits the frames using PAL functionality The Frame Reception Unit reads uploads the incoming frames and pushes them into the TAL Incoming Frame Queue The TAL handles the Incoming Frame Queue and invokes the receive callback function of the MCL The operation of the TAL is controlled by the TAL state machine The CSMA CA module is used for channel access The PIB attributes related to the TAL are stored in the TAL PIB storage amp The function prototypes for the TAL features are provided file TAL Inc tal h The implementation of a TAL is located in a separate subdirectory for each transceiver The MAC Core Layer MCL abstracts and implements IEEE 802 15 4 2006 compliant behavior for non beacon enabled and beacon enabled network support The implemented building blocks are e MAC Dispatcher e MAC Data Service e MAC Management Service like start association scan poll etc e MAC Beacon Manager e MAC Incoming Frame Processor e MAC PIB Module e MAC API e MAC stack
155. be part of the stack and residing on top of the MAC layer a number of resources are used differently compared to an application on top of the MAC Example Reading of PIB attributes residing in TAL layer If the HIGHEST_STACK_LAYER is MAC HIGHEST_STACK_LAYER MAC the function tal_pib_get in file tal_pib c is not included in the binary because the MAC reads all PIB attributes residing in TAL directly by accessing the global variables On the other hand if the HIGHEST_STACK_LAYER is TAL HIGHEST_STACK_LAYER 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 TAL this function is available because an application being not part of the stack shall not access global variables of the stack directly Conclusion If the application sits on top of the MAC layer this build switch shall be set to HIGHEST STACK LAYER If the application sits on top of the TAL layer this build switch shall be set to HIGHEST STACK LAYER TAL If the application sits on top of the PAL layer this build switch shall be set to HIGHEST STACK LAYER PAL Usage in Makefiles CFLAGS DHIGHEST STACK LAYER MAC or CFLAGS DHIGHEST STACK LAYER TAL Usage in IAR ewp files HIGHEST STACK LAYER MAC or HIGHEST STACK LAYER TAL For more information check file Include stack config h This shows how the timer resources are used and included in the end applicatio
156. beacon example the application is residing on top of the MAC so HIGHEST STACK LAYER needs to be MAC If this is not properly set this leads to undefined behavior during the build process or during application usage 11 4 8 3 Step Update the GCC Makefile The Makefile of the target platform which was duplicated from the base platform is now located in the GCC directory of the target platform that is Applications MAC Examples Star Nobeacon AT86RF231 ATXMEGA256A3 REB 4 1 CBB GCC In order to support the target platform this Makefile needs to be updated as follows e Update the build specific properties from AMEL 223 8412D AVR 5 12 AIMEL puu HM _TAL_TYPE AT86RF231 PAL TYPE ATXMEGA128A1 PAL GENERIC TYPE XMEGA BOARD TYPE REB 4 1 CBB to TAL AT86RF231 PAL TYPE ATXMEGA256A3 PAL GENERIC XMEGA BOARD TYPE REB 4 1 CBB In the described example only the PAL TYPE needs to be changed Make sure that the PAL TYPE that is the variable in the Makefile is set identical to the target directory in the PAL that was created for the new platform see Sections 11 4 2 2 and 11 4 2 4 since the PAL TYPE is used within directory names e Update the MCU type from MCU atxmegal28al to MCU atxmega256a3 e Updating the SIO channel for examp
157. building the application the subdirectory IAR Exe contains either an a90 file in case the Release configuration was selected or a d90 file in case a Debug configuration was selected Both binaries can be downloaded onto the hardware see Section 8 3 The Release configuration binary a90 file can both be downloaded using IAR Embedded Workbench directly or AVR Studio The Debug configuration binary d90 file can only be downloaded using IAR Workbench and can be debugged using IAR C Spy In case is it desired to create a binary with IAR Embedded Workbench which contains AVR Studio Debug information and can thus directly be downloaded and debugged using AVR Studio the following changes need to be done with IAR Embedded Workbench o Select the Debug configuration Open the Options dialog Select Category Linker Select tab Output Change Format from Debug information for C Spy to Other Select ubrof 8 forced as Output format Select None as Format variant Rebuild the application The generated binary can now contains debug information that can be used directly within AVR Studio O O 0 0 0 8 2 5 Using IAR AVR32 Embedded Workbench Each application can be rebuilt using the IAR AVR32 Embedded Workbench directly Please follow the procedure as described 94 Atmel AVR2025 Change to the directory where the IAR Embedded Workbench workspace file eww file for the desired platf
158. by the MAC These are setting the MAC PIB attribute macRxOnWhenldle and the MAC primitive MLME_RX_ENABLE request 5 3 1 MAC PIB attribute macRxOnWhenldle Setting the MAC PIB attribute to a specific value controls the handling of MAC power management Whenever a transaction within the MAC has finished for example transmitting a frame setting of PIB attributes residing within the transceiver etc the MAC checks this PIB attribute If the corresponding value is False the radio enters SLEEP mode again otherwise the transceiver stays awake Any node will always enter SLEEP mode after each finished transition since the PIB attribute macRxOnWhenldle is False as default If this behavior shall be altered especially for Coordinators or PAN Coordinators the application needs to change the value of macRxOnWhenldle to True after whenever this shall be applied The current value of the MAC PIB attribute macRxOnWhenldle can be altered by calling function wpan mlme set req with the appropriate value see file main c of example in Section 9 2 1 2 Switch receiver on to receive frame wpan mlme set req macRxOnWhenIdle true or Switch receiver off wpan_mlme_set_req macRxOnWhenIdle false Please note that the transceiver will be immediately enabled or disabled 5 3 2 Handling the receiver with wpan_rx_enable_req While setting of the PIB attribute macRxOnWhenldle is a more globally or statically applied
159. c Initialize LEDs pal led init pal led LED 0 LED ON indicating application is started pal led LED 1 LED OFF indicating network is started pal led LED 2 LED OFF indicating data reception Enable the global interrupts pal global enable Initiate a reset of the MAC layer wpan mlme reset req true Run the main loop while 1 wpan_task Once the main loop is running the MAC layer will execute the previously requested reset and call the implementation of usr mlme reset conf callback function Depending on the returned status information the program continues either with the request to set the short address of the coordinator or with a new reset request void usr mlme reset conf uint8 t status if status MAC_SUCCESS Set the short address of this node AMEL I 8412D AVR 5 12 134 AMEL uint8_t short_addr 2 short_addr 0 uint8_t COORD_SHORT_ADDR short_addr 1 uint8_t COORD_SHORT_ADDR gt gt 8 wpan_mlme_set_req macShortAddress short addr else something went wrong restart wpan mlme reset req true The request to set the short address of the coordinator will be processed once the control flow of the application enters the main loop again The MAC layer will call the implementation of usr mlme set conf void usr mlme set conf uint8 t status uint8 t PIBAttribute
160. c properties such as TAL PAL TYPE PAL_GENERIC_TYPE _ o The MCU type The selected SIO channel in case stream I O is used within the particular application f the build switch SIO is set in the Makefile DSIO_HUB also one of the following currently supported SIO channels needs to be enabled as well DUARTO DUART1 DUSBO f the build switch SIO HUB is not set no further SIO channel needs to be defined Other specific build and link options if required Update the IAR project files Usually all required changes for the IAR Workbench are to done in the ewp file This includes changing of the paths for includes and source files referring to the proper MCU Also the proper MCU needs to be selected within the options for this project Other changes may include updating the proper SIO channel etc Update the AVR Studio Project files aps files This includes changing of the paths for includes and source files referring to the proper MCU All other items are already within the external Makefiles that are called during the build process 8412D AVR 5 12 Atmel AVR2025 11 4 3 1 Step 1 Identify the application to be ported to the target platform The MAC application Star_Nobeacon shall be enabled on the target platform ATxmega256A3 MCU based on REB231ED V4 1 1 on top of a CBB board For more information about the platform bring up for this target platform see the previous sections The MAC
161. c to the list of source and object files in GCC Makefiles e g lt file gt lt name gt SPROJ_DIRS Helper_Files SIO_Support Srce sio_handler c lt name gt lt file gt lt file gt lt name gt AMEL s 8412D AVR 5 12 AIMEL SPROJ_DIRS Helper_Files SIO_Support IAR_Support write c amp lt name gt lt file gt 9 4 Handling of callback stubs 9 4 1 180 MAC callbacks Atmel AVR2025 The MAC stack must support asynchronous operation by all layers for instance to allow for callbacks from lower layers back to higher layers without blocking the control flow This is required to implement the request confirm or indication response primitive handling A common way of implementing asynchrony operation by lower layers is the installation of callback functions which are called a lower layer but actually implemented in the higher layer Callbacks are required by both the TAL and the MAC layer The MAC Core layer MCL requires the following callback functions e usr data conf e usr data ind e usr mcps purge conf e usr mlme associate conf e usr mlme associate ind e usr mlme beacon notify ind e usr mlme comm status ind e usr mlme disassociate conf e usr mlme disassociate ind e usr mlme get conf e usr mlme orphan ind e usr mlme poll conf e usr mlme reset conf e usr mlme rx enable conf e usr mlme scan conf e usr mlme set conf e usr mlme start conf
162. cast with ACK is used Since the boards are not factory connected they are field connected by the method described in the Section Error Reference source not found Please refer the Atmel Transceiver datasheet for expected sensitivity 8412D AVR 5 12 9 2 2 1 3 2 2 TX Power handling Atmel AVR2025 The Atmel AT86RF231 provides the programmable TX output power from 17dBm to 3dBm The output power of the transmitter can be controlled over a range of 20 dB Default TX power is set to 3dBm The PER measurement mode gives an option to configure the TX out power in the form of absolute power in dBm or TX PWR register value If the AT86RF231 is connected with front end module e g REB231FE2 EK kit TX power can be extended till 21dBm The control of an external RF front end is done via digital control pins DIG3 DIG4 The function of this pin pair is enabled with register bit PA EXT EN register 0x04 TRX CTRL 1 While the transmitter is turned off pin 1 DIG3 is set to low level and pin 2 DIG4 to high level If the radio transceiver starts to transmit the two pins change the polarity This differential pin pair can be used to control PA LNA and RF switches If the AT86RF231 is not in a receive or transmit state register bit PA EXT EN register 0x04 TRX CTRL 1 is disabled to reduce the power consumption or avoid leakage current of external RF switches and other building blocks especially during SLEEP state If register bits PA EXT
163. cess by default amp 9 22 1 Performance Test EVK The TAL example Performance Test EVK is a terminal based application for Range measurement and Packet Error Rate measurement The application is targeted to demonstrate the capabilities of Atmel Transceivers such as e Range of the Transceiver for peer to peer communication Range measurement e Robust Link Quality e Packet Error Rate measurement PER e Evaluate features as with UART connection only o Antenna Diversity Rx Sensitivity CSMA CA Transmission Read Write Transceiver Registers TX Power of radio Continuous transmit test modes Reduced Power consumption mode O O 0 0 The different states of the Performance Test EVK application are explained and also the state diagram is shown in Figure 9 5 Each state is represented by a number in the state diagram 1 INIT e Initializes all underlying layers like TAL PAL and Resource Management Board Identification if required e Initializes all board utilities like LEDs and buttons etc 2 WAIT_FOR_EVENT e Initializes the TAL PIB attributes PAN Id with OxCAFE physical channel with on both the nodes and their radios kept in receive state e Continuously search for the user events like key press or character on UART or a valid frame Peer Request received on air 3 PEER_SEARCH_RANGE_TX e Enters after key press event is detected from user Peer Search process in Range Measurement mode as
164. ch on the other node e LED 0 indicates that the node has started properly Flashing of LED 1 indicates that the node is scanning its environment Scanning is again done three times on each available channel depending on the radio type f a proper network is discovered the node joins the existing network indicates a successful association by switching on LED 1 and goes both MCU and transceiver to sleep e Once the button is pressed the End Device wake up again and send data frames to the PAN Coordinator every 200ms If the packet is acknowledged by the PAN Coordinator the LED 2 is flashing e If the button is released the node goes to full sleep again e The current channel is coded within the application In order to run the application on another channel change the default channel in file main c and re built the application e Currently only 2 devices are allowed to associate to the PAN Coordinator This can be easily extended by increasing the define MAX_NUMBER_OF_DEVICES Serial_AT_Interface The example application enables the use of AT command set with Atmel AVR2025 stack so that the host application can communicate with 802 15 4 network The AT command set consists of a series of short text strings which combine together to produce complete commands for operations such as dialing hanging up and changing the parameters of the connection A set of basic commands and proprietary extended commands have been defined for the sa
165. cific implementations Each transceiver implementation inside the TAL has its own Inc directories for example TAL AT86RF231 Inc or each microcontroller family and each single microcontroller have their own Inc directories for example PAL XMEGA Generic Inc or PAL AVR ATMEGA1281 Inc Generally the following header file naming conventions are followed 6 layer h o This file contains global information that forms the layer or building block API such as function prototypes global variables global macros defines type definitions etc o Each upper layer that wants to use services from a lower layer needs to include this file o Examples mac h tal h pal h stb h sal h tfa h 7 layer internal h o This file contains stack internal information only No other layer or building block shall include such a file o Examples MAC Inc mac internal h TAL AT86RF212 Inc tal internal h PAL AVR Generic Inc pal internal h 8 layer types h o This file contains the definitions for the supported types of each category that can be used with Makefiles or project files to differentiate between the various implementations and make sure that the proper code is included o Whenever a new type of this category is introduced for example a new hardware board type the corresponding file needs to be updated o Examples tal types h pal types h sal types h pal boardtypes h vendor boardtypes h 9 layer config h o This file contains defin
166. ck The application and all required build files are located directory Applications MAC_Examples Nobeacon_Application The source code of the AMEL a 8412D AVR 5 12 9 2 1 1 2 9 2 1 1 3 9 2 1 1 4 9 2 1 2 9 2 1 2 1 142 Requirements Implementation Limitations Introduction Atmel AVR2025 AIMEL SEE application can be found in the subdirectories Coordinator Src or Device Src The common source code for handling Serial I O can be found in the subdirectory Src The application requires up to three LEDs on the board in order to indicate the proper working status A sniffer is suggested in order to check frame transmission between the nodes For further status information this application requires a serial connection Depending on the available Serial I O interface for each board this can be either UART or USB In order to start the application and to see the output of the application please start a terminal application on your host system and press any key for the application to begin The PAN Coordinator starts a PAN at channel DEFAULT CHANNEL with the PAN ID DEFAULT PAN ID The Device scans for this network and associates to the PAN Coordinator Once the device is associated it uses a timer that fires every 5 seconds to poll for pending data at the coordinator by means of transmitting a data request frame to the coordinator On the other hand the coordinator every 5 seconds queues a dummy data
167. coming Frame Processor receives frames from the TAL and depending on the type of the frame passes it to the MAC Data Service or the MAC Management Service for further processing The MAC PIB attributes are stored in the MAC PIB and are accessed by the MAC Data Service the MAC Management Service and the Beacon Manager PIB attributes that are used by the TAL module are stored within the TAL The Beacon Manager generates the beacon frames which are transmitted using the TAL The beacon manager is also responsible for beacon reception at the start of a superframe and its synchronization The received beacons are processed based on the current state of the MAC and if required indications or notifications are given to the MAC API An application can use any layer as desired depending on the required functionality An application that is based on a standard IEEE 802 15 4 MAC uses the MAC API based on the stack built by PAL TAL and MCL Another application for example a simple data pump may want to use only the basic channel access mechanism automatic handling of Acknowledgments etc In this case potentially only the TAL API based on a stack consisting of PAL and TAL will be used A very simple application may even only use the PAL API based on the PAL layer What kind of stack is AMEL s AIMEL actually being used by the application is always depending on the end user needs and the available resources amp In order to specify which
168. con Src main c i File Project Build Edit View Tools Debug Window Help iD id BW 64 4 1 Trace Disabled 2x Q0 demo k Ye gun Processor i Name Value Obrief Main 6 comparator E Program Counter 0003 d r Name Value EJ Stack Pointer 0x21FD oi aaia onid 3 19A4D CONVERTER pointer 0 0896 Initializ 4 D anao G_COMPARA Y pointer 0x21FF gt if wpan_ini p 4 1 Name Address Value Bits 4 aver Gcc Processor Program 30996 bytes 23 6 Full text data bootloader D 13 25 36 73 83 74 75 38 009070778 Data 1686 bytes 20 6 Full 000010 FF FF FF FF FF FF FF FF data bss noinit 000018 FF FF FF FF FF FF FF FF 000020 FF FF FF FF FF FF FF FF 000028 FF FF FF FF FF FF FF FF 4 7 000030 FF FF FF FF FF FF FF FF 1 000038 FF FF FF FF FF FF FF FF ElBuild message Find in Files Lg Breskpoints and Tracepoints YR 1281 JTAGICE mkII Auto Stopped e Ln 111 Col 1 CAP NUM C Using AVR Studio 4 after command line build of application When the application has been built using external Makefiles from the command line the application can be started following the steps described below 8 3 2 1 Starting the release build The release b
169. ctory PAL ARMT7 AT91SAM7X256 Boards REB 2 REX ARM REV 2 and rename it to directory PAL ARMT7 AT91SAM7X256 Boards REB 4 0 2 REX ARM REV 3 Your directory PAL ARM7 AT91SAM7X256 Boards now contains the following entries REB 2 3 REX ARM REV 2 REB 4 0 2 REX ARM REV 3 The directory REB 4 0 2 REX ARM REV 3 currently contains the identical code from the directory REB 2 3 REX ARM REV 2 from the base platform It comprises of the following files pal board c pal irq c pal config h 11 8 2 5 Step 5 Rename all occurrences of base platform to target platform Within the entire directory AMEL a 8412D AVR 5 12 AIMEL PAL ARM7 AT91SAM7X256 Boards REB_4 0 2 REX_ARM_REV_3 all occurrences of the string REB 2 3 REX ARM REV 2 are searched and replaced by the target Platform REB 4 0 2 REX ARM REV 3 In this example this needs to be done the following files amp pal_board c e pal e pal config h 11 3 2 6 Step 6 File pal irq c This file contains functions to initialize enable disable and install handler for the transceiver interrupts In this porting example it is a file dedicated to a board utilizing the transceiver Atmel AT86RF231 but is derived from a board utilizing the transceiver Atmel AT86RF230B While the AT86RF230B provides only one transceiver interrupt the AT86RF231 provides usually two transceivers interrupt This approach is followed
170. d in the standard In order to have a clear design separation between the standard features and additional features a new software block has been introduced TFA Transceiver Feature Access If the TFA shall be used within the application a special build switch needs to be set in order to get access to these specific features see Section 6 1 4 2 2 2 4 2 Features The following features have been implemented within the TFA e Additional PIB attribute handling o Function for reading or writing special PIB attributes not defined within 4 are provided o Example Transceiver Rx Sensitivity see the Data Sheets of the transceivers for more information about the Transceiver Rx Sensitivity e Single CCA o Based on 4 a function is implemented to initiate a CCA request to check for the current state of the channel o result is either PHY IDLE or PHY BUSY o Allows for CCA measurements independent from the MAC based CSMA CA algorithm AIMEL d Eu 0 AIMEL e Single ED measurement o Based on 4 a function is implemented to initiate a single ED measurement separate from the cycle of a full ED scanning e Reading transceiver s supply voltage o The battery or supply voltage reading can be enabled separately without enabling the entire TFA If only the reading function tfa_get_batmon_voltage of the supply voltage is needed the build switch TFA_BAT_MON needs to be set See also Section 6 1 4 2 for further inf
171. done in this file AMEL m 8412D AVR 5 12 AIMEL amp 11 4 3 Bring up of an existing application on the target platform The task of bringing up an already existing application on a new target platform is explained by the example of a platform based on the Atmel ATxmega256A3 The same steps are to be performed for all other MCUs that shall be used Each step is first described generally and then specifically described in detail for porting the existing code to the Atmel ATxmega256A3 Please note that the opposite task of bringing up a new application for an existing platform is explained in Section 11 5 e Step 1 e Step 2 e Step 3 e Step 4 e Step 5 222 Atmel AVR2025 Identify the application that shall be ported This requires that all peripherals required by the application need to be supported such as SIO support LEDs buttons For more information about the requirements of existing applications see Section 9 2 Identify the best matching base platform already supported within this application Duplicate the directory of the base platform within this application and rename it according to your target platform Update the GCC Makefile Independent from whether the target application is built from command line using make or Atmel AVR Studio project file APS files which also use external Makefiles themselves the Makefile needs to be updated to cope with the target platform This includes o Build specifi
172. dy existing board type base board within the directory of the target MCU that best fits the new board to be supported target board Each supported board with the newly created directory contains board directory including pal boardtypes h and least one specific board directory Select the base board for the target board Other boards within target board directory that are obsolete may be removed e Step 6 Rename the target board optional Atmel AVR2025 In case the selected target board shall to be renamed file pal_boardtypes h with in target MCU directory needs to be updated 8412D AVR 5 12 Atmel AVR2025 with the new board type Also the target directory needs to be renamed matching the new board type For more information see Section 11 3 e Step 7 Rename all occurrences of base MCU to target MCU 11 4 1 2 Phase2 Actual porting to target platform This section describes the actual porting phase once the directory and file structure of the target platform has been established The directory of the target platform contains currently three directories same as for the base platform e Boards e Inc e Src Within the next phase all hardware resources need to be adjusted from the base platform to fit the resources of the target platform such as timers IRQs ports LEDs buttons ports and registers for SIO support etc This is explained in the subsequent steps The main changes fo
173. e the corresponding function for handling this message is called mcps data in file MAC Src mac callback wrapper c Here the structure of type data ind t is overlaid again over the actual buffer body pmsg mcps data ind t BMM BUFFER POINTER buffer t m Finally the corresponding parameters of the callback function inside the application function mcps data ind are filled by the corresponding members of the mcps data ind t structure and the buffer is freed again by calling function bmm buffer free The buffer is now free for further usage Through all steps from 1 to 3 the same buffer is used 4 2 2 Application on top of TAL While an application on top of the MAC API is logically decoupled from the actual buffer handling inside the entire stack such an application does neither need to allocate nor free a buffer an application on top of the TAL requires more interworking Atmel AVR2025 8412D AVR 5 12 IMPORTANT 8412D AVR 5 12 Atmel AVR2025 with the stack in regards of buffer handling and internal frame handling structures This is explained in the subsequent section As an example for application residing on top of the TAL HIGHEST_STACK_LAYER TAL is described in Section 9 2 2 1 4 2 2 1 Frame transmission buffer handling using TAL API The following section describes how buffers are used inside the stack during the procedure of the transmission of a
174. e AVR XMEGA microcontroller family Usage in IAR ewp files PAL GENERIC TYPE AVR selects the Atmel 8 bit AVR ATmega microcontroller family 8412D AVR 5 12 Atmel AVR2025 6 1 32 PAL TYPE To build the proper code the compiler needs to know which microcontroller is used Also depending on the microcontroller specific code portions needs to be used within the build since for example some microcontrollers do not support USB while others do The type of microcontroller is specified by the build switch PAL TYPE Examples of currently supported microcontrollers are e Atmel 1281 Atmel ATxmega128A1 e Atmel ATxmega256A3 e Atmel AT91SAM3S4C e Atmel AT32UC3A3256S e Atmel AT32UC3L064 For more information check file PAL Inc pal_types h Usage in Makefiles CFLAGS DPAL TYPE ATXMEGA256A3 selects the ATxmega256A3 microcontroller Usage in IAR ewp files PAL_TYPE ATXMEGA256A3 selects the ATxmega256A3 microcontroller 6 1 3 3 BOARD TYPE Since the platform may vary between different boards even for one specific microcontroller certain functionality within a specific PAL has to be implemented depending on the type of board used The supported board types for one microcontroller can be found in file pal boardtypes h for each MCU for example for Atmel ATmega1281 this file is located in directory PAL AVR ATMEGA1281 Boards If a new board is designed whic
175. e definitions debug macros etc It needs to be updated to match the requirements of the target board see example in Section 11 3 2 8 11 3 2 Example implementation of PAL for Atmel AT91SAM7X256 based platform This section describes the porting activities explained in the previous sections in general more specifically for the example of porting an existing software package based on the AT91SAM7X256 ARM 7 MCU to the new target board Atmel AT91SAM7X EK with Radio Extender board REB231 V4 0 on REX ARM adapter Revision REB 4 0 2 REX ARM REV 3 in order to support the Atmel AT86RF231 transceiver on this MCU 11 3 2 1 Step 1 Identify the MCU of the new board The target board is based on the MCU AT91SAM7X256 It is a member of the ARM7 family Therefore new code of the target board is based the PAL_GENERIC_TYPE ARM7 and PAL_TYPE AT91SAM7X256 11 3 2 2 Step 2 Add the new board to file pal_boardtypes h To add support for the target board AT91SAM7X EK with Radio Extender board REB231 V4 0 REX_ARM adapter Revision 3 open file PAL ARM7 AT91SAM7X256 Boards pal_boardtypes h and add the target board definition to the proper section of this file Since the REB 4 0 2 REX ARM REV 3 is based on the transceiver Atmel AT86RF231 the new target board shall be added to the section Boards for AT86RF231 where all AT86RF231 based boards for this MCU are listed Use a not existing unique value for the target board Make sure that 28
176. eceived from Transmitter e Receives the packets from other node and acknowledges by an 802 15 4 protocol ACK each packet received e Enters from RANGE TEST TX 8 state on button press 10PER TEST INITIATOR e PER Measurement mode as Transmitter e Enters after successful Peer Search on character received on UART event e Node shall go into sub states like TX PER TEST FRAMES SENT WAIT FOR TEST RES SET PARAMETER IDENTIFY PEER DIVERSITY SET REQ DIVERSITY STATUS CRC SET REQ WAIT CRC STATUS REQ WAIT CONTINOUS TX MODE RESULT RSP DIV STAT RSP etc 11 PER TEST RECEPTOR e PER Measurement mode as Reflector e Enters after successful Peer Search on a valid frame Peer Request received from Transmitter e Node shall respond back for the cmds sent from different states in Transmitter node 9 SINGLE NODE TESTS e Transmitter node in single node operation e Enters on user abort or Peer Search time out i e No Peer Response is received during the Peer Search process e Node shall go into sub states similar but applicable states in PER TEST INITIATOR 10 by considering the Peer Search status as failed AMEL 157 8412D AVR 5 12 AMEL Figure 9 5 Performance Test EVK Application State Diagram POWER_ON Successful board initialization 2 Peer Req received Peer Req received air in Range mode WAIT_FOR_EVENT air in PER mode Key press detected Character on UART Peer Search Peer
177. ecially if the three standard LEDs are blinking fast check first the proper IEEE address setting see Section 8 3 1 or Section 8 3 2 2 or whether the proper binary has been selected selection of transceiver type microcontroller type and board type 8 3 3 2 Starting the Debug Build The debug build can simply be started as follows e Open AVR Studio 5 by double clicking on the corresponding AVR Studio 5 Solution file avrsin file Select Debug configuration from the Configuration Manager 16 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 8 20 AVR Studio 5 Build gt Configuratoin Manager gt Debug 21 Active solution configuration Active solution platform Project contexts check the project configurations to build or deploy e Rebuild the application in AVR Studio 5 e Open Project Properties Figure 8 21 AVR Studio 5 Project gt Properties Promiscuous_Mode_Demo Build Build Events Configuration Active Debug Platform Active AVR E Toolchain Memory Device Debuaging Use External Makefile GCC Makefile_ Debug Browse 1 Target name must equal project name 2 Build support requires all and clean targets 3 Makefile and target must exist in the same folder Advanced m Build Artifact Artifact Type Artifact Name Generate Files Executable Promiscuous Mode Demo elf
178. ect the desired workspace Release or Debug and Rebuild the entire application in IAR Embedded Workbench e After building the application the subdirectory IAR Exe contains either a binary file or an elf file in case the Release or Debug configuration was selected The binaries can be downloaded onto the hardware see Section 8 3 e The Release and Debug configuration binary or elf file can both be downloaded using IAR ARM Embedded Workbench directly 8 2 7 Batch build If several applications shall be built or all applications need to be re built bat files are provided to initiate an automatic batch build Please check directory Build and run the corresponding bat file as desired 8 3 Downloading an application This section describes how the binaries of the applications can be downloaded onto the hardware Please note that in case the board stores its IEEE address in the internal EEPROM of the microcontroller it is important to ensure that this IEEE address is not overwritten by the tool that is the content of the internal EEPROM needs to be preserved If this rule is not followed properly the EEPROM content might be overwritten and the example applications will not run since all example application are required to have a unique IEEE available for each node being detected during runtime In the subsequent section this is indicated both for AVR Studio and IAR Embedded Workbench 8 3 4 Using AVR Studio 4 directly When the ap
179. efore switching to promiscuous mode for example a node that was associated will still be connected to the same network The following picture indicates the proper handling of promiscuous mode 8412D AVR 5 12 Atmel AVR2025 Figure 6 2 Handling of promiscuous mode Node built with PROMISCUOUS MODE Other Node on Application Stack same Channel main c wpan mlme reset req usr mlme reset conf wpan mlme set req phyCurrentChannel usr mlme set conf Success wpan mlme set req phyCurrentPage usr mlme set conf Success wpan mlme set req macRxOnWhenldle True Setting up of Promiscuous Mode usr mlme set conf Success wpan mlme set req macPromiscuouMode True usr mlme set conf Success usr mcps data ind Frame 1 content wpan mlme set req macPromiscuouMode False Promiscuous Mode Used usr mlme set conf Success Switchted back to Normal Mode 6 1 1 4 ENABLE TSTAMP This build switch allows creation of timestamping information throughout the entire MAC stack This includes two different angles d Eu 00 8412D AVR 5 12 AIMEL e Generation of timestamping information within the TAL e Inclusion of timestamp information in the MAC API primitives see function usr mcps data conf and usr_mcps_data_ind in file MAC Inc mac_api h In case timestamping information shall be generated and included in the MAC API for
180. emains unchanged for this platform since the same timer sources are used as for the base platform e TIME STAMP REGISTER Remains unchanged since the target platform uses the same register for time stamping as the base platform e TRX Access macros for SPI Remain unchanged e LED pins and joystick Remains unchanged e Alert initialization and indication macros Remain unchanged since the same ports for the LEDs are used as for the base platform e ADC Initialization values Remove completely since ADC is not used for random number generation e ANTENNA DIVERSITY Some IEEE 802 15 4 Atmel transceivers allow for the utilization of antenna diversity as hardware feature e g AT86RF231 if the board also does support this feature The current MAC release supports antenna diversity where applicable In order to use antenna diversity the definition is included in this file as o didefine ANTENNA DIVERSITY 0 Boards do not support o define ANTENNA DIVERSITY 1 Boards do support 11 3 3 Bring up of an existing MAC application on the target platform The task of bringing up an already existing application on the new target platform is explained this section by the example of target platform REB 4 0 2 REX ARM REV 3 based on the Atmel AT91SAM7X256 ARM7 MCU A similar example based on the Atmel ATxmega256A3 MCU during the course of bringing up a new MCU is explained in detail in Section 11 5 The same steps are to be performed for all othe
181. ent frames initiated by calling function wpan mlme start req with parameter CoordinatorRealignment true a Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 4 14 Start of non beacon network and active scan Node using Node FFD using SCAN ACTIVE MAC START REQUEST CONFIRM REQUEST CONFIRM MAC MAC App Do LS wpan mime statt req Nonbeacon network Network Start N usr mlme start conf wpan mlme scan req Active scan Beacon Request Frame Beacon Frame A Active Scan Procedure usr mlme scan conf 4 4 11 MAC RX ENABLE SUPPORT This feature is usually required for any node both RFD and FFD that wants to enable its receiver for a certain amount of time or disable its receiver Most commonly it is utilized at an RFD that goes to sleep mode during idle periods to save as much power as possible In order to periodically listen to the channel or frames to be received the application can initiate a wpan mlme rx enable req with proper parameters see MAC Example Basic Sensor Network in Section 9 2 1 1 AIMEL 43 8412D AVR 5 12 Other Node e g PAN Coordinator Node using MAC_RX_ENABLE_SUPPORT MAC MAC A wpan_mcps_data_req Direct Data Frame Unsuccessful Data Transmission Data Frame last retry u usr mcps data conf 24 5 wpan mlme
182. er Request gt Broadcast Peer Unicast Peer Confirm L Unieasty p Blink TX LED Blink tX LED cp Univastdata packats LED Blink 1X LED Blink LED Blink TX LED UMicastdatapackets BINS LED Blink RX LED The LED on the receiver will blink sequentially and repeat at the rate at which the packets are received The LED on the transmitter will blink sequentially amp repeat at the rate at which the packets are transmitted The LED will blink at a constant rate on the transmitter as the packets are transmitted at a constant duration The packet format is described in the section Packet Format 9 2 2 1 3 1 1 Packet Format The transmitted packet format and content for the operation mode is customized to suite only the requirements of this application The format is shown in Table 9 5 Table 9 5 Packet payload format for Range measurement Payload Command ID Sequence Number Packet Count Field Description is as follows e Command ID 0x00 the value of command ID DATA FRAME AMEL s 8412D AVR 5 12 AIMEL EEE e Sequence Number To have a sequence of packets transmitted from the transceiver to the receiver The range of sequence number is 0x00 OxFF will roll over respectively This is to track the packet loss for a continuous transmission of packets e Packet Count The packet format maintains a 32 bit packet counter to count the number of packets at any
183. eriodically In order to enable the usage of Watchdog this feature needs to be enabled explicitly by setting this build switch during compilation AMEL so 8412D AVR 5 12 AIMEL Usage in Makefiles amp CFLAGS DWATCHDOG enables the Watchdog module Usage in IAR ewp files WATCHDOG enables the Watchdog module 6 1 3 16 SLEEPING TIMER In cases where it is needed a timer to be running while the microcontroller unit is in sleep either to count system time or to fire an interrupt to wake up the microcontroller this feature needs to be enabled explicitly by setting this build switch during compilation Usage in Makefiles CFLAGS DSLEEPING TIMER enables the Sleeping Timer Usage in Makefiles SLEEPING TIMER enables the Sleeping Timer 6 1 4 Transceiver specific switches 6 141 TAL TYPE The TAL Transceiver Abstraction Layer contains all transceiver based functionality and provides an API to the MAC which is independent from the underlying transceiver Certain functionality that for instance the MAC or an application may require is dependent from the actual used transceiver chip Examples are the utilization of antenna diversity time stamping mechanisms or the automatic CRC calculation in hardware Examples of currently supported transceivers are Atmel ATmega128RFA1 TAL directory ATMEGARF TAL 1 e Atmel AT86RF230B AT86RF230 Revision B e Atmel AT86RF231 e A
184. ers OK Entering programming mode OK Reading fuses address to 2 O E2 0x91 OxFF Leaving programming mode OK 9s Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 e Select the Program tab Within this tab select the Flash section selection the proper Intel Hex File in either hex or a90 format Afterwards press button Program Figure 8 7 Atmel AVR Studio 4 dialog with Program tab DTAGICE min mode with ATmegsi20 Main Program Fuses LockBits Advanced HW Settings HW Info Auto Device IV Erase device before flash programming Verify device after programming Flash Use Guns Gic Input HEX File Rr231 ATMEGA1281 REB 4 0 231MARSExe Star hex EEPROM Use Curent Simulator Emulator EEPROM Memory Input HEX File Program Verify Read r ELF Production File Format InputELF Fie Fuses and lockbits settings Program Save must be specified before saving to ELF Setting device parameters OK Entering programming mode OK Reading fuses address 0 to 2 2 0x91 OxFF OK Leaving programming mode OK zi e The image will be downloaded onto the target and the status will be indicated Figure 8 8 AVR Studio JTAGICE dialog with Program tab download status JTAGICE mkII in JTAG mode with A
185. es PIB 00 00 PIB 00 value is set successfully PIB 53 00 FFFF PIB 53 value is OXFFFF Result code OK Execution is completed successfully AT commands for the MLME SAP is shown in the Table below Table 9 2 MLME SAP listing MLME SAP Function Request Indication Response Confirm MLME ASSOCIATE ASSOC INASSOC ASSOCRSP ASSOC A DE 4DASSOC INDASSOC 4DASSOC INBCN MLME GET PIB lt gt PIB lt gt lt gt MLME GTS Not supported Not supported Not supported Not supported MLME ORPHAN INORPH ORPHRSP MLME RESET RESET RESET MLME RX ENABLE RXEN RXEN MLME SCAN SCAN SCAN m INCOMM MLME SET PIB lt gt lt gt PIB lt gt lt gt MLME START START START MLME SYNC SYNC MLME SYNC LOSS INSYNL MLME POLL POLL POLL Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 AT commands for the MCPS SAP is shown in the Table below Table 9 3 MCPS SAP listing MCPS SAR Request Confirm Indication Function MCPS DATA DATA DATA INDATA MCPS PURGE PURGE PURGE Format of the extended command set is shown in the Table below Table 9 4 Extended command set Format Comment Command alities DATA lt SrcAddrMode DstAddrMo Refer section 7 1 1 1 and 4DATA Send de DstPANId DstAddr msduLength 7 1 1 2 of IEEE Stand
186. es MPromiscuous Mode Demo cd AT86RF212 ATMEGA1281 RCB 5 3 SENS TERM BOARD e Double click on the corresponding AVR Studio 5 solution file avrsin file for example Promiscuous Mode e Select the desired configuration Release or Debug Depending on the selected configuration the corresponding external Makefile is chosen during the build process These Makefiles are exactly those Makefiles located in subdirectory GCO that are used to build the application from command line see section 8 2 1 e Rebuild the entire application in AVR Studio 5 e After building the application the subdirectory GCC contains executable files and hex file which can be downloaded onto the hardware see section 8 3 8 2 4 Using IAR Embedded Workbench 8412D AVR 5 12 Each application can be rebuilt using the IAR Embedded Workbench directly Please follow the procedure as described AMEL s AIMEL pu M Change to the directory where the IAR Embedded Workbench workspace file eww file for the desired platform of the corresponding application is located for example cd ApplicationsMMAC Examples MPromiscuous Mode Demo cd AT86RF212 ATMEGA1281 RCB 5 3 SENS TERM BOARD Double click on the corresponding IAR Embedded Workbench file eww file for example Promiscuous Mode Demo eww Select the desired workspace Release or Debug and Rebuild the entire application in IAR Embedded Workbench After
187. es are included depending on the used build switches and basic configuration type Qualitative configuration includes e Features or modules can be included to or excluded from the firmware using build switches The build configuration is controlled by switches within Makefiles or IAR project files e Several Makefile or IAR project file templates are provided for getting started see directory Applications e Primitives as defined within IEEE 802 15 4 and thus features within the MAC can be included or excluded depending on the required degree of standard compliance or application needs e Two generic profiles are provided RFD and FFD primitive configuration Quantitative configuration includes e Resources can be adjusted to the application needs e The file app config h usually located in the Inc path of the applications provides hooks for the application configuration to configure its own resources e Each demonstration application comes with its own configuration app config h that can be re used for own application design The stack and application based on the stack can be highly configured according to the end user application needs This requires a variety of build switches to be set appropriately The following section describes that build switches may be used during the build process The switches may be categorized as follows 18 Global stack switches o HIGHEST STACK LAYER REDUCED PARAM CHECK PROMISC
188. esent received beacon frame to its upper layer in case the beacon frame contains a beacon payload or the MAC PIB attribute macAutoRequest is set to false e MAC DISASSOCIATION BASIC SUPPORT The node is able to accept and process a request from its upper layer to Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 disassociate itself from its network or to process a received disassociation frame from its parent MAC_INDIRECT_DATA_BASIC The node is able to poll its own parent for indirect data MAC_PAN_ID_CONFLICT_NON_PC The node is able to detect a PAN Id conflict situation while NOT acting as a PAN Coordinator by checking received beacon frames from other PAN Coordinators and being able to initiate the transmission of PAN Id Conflict Notification Command frames from its parents if required MAC RX ENABLE SUPPORT The node is able to switch on or off its receiver for a certain amount of time upon request by its upper layer This is required in order to allow for the upper layer to receive frames in case the node is generally in a power safe state MAC SCAN ACTIVE REQUEST CONFIRM The node is able to perform an active scan to search for existing networks MAC SCAN ORPHAN REQUEST CONFIRM The node is able to perform an orphan scan in case it has lost its parent MAC SYNC LOSS INDICATION The node is able to report a sync loss condition to its upper layer This can be either the reception of a coordinator realignment frame from its parent
189. esponse frame indirectly also the components INDIRECT DATA BASIC and MAC INDIRECT DATA FFD are required 4 445h MAC ASSOCIATION REQUEST CONFIRM This feature allows a node both RFD and FFD to associate to a parent PAN Coordinator or Coordinator to initiate an association procedure by transmitting an AMEL s 8412D AVR 5 12 AIMEL association request frame and handle the reception of an association response frame amp In case a short address is desired this will be requested by the parent if allowed All required timer for the association process are handled as well Since the association response frame is received indirectly also the feature MAC_INDIRECT_DATA_BASIC is required The node is able accept and process a request from its upper layer for example the network layer to associate itself to another node that is its parent Figure 4 12 Provided functionality for ASSOCIATION INDICATION RESPONSE and MAC ASSOCIATION REQUEST CONFIRM Node using Node FFD using MAC ASSOCIATION MAC ASSOCIATION REQUEST CONFIRM INDICATION RESPONSE App MAC MAC App wpan mlme associate req Association Request Frame usr mlme associate ind mlme associate resp Data Request Frame Standard Associaton Procedure Association Response Frame usr mlme associate conf usr mlme comm status 4 4 6 MAC DISASSOCIATION BASIC SUPPORT This componen
190. essing of a received frame in side the TAL is independent from the layer residing on top of the TAL The same mechanisms as described in Section 4 2 1 2 apply within in the TAL layer Step 2 Once the TAL frame reception callback function tal rx frame cb implemented inside the application is called the application can access the frame buffer via a frame inof t structure At the end it is necessary to free the receive buffer by calling the function bmm buffer A new buffer for frame reception is automatically allocated inside the TAL itself so the application does not need to take for Rx buffer allocation The stack contains a variety of configuration files which allow e The stack to configure the required stack resources according to the application needs based on the required functionality and e The application to configure its own resources Throughout the various layers and thus directories within the software package the following configuration files are available e app config h e stack config h pal config h e tal config h e mac config h e mac build config h e mac user build config h The meaning of these configuration files are described in more detail in the following sections The following picture shows the include hierarchy amp include file name h for these configuration files AIMEL 33 AMEL Figure 4 9 Configuration file include hierarchy Application Domain Stack Dom
191. etworks are enabled The actually enabled functionality differs depending on the internal requirements for FFDs or RFDs amp Additionally the following feature is enabled e MAC_SYNC_REQUEST The node is able to sync itself with its parent by tracking the corresponding beacon frames Please check IEEE 802 15 4 2006 for further information about the MAC primitives and the implementation of their corresponding features in the MAC 6 2 1 4 MAC_SECURITY_ZIP If MAC SECURITY ZIP is set during the build process all functionality required to support security are enabled Additionally the following feature is enabled STB ON SAL e SAL TYPE Please check IEEE 802 15 4 2006 for further information about the MAC primitives and the implementation of their corresponding features in the MAC 6 2 2 User build configurations MAC USER BUILD CONFIG 6 2 2 1 Introduction Since a number of applications do not necessarily need the functionality provided by any of the standard build configurations or may even have more rigid requirements concerning FLASH or RAM utilization the concept of user build configuration has been introduced The usage of the build MAC USER BUILD CONFIG in the Makefiles or IAR Embedded Workbench project files allows the end user to tailor its MAC completely according to its own needs The following MAC features can be separately selected or removed from the build e Association e Disassociation e Support of
192. evice MCU is full sleep mode and user can wakeup the device and send data to PAN Coordinator anytime by pressing the button This example application uses MAC API as interface to the stack The application and all required build files are located directory Applications MAC_Examples Star_Push_Button The source code of the application can be found in the subdirectory Src The application requires up to three LEDs on the board in order to indicate the proper working status A push button is mandatory as it is required to generate an external interrupt to wakeup the MCU from full sleep A sniffer is suggested in order to check the proper association and the data transfer between the devices The application works as described subsequently Node one e Switch on node one e LED 0 indicates that the node has started properly 8412D AVR 5 12 9 2 1 7 4 Limitations 9 2 1 8 9 2 1 8 1 Introduction 9 2 1 8 2 Requirements 8412D AVR 5 12 Atmel AVR2025 e Flashing of LED 1 indicates that the node is scanning its environment Scanning is done three times on each available channel depending on the radio type e f no other network with the pre defined channel and PAN Id is found the node establishes a new network at the pre defined channel channel 20 for 2 4GHz radio This node now becomes the PAN Coordinator of this network The successful start of a new network is indicated by switching LED 1 on Node two e Swit
193. explained in Section 4 1 1 the stack is always separated into a stack domain and an application domain Figure 4 3 Data frame reception procedure usr_mcps_data_ind e mac callback wrapper c mops data ind MAC NHLE Queue MCL T mac_task TAL MAC Queue JA tal tx frame bu tx frame done cb tal rx frame cb TAL Incoming Frame T AL Queue tal task 2 process Coming frame PAL HW How is the procedure for a MAC Data frame which is received A Once the frame has been received by the hardware the ISR is invoked and function handle received frame irq located in file TAL tal_type Src tal_rx c is called within the ISR contect In this function the following tasks are performed e Reading of the ED value of the current frame e Reading of the frame length e Uploading of the actual frame including the LQI octet appended at the end of the frame 8412D AVR 5 12 AMEL 21 AIMEL e Constructing the array of the frame_info_t structure for the received frame by additionally appending the ED value after the value for more information about the structure of the received frame see Section 4 2 1 2 e Reading of the timestamp of received frame if required e Queuing the received frame into the TAL Incoming Frame Queue for further processing in the main context B During t
194. flector Receiving Number of received frames 100 average LQI 255 average RSSI 41 dBm Frames Rec on air PER Measurement mode Peer device found Starting PER Measurement mode as Reflector Receiving Number of received frames 100 average LQI 255 average RSSI 41 dBm Receiving Number of received frames 100 average LQI 255 average RSSI 40 dBm 166 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 9 2 2 1 3 3 Peer Search Process The Peer Search process is described in detail below and is illustrated by a sequence diagram Initially the nodes uses their 64 bit MAC address as source address during the Peer Search Process to get connected each other During the Peer search process 16 bit random address shall be assigned to both the devices Figure 9 199 Sequence Diagram for Peer Search process Transmitter Reflector PEER_REQ M1 Src 64 bit MAC addr Dest Oxffff payload rand addr1 mode byte PER Range PEER_INIT PEER RSP WAIT TIMER i m PEER_REQ 1 Src 64 bit MAC addr Dest Oxffff payload rand addr1 mode byte PER Range PEER_REQ_SENT PEER RSP WAIT TIMER 1 A PEER_REQ M1 Src 64 bit MAC addr Dest Oxffff payload rand addr1 mode byte PER Range PEER RSP WAIT TIMER i 1 _RSP_RCVD x PEER RSP M2 Src rand addr1 Dest 64 bit MAC addr payload rand addr2 mode byte P
195. formation previously included by means of several structure elements has been migrated into the new element mdpu which contains the complete MPDU both the MAC Header and the MSDU Data Payload This implies that starting with release 2 5 x the MAC header information is only parsed and formatted inside the MAC layer and is fully transparent for the TAL layer 7 2 2 2 Simplification of Function tal_rx_frame_cb The TAL callback function for a frame indication once a valid has been received and needs to be forwared to the MCL has been simplified The function tal_rx_frame_cb has changed from void tal rx frame cb frame info t mac frame info uint8 t lqi to void tal rx frame cb frame info t rx frame The parameter LQI has been removed since the LQI value of the current frame is now part of the element mpdu of the frame info t structure variable rx frame For more information check function tal rx frame cb in file TAL Src tal rx frame cb c For more information how to extract and use the LQI value of the received frame see Section 4 2 1 2 7 2 2 3 Simplification of Beacon Handling API The API handling periodic Beacon frames within a beacon enabeld network has been simplified by removing function tal_prepare_beacon and updating function tal_tx_beacon AMEL s7 8412D AVR 5 12 7 23 PAL API Changes 88 Atmel AVR2025 AMEL Originally release 2 4 x the periodic Beacon transmission was perf
196. ga256A3 MCU REB212 V5 0 2 with Atmel AT86RF212 in conjunction with CBB with ATxmega256A3 MCU The following pictures depict an Atmel ATxmega256A3 CBB board with REB231 V4 1 1 with Atmel AT86RF231 AMEL AMEL Figure 10 17 REB CBB assembly Transceiver Side 14 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 10 19 Connecting UART cable and JTAG to CBB 10 4 3 3 AT91SAM7X EK The Atmel AT91SAM7X EK in conjunction with an REB to ARM Adapter can be used as a baseboard for an REB to create platforms using Atmel ARM7 MCUs such as Atmel AT91SAM7X256 MCUs It provides currently four LEDs and a joystick for user interaction Currently supported are REB230B V2 3 with Atmel AT86RF230 in conjunction with REB to ARM Adapter Rev 2 REV_ARM REV 2 e REB231 V4 0 1 V4 0 2 with Atmel AT86RF231 in conjunction with REB to ARM Adapter Rev 3 REV_ARM REV 3 e REB212 V5 0 2 with Atmel AT86RF212 in conjunction with REB to ARM Adapter Rev 3 REV ARM REV 3 The following pictures depict an AT91SAM7X EK board with Atmel AT91SAM7X256 and an AT91SAM7X E with an REV ARM REV 2 with REB230B V2 3 AMEL s 8412D AVR 5 12 AIMEL Figure 10 20 Atmel AT91SAM7X EK board with Atmel AT91SAM7X256 16 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 10 22 Atmel AT91SAM7X EK board with Atmel AT91SAM7X256 connected to Atmel SAM ICE and UART 10 4 4 Atmel AT91SAM7XC EK
197. h requires specific software changes a new board has to be added to the PAL and the board type has to be added to file pal boardtypes h preferably added to customer specific vendor boardtypes h being enabled by setting compile switch VENDOR BOARDT YPES see Section 6 1 3 11 or 11 3 1 1 Usage in Makefiles CFLAGS DBOARD TYPE USBSTICK C selects the Raven USB stick revision C Usage in IAR ewp files BOARD TYPE RCB 4 1 SENS TERM BOARD selects the Radio Controller Board Revision 4 1 using antenna diversity for the Atmel AT86RF231 microcontroller AMEL 8412D AVR 5 12 AIMEL pum 6 1 3 4 SIO UAHTO UART1 USBO Certain applications for example TAL example Performance Test EVK require Serial I O support SIO in order to print characters on a serial terminal or get input from the user For easy SIO configuration the concept of a SIO Hub was introduced This implements a simple software multiplexer de multiplexer which allows the application or stack to access SIO hardware resources without actually knowing which kind of SIO hardware support is provided The actually supported hardware is currently UART or USB In order to enable SIO functionality the build switch SIO HUB has to be set Also the proper USB or UART channel needs to be set Usage in Makefiles CFLAGS DSIO HUB DUSBO enables the SIO Hub and uses USB channel 0 Usage in IAR ewp files SIO HUB UA
198. h the application simultaneously Secure Star Network The STB example Secure Star Network deploys non beacon enabled network with encrypted and authenticated frames It is using CCM security The application consisting of PAN Coordinator and Device utilizing the mechanism of transmitting secured data frames from the Device to the Coordinator after successful joining of the Device to the Coordinator This example application uses both STB and MAC API as interface to the stack The STB is used to secure application data and the MAC is used to set up a non beacon enabled network perform scanning and network association and to transmit or receive secured frames AIMEL i AIMEL The application and all required build files are located directory Applications STB Examples Secure star Network The source code of the application can be found in the subdirectory Coordinator Src and Device Src amp 9 2 3 32 Requirements This application requires e Up to three LEDs on the board in order to indicate the proper working status A sniffer is suggested in order to check frame transmission between the nodes 9 2 3 3 3 Implementation The node acting as a Coordinator PAN Coordinator starts a non beacon enabled PAN at channel DEFAULT CHANNEL with the PAN ID DEFAULT PAN ID The Device scans for this network and associates to the PAN Coordinator Once the Device is associated it uses a timer that fires every 2 seconds to tran
199. hat the new board type gets a unique reasonable number in its definition The actually selected number for the board definition itself can be deliberately selected as long as it is unique in this particular board definition header file b Orcreate a new file vendor boardtypes h and add the new hardware platform with its own ID in this file An example of such a vendor specific file can be found at PAL AVR ATMEGA 1281 Boards vendor boardtype example h Copy this file into your board directory and rename it to vendor boaratype h Added the boardtype into this file Also make sure that the build switch VENDOR BOARDTYPES is used within your application project files e Step 3 Identify an already supported board that best fits the target board to start the porting base platform o Each supported board based on a given MCU is identified by a specific value of the build switch BOARD TYPE o For a list of all currently supported boards check PAL MCU FAMILY NAME MCU NAME Boards pal boardtypes h for defined values of BOARD TYPE o For more information see also Section 10 4 e Step 4 Copy the PAL board directory of the base platform in a separate directory within the same board directory of the target MCU and name it according to the target platform e Step 5 Rename all occurrences of base platform to target platform 11 3 1 2 Phase2 Actual porting to target platform This section describes the actual porting phase once the direct
200. he Plugins tab and deselect all entries 8 3 4 2 Starting the debug build The debug build can simply be started as follows 8412D AVR 5 12 Make sure that only the JTAGICE of the node where the current build shall be downloaded to is switched on Switch off all other JTAGICE Open IAR Workbench by double clicking the desired eww file Select the Debug Workspace Open the Options window for the Debug Workspace Select the Debugger window and within this window select the Setup tab AIMEL mn 112 Atmel AVR2025 AIMEL SEE E Options for node Star Category General Options C C Compiler Assembler Custom Build Build Actions ICE200 2 JTAGICE mkII r Dragon Use macro file Simulator Third Party Driver Setup macros Device description file Override default TOOLKIT DIR ConfigNiom1281 ddf main this is different to Release build Options for node Star Category Factory Settings General Options C C Compiler Assembler Custom Build Setup Plugins Build Actions Linker CCR Code Coverage ICE200 ORTI RTOS JTAGICE Profiling 2 mkII Stack Dragon Symbols Simulator Third Party Driver uC OS ll Kernel Awareness Location C Programme IAR Systems EmbeddedworkbenchS3 avr Originator Micrium Version Figu
201. he remote node Disabled To enable disable the CRC settings on remote node Table 9 9 Description for Sub menu Service functions 4 9 2 2 1 3 2 1 Sensitivity testing 164 Atmel AVR2025 Menu Functionalities Default Comment Option Value Peer Identify Peer node identifies itself by blinking its LEDs E Energy Scan do energy scan for all channels 0 Continuous _ To enable disable continuous transmission on the Transmission current channel D Continuous _ To enable disable continuous wave pulse mode from Wave Pulse the radio transceiver V Sensor Data To read the sensor data in voltage H Read Write _ To read or write any register set from the radio transceiver In the IEEE 802 15 4 standard the receiver sensitivity is defined as the lowest received signal power that yields a packet error rate loss of less than 1 IEEE 802 15 4 requires only 85 dBm of sensitivity for operations in the 2 4 GHz ISM band Using the PER test sensitivity can be tested by configuring one of the nodes as a transmitter and another as a receiver The number of packets to be transferred is configured on the transmitter and all the packets received by the receiver are acknowledged The receiver keeps a count of the packets received At end of the test the transmitter asks the receiver for the test results The test results are displayed on the UART terminal at the end of the test For this test uni
202. he proper buffer header is stored inside the buffer header element of structure frame info t receive frame buffer header buf ptr The processing inside the TAL is done once tal rx frame cb is called Although this function resides inside the MCL see file MAC Src mac data ind c the functionality is considered here being logically part of the TAL Here the msg type of the frame residing in the current buffer is specified as TAL DATA INDICATION and the buffer is pushed into the TAL MAC Queue Step 2 Once the TAL DATA INDICATION message has been de queued from the queue the dispatcher calls the corresponding function process tal data ind see file MAC Src mac data ind c In this function the received frame is parsed and eventually the dedicated function handling the particular frame type is invoked which is mac process data frame in file MAC Srcmac mops data c Here a structure of type mcps data ind tis overlaid over the receive buffer body mcps data ind t mdi mcps data ind t BMM BUFFER POINTER buf ptr For more information about the data ind t structure see MAC Inc mac msg types h The members of the mcps data ind t structure are filled based on the information within the received MAC Data frame The message is identified as MCPS DATA INDICATION message and is queued into the MAC NHLE Queue Step 3 Once the dispatcher removes the MCPS DATA INDICATION from the queu
203. he subsequent call to tal_task see file TAL tal_type Src tal c the frame is extracted from the TAL Incoming Frame Queue and function process_incoming_frame see file TAL tal_type Src tal_rx c is called C Within function process_incoming_frame further handling of the frame is performed such as calculation of the normalized value based on the selected algorithm for LQI handling and the callback function tal rx frame cb residing inside the MAC see file MAC Src mac data ind c is called D The callback function tal rx frame cb pushes the TAL frame indication message into the TAL MAC Queue for further processing inside the MCL E During the subsequent call to mac task see file MAC Src mac c the TAL indication message is extracted from the TAL MAC Queue and function mac process tal data ind see file MAC Src mac data ind c is called F Within MCL the following task are performed once function mac process tal data ind is executed e Depending on the current state of the MCL the frame type is derived and the function handling the specific frame type is invoked e n case of a received MAC Data Frame received during regular state of operation that is no scanning is ongoing etc the corresponding function is mac process data frame residing in MAC Src mac mcps data c e Within function mac process data frame the MAC Header information is extracted from the received frame and the corresponding MCPS DATA indication
204. ication so that direct data transmission is performed in the other direction from coordinator to device In case the data transmission from coordinator to device is required more changes within the application are required For more information please see Section 4 5 An example where this scenario has been implemented by means of using the feature MAC_RX_ENABLE_SUPPORT can be found in Section 9 2 1 3 MAC Example Basic_Sensor_Network 8412D AVR 5 12 9 2 1 6 1 9 2 1 6 2 9 2 1 6 3 Introduction Requirements Implementation 8412D AVR 5 12 Atmel AVR2025 9 2 1 6 Star_High_Rate The application Star_High_Rate provides a simple start network application based on IEEE 802 15 4 2006 transmitting data frame using a High Data Rate that is 2Mbit s The application uses two nodes a PAN Coordinator 1 and an End Device 2 The firmware is implemented as such that a node can either act as a PAN Coordinator or an End Device This application works very identical to the MAC Example Star_Nobeacon see Section 9 2 1 5 but the nodes switch to 2MBit s data rate once the end device has been associated In order to see the check functioning of the application the terminal output can be used This example application uses MAC API as interface to the stack The application and all required build files are located directory Applications MAC_Examples Star_High_Rate The source code of the application can be found in the subdi
205. id usr mcps data conf uint8 t msduHandle uint8 t status uint32 t Timestamp if status MAC SUCCESS Dummy data has been transmitted successfully Application code could be added here ey pal_led LED_2 LED ON Start a timer switching off the LED pal timer start TIMER LED OFF 500000 IMEOUT RELATIVE void data exchange led off cb NULL 9 2 Provided examples applications 9 2 1 MAC examples 9 2 1 1 Nobeacon_Application 9 2 1 1 1 Introduction The basic MAC Example Nobeacon Application deploys a non beacon enabled network consisting of PAN Coordinator and Device utilizing the mechanism of indirect data transfer between Coordinator and Device In this example the Coordinator wants to send data to the Device and since a Device in a non beacon enabled network is in sleep mode as default direct transmission to the Device is not possible In order to enable communication with the Device indirect data transmission using polling by the device is applied For further explanation of indirect transmission see section 4 4 1 4 4 2 For power management and indirect transmission see Section 5 2 4 After the Device receives the data from the Indirect Data Queue from the Coordinator the Device sends back the data received from the Coordinator to the Coordinator itself by direct data transmission This example application uses MAC API as interface to the sta
206. iding in files usr_ c The MAC API in return interacts with the MAC Core Layer MCL by means of messages handled with an internal queue S An application residing on top of another layer above the MAC layer The application interacts with the Highest Stack Layer by means of function calls and callback to be implemented within the highest stack layer and or the application The stack layer above the MAC that is the Network Layer NWk interacts with the MAC by means of messages handled with an internal queue similar to 1 AIMEL 17 8412D AVR 5 12 AIMEL 4 1 1 1 Part 1 Data frame creation and transmission amp Figure 4 1 Data frame transmission procedure Part 1 0 2 wpan mops data req mac api c NHLE MAC Queue EL NN mocps data request mops data request MCL m diat tc trame done nc trame E TAL PAL HW How is the procedure for a MAC Data frame which shall be transmitted A In case the MAC application wants to initiate a frame transmission it call the MAC API function wpan mcps data req function with the corresponding parameters see file MAC Inc mac api h As part of the parameter list the application needs to specify the proper MAC addressing information and the actual application payload In case the application resides on another higher layer than the MAC the H
207. ighest Stack Layer needs to provide a similar API than the MAC and should handle the request of the application for a frame transmission similarly A B Within file mac api c the corresponding MAC message is generated and queued into the NHLE MAC Queue which handles all MAC layer request and response messages During this process the actual application payload is copied once into the proper position of the MCPS message This is actually the only the data payload is copied during the entire frame transmission process During the further processing of the frame the payload is not copied further except for the utilization of MAC security Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 In case the application resides on another higher layer than the MAC the Highest Stack Layer needs to generate the corresponding message accordingly and queued this into the proper queue Here the application payload is also copied only once at the interface of the Highest Stack Layer B If the application is already at the right position is it not necessary to copy the application payload again during the further process of the frame in all lower layers down to the MAC layer The subsequent handling of the frame transmission attempt is identical independent from the stack layer the application is actually residing on C Within the MAC Core Layer MCL the dispatcher reads the message form the NHLE MAC Queue a
208. indow select the Setup tab 124 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 8 42 IAR ARM Embedded Workbench Options gt Debugger gt Setup Options for node Coordinator E Category Factory Settings General Options C C Compiler Assembler Output Converter Download Images Extra Options Plugins Custom Build Build Actions Run to main imulacor Setup macros Angel Use macro file s GDB Server IAR ROM monitor J Link J Trace LMI FTDI iia Device description file ST Link Override default Third Party Driver TOOLKIT DIR SCONFIG debuggers amp tmelNioat81sam3s4 ddf Cancel e Within the Setup tab select the Driver and select Run to main this is different to Release build e Change to the Plugins tab and select the entries as shown in Figure 8 AMEL 125 amp 8412D AVR 5 12 AMEL Figure 8 43 IAR ARM Embedded Workbench Options gt Debugger gt Plugins Options for node Coordinator E Category Factory Settings General Options C C Compiler Assembler Output Converter Setup Download Images Extra Options Custom Build Build Actions lect plugins to load Linker imulator Angel GDB Server IAR ROM monitor J Link J Trace LMI FTDI Description RTOS awareness for Macraig
209. ing timestamp information If this build switch is explicitly set in the project files or Makefiles for an application the timestamp information is generated similar as for Atmel AT86RF230 based systems 6 1 4 9 TRX_REG_RAW_VALUE This build switch is used to disable the scaling of ED value By default ED value read from the RG_PHY_ED_LEVEL register shall be scaled using CLIP VALUE REG value By using this buid switch this can be avoided and raw value of ED sall be used AMEL 8412D AVR 5 12 6 1 5 Security switches 7 Atmel AVR2025 AIMEL ey 6 1 4 10 SW_CONTROLLED_CSMA This build switch SW_CONTROLLED_CSMA includes functions to the build process that control the CSMA CA algorithm by software CCA backoffs and re transmissions are controlled by software while the transceiver handles frame validation e g CRC and frame filtering and ACK transmission using its automatic extended modes 6 1 4 11 TX OCTET COUNTEHR This build switch TX COUNTER includes functions to the build process that count the number of actually sent bytes over the air The number of bytes are accumulated in the variable tal tx octet cnt This includes data frames that are sent actively and ACK frames that are sent due to received frames including preamble SFD and length field The application can reset and read the tal tx octect cnt variable It can be used to calculate an actual duty cycle In order to use the TX COUNTER sw
210. inker Get reset address from UBROF JTAGICE mkII r Setup macros Simulator Use macro file r Device descriptions Override default TOOLKIT_DIR config iouc3I064 ddf OK e Within the Setup tab select the Driver JTAGICE and select Run to main this is different to Release build e Change to the Plugins tab and select the entries as shown in Figure 8 AIMEL i 120 Atmel AVR2025 AIMEL SEE Figure 8 37 IAR AVR32 Embedded Workbench Options gt Debugger gt Plugins Options for node Wireless Touch Category Factory Settings General Options C C Compiler Assembler to Custom Build Build Actions Setup Extra Options Plugins Select plugins to load AVR ONE JTAGICE mkII Simulator Description 05 Awareness Location Program Files IAR Systems Embedded Workbench 5 6 Originator Micrium Version OK e Press e Press the button Download and Debug 8412D AVR 5 12 Atmel AVR2025 Figure 8 38 IAR AVR32 Embedded Workbench start Download and Debug E IAR Embedded Workbench IDE Ele Edit View Project Tools Window Help Download and Debug Cg Resources main c C3 Output Mes
211. internal event queue TAL MAC Queue and calls the corresponding event handler The MAC Data Service transmits data using the frame transmission services of the Transceiver Abstraction Layer invokes the confirmation function mcps data conf which is implemented the MAC API This function in turn calls the usr mcps data conf callback function implemented by the application The indirect data requests are queued into the Indirect Data Queue where the frames are re fetched from when a corresponding data request poll request is received from a device Receiving a data frame from the TAL through MAC Incoming Frame Processor the MAC Data Service invokes the indication function mcps data ind which is implemented by the MAC API This function calls the usr mcps data ind callback function implemented by the application The MAC Management Service processes the management requests and responses through TAL and PAL and if applicable invokes the respective confirm function implemented by the MAC API This function in turn calls the usr mlme xyz conf callback function implemented by the application Receiving a command frame from the TAL through the MAC incoming frame processor the MAC Management Service invokes the indication function mlme xyz ind which is implemented by the if required xyz ind function calls the mlme xyz ind callback function implemented by the application The MAC In
212. ion file stack config h Usage in Makefiles CFLAGS DVENDOR STACKCONFIG enables the utilization of customer defined stacks Usage in IAR ewp files VENDOR STACKCONFIG enables the utilization of customer defined stacks 6 1 3 13 ENABLE ALL IRQS MEGA only Each transceiver has a variety of transceiver interrupts connected to the MCU depending on the used transceiver and board type Depending on the type of application and the footprint requirements not all transceiver interrupts may be used within a specific application Single chip transceivers PAL GENERIC TYPE MEGA RF have a large number of available transceiver interrupts For example the Atmel Atmega128RFA1 provides up to usable 10 transceiver interrupts The provided software package only requires three transceiver interrupts being support mandatorily 26 TX END IRQ that is the main transceiver interrupt Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 27 RX END IRQ and 28 CCA ED IRQ whereas the other transceiver interrupts may be utilized within specific applications if desired The timestamp interrupt can be enabled by using the build switch ENABLE_TSTAMP see Section 6 1 1 4 The other enhanced transceiver interrupts of MEGA_RF platforms 29 AMI IRQ 30 Batmon IRQ 31 Awake IRQ 32 PLL Lock IRQ 33 PLL Unlock IRQ 34 AES Ready IRQ are not used within the Atmel AVR2025 software package but may neverthele
213. irectory AT86RF230B 915 7 256 REB 2 3 REX ARM REV 2 within the application directory Applications MAC Examples Star Nobeacon The entire directory Applications MAC Examples Star Nobeacon AT86RF230B 4 915 7 256 REB 2 3 REX ARM REV 2 is copied and renamed 21 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Applications MAC_Examples Star_Nobeacon AT86RF231_AT91SAM7X256_REB 4 0 2 REX ARM REV 3 Usually the directory name for applications consists of the following items to uniquely identify the target platform e TAL_TYPE AT86RF231 e PAL_TYPE AT91SAMX256 PAL GENERIC TYPE ARM7 e BOARD TYPE REB 4 0 2 REX ARM REV 3 IMPORTANT Make sure that the build switch HIGHEST STACK LAYER is not changed This build switch always needs to reflect the proper highest stack layer that the application is residing on In case of a MAC application such as the Star Nobeacon the application is residing on top of the MAC so HIGHEST STACK LAYER needs to be MAC If this is not properly set this leads to undefined behavior during the build process or during application usage 11 3 3 3 Step 3 Update the GCC Makefile Currently the GCC build is not supported for ARM7 based boards For an example how to port applications for MCU families with GCC support within this software package such as AVR or XMEGA MCUs see Section 11 4 3 3 11 3 3 4 Step 4 Update the
214. is explained in general within this section and furthermore by the example of a platform based on the Atmel AT91SAM7X256 in Section 11 3 2 The same steps are to 2 Atmel AVR2025 be performed for all other platforms or boards respectively that shall be used 8412D AVR 5 12 Atmel AVR2025 11 8 1 1 Phase1 General preparation for target platform The first phase is a simple preparation phase It provides the required directory and file structure for the target platform board and defines proper build switches required for this target platform e Step 1 Identify the MCU for the target board Each supported MCU is identified by a specific value of the build switch PAL_TYPE and is part of a specific MCU family specified by the build switch PAL_GENERIC_TYPE For a list of all currently supported MCUs with a given MCU family check file PAL Inc pal_types h for defined values of PAL_TYPE for each MCU family o For more information see also Section 10 2 e Step 2 Add the target board to the selected MCU that is PAL TYPE in the corresponding file containing the supported hardware platforms for the target MCU This can be done using one of the following approaches a Add the board type to the existing file PAL MCU FAMILY NAME MCU NAME Boards pal boardtypes h As an example for a new board for the Atmel AT81SAM7X256 add the target board to file PAL ARM7 AT91SAM7X256 Boards pal_boardtypes h see Section 11 3 2 Make sure t
215. itch the build switch SW CONTROLLED needs to be set as well 6 1 4 12 TX RX WHILE BACKOFF The build switch RX WHILE BACKOFF enables switching the receiver on during backoff periods of the CSMA algorithm If the build switch RX WHILE BACKOFF is not defined for the build the receiver remains off during backoff periods In order to use the WHILE BACKOFF switch the build switch SW CONTROLLED CSMA needs to be set as well If the receiver is switched on during backoff periods and a frame is received including automatic ACK transmission the received frames get queue into the receive frame queue After frame reception the CSMA algorithm is continued with the next CSMA attempt Impacts with RX WHILE BACKOFF e a normal scenario low traffic the maximum data throughput is reduced by about 2 percent at 250kb s and about 1 percent at 100kb s due to the software controlled CSMA using a SPI based transceiver e In high density networks the outgoing data throughput highly varies based on the number of received frames during the backoff periods e The implementation of the software controlled CSMA algorithm requires about 0 5 kB Xmega 0 8kB ARMY7 program code e An additional software timer is required and the MCU utilization is higher during the actual CSMA procedure In order to provide security support to the application a number of switches controlling the incorporation of code for security is defined For exam
216. itions of layer specific stack resources such as timers or buffers o For further information see Section 4 3 Examples mac config h tal config h pal config h 8412D AVR 5 12 Atmel AVR2025 4 Understanding the stack The following chapter explains how an end user application is configured Generally the stack is formed by every software portion logically below the application The stack can comprise e Only the PAL or e The TAL based on PAL or e The MAC based on TAL and PAL or e A network layer NWK based on TAL and PAL e Any other layer residing below the application For configuring the stack appropriately please refer to Chapter 6 4 1 Frame handling procedures 4 1 4 Frame transmission procedure This section shall explain the stack layer interworking for the transmission of a MAC data frame The payload of such a frame requires special treatment since it is handed over from the higher layer or application whereas other MAC frames are generated inside the MAC layer itself The stack is always separated into a stack domain and an application domain The application resides on the stack layer called Highest Stack Layer see Section 2 1 4 The AVR2025 software package can be utilized in the following two different architectures 1 An Application residing on top of the MAC layer The application interacts with the MAC Layer by means of functions call residing in file mac api c and callbacks res
217. ization level is changed If the GCC compiler is used this switch also enables printout functionality for debug purposes ASSERT 6 1 6 2 5 55 This build switch is solely present for Atmel internal regression testing not to be used by an application Although the code in file mac_pib c may lead to the conclusion that this switch needs to be set in order to be allowed to set the IEEE address of this node via software this is not supposed to be used this way Each device has its own IEEE address that is fixed for this device and usually it is located in any type of persistent storage This is actually not a PIB attribute but rather a constant see IEEE 802 15 4 2006 Section 7 4 1 Table 85 aExtendedAddress So the value is only READ_ONLY and in normal mode not supposed to be written by the application or stack Therefore this attribute can be read using functions wpan_mime_get_req but written wpan mlme set req 6 2 1 Standard build configurations 76 Atmel AVR2025 Based on the IEEE 802 15 4 standard there are four basic standard configurations available which provide different functionality to the user application This implies different APls for each of these configurations and also different footprints codes size SRAM utilization These standard configurations can be classified in two categories e Support of beacon enabled networks e Reduced Functional Devices RFD f
218. l located in the AVR2025 top directory The main MAC stack software consists of three layers starting from the bottom up e Platform Abstraction Layer PAL e Transceiver Abstraction Layer TAL MAC Core layer MCL For other stack layers please refer to Section 2 2 8412D AVR 5 12 Atmel AVR2025 2 1 4 Platform abstraction layer PAL The Platform Abstraction Layer PAL contains all platform that is MCU and board specific functionality required by the MAC software packages and provides interfaces to the upper modules Therefore all upper modules are independent from the underlying platform Since some components of the PAL maybe dependent on the actual platform board certain functionality within the PAL has to be implemented for each setup like LEDs and buttons For each microcontroller a separate implementation exists within the PAL layers The board and application needs are adapted via a board configuration file pal config h This board configuration file exists exactly once for each supported hardware platform The PAL provides interfaces to the following components e Transceiver access functionality that is via SPI or direct memory access e GPIO control access from microcontroller to the GPIO pins connected to the transceiver e Low level interrupt handling e Timers high priority and software timers e Serial stream I O support via USB or UART e Access to persistent storage for example EEPRO
219. le UART1 etc is not required here since this application does not use SIO functionality 11 4 3 4 Step 4 Update the IAR project files The IAR project files Star eww and Star ewp of the target platform which were duplicated from the base platform are now located in the application build directory of the target platform that is Applications MAC_Examples Star_Nobeacon AT86RF231 ATXMEGA256A3 REB 4 1 CBB GCC In order to support the target platform the Star ewp file needs to be updated as follows e Select the proper MCU Atmel ATxmega256A3 for this project within IAR Workbench e Correct the proper used SIO channel is not required for here since this application does not use SIO functionality This can be done using an XML editor or within IAR Workbench e Change all occurrences of ATXMEGA128A1 which are used as path names for directories and files to ATXMEGA256A3 This can be done using an XML editor a regular text editor or within IAR Workbench 11 4 8 5 Step 5 Update the Atmel AVR Studio project files The AVR Studio project file that is aps file of the target platform which were duplicated from the base platform are now located in the application build directory of the target platform that is Applications MAC Examples Star Nobeacon AT86RF231 ATXMEGA256A3 REB 4 1 CBB GCC In order to support the target platform the file Star aps needs to be updated as follows 24 Atmel
220. leeping state for the transceiver and requires much more energy than a power safe state this behavior is usually applied for all mains powered nodes such as PAN Coordinators or Coordinators Routers nodes built using build switch FFD see Section 6 2 1 1 As mentioned MAC power management works automatically within the stack Once a node is started it is automatically in power save mode This is handled by the MAC PIB attribute macRxOnWhenldle The default value for macRxOnWhenldle is False that is the radio shall be off in case the node is idle meaning that the radio will be in sleep mode This is valid for all nodes including End Devices Coordinators and PAN Coordinators Any node that shall not be in sleep as the default mode of operation needs to be put in listening mode by setting the PIB attribute macRxOnWhenldle to True Usually this is only done for mains powered nodes such as Coordinator or PAN Coordinators This will be explained in more detail in the subsequent sections For battery powered nodes usually End Devices the default state shall be sleeping since otherwise the battery would be emptied too fast Since the PIB attribute macRxOnWhenldle is per default set to False such nodes will automatically enter SLEEP state when there is nothing to be done for the transceivers The transceiver of such nodes will be woken up automatically whenever a new request from the upper layer for example the application on top of the MAC or
221. les Table 9 10 File list for Performance Test application File name Short description of contents main c Main application task TX done handler amp Rx callback functions represents entire state machine user_interface c User interface related functions like LED Serial prints buttons init_state c Board and startup application initialization functions represents INIT State wait_for_event c Functions for waiting for events like character on UART Key press etc represents WAIT_FOR_EVENT state peer_search_initiator c Proprietary Peer Search related functions as Initiator represents PEER SEARCH PER TX amp PEER SEARCH RANGE TX states peer search receptor c Proprietary Peer Search related functions as Receptor represents PEER SEARCH RX amp PEER SEARCH RANGE RX states range measure c Range measurement related functions represents RANGE TEST TX OFF amp RANGE TET TX OFF states per mode initiator c PER measurement related functions as Initiator represents PER TEST INITIATOR amp SINGLE NODE TESTS states per mode receptor c PER measurement related functions as Receptor represents PER TEST RECEPTOR state per mode common utils c Common utility function related to all PER mode states AIMEL 169 amp 8412D AVR 5 12 9 2 2 1 4 Limitations 9 2 2 2 1 Introduction 9 2 2 2 2 Requirements 9 2 2 2 3 Implementation 10 Atmel AVR2025 AIMEL amp
222. lesWPromiscuous Mode Demo cd AT86RF231_AT91SAM3S4C_SAM3SEK cd GCC The SAM Boot Assistant SAM BA software provides a means of easily programming different Atmel AT91SAM devices They are based on a common dynamic linked library DLL the SAMBA DLL DLL It is used by SAM BA tool SAM BA now use the DLL to communicate with the target SAM PROG will remain available in the at91isp v1 13 User who still wants SAM PROG can download AT91 ISP v1 13 The user can connect through J Link ARMO if SAM BA is used or The user connect to the port as it is detected in the system if SAM BA is used Note The user has to make sure that the device is running in bootloader mode Select the type of device and then click connect This is explained in detail in Figure 8 Once the device gets connected successfully with the SAM BA tool the user has to follow the steps below to enable flash access and to erase the flash and for AMEL 127 8412D AVR 5 12 AIMEL downloading the file the user has to browse for the executable file and then click send file to write into the flash This is explained in detail in Figure 8 Figure 8 46 Atmel SAM BA using J Link Atmel SAM ICE SAM BA 2 10 Select the connection Y silink amp RM m Select your board at381sam3s4 ek Figure 8 47 SAM BA using comport CDC 2 10 Select the connection ists Select your board at31sam3s4 ek
223. me Step 3 Within the TAL in function tal tx frame see file TAL tal type Src tal tx c a pointer is set to the location of the actual MPDU inside the frame buffer member mpdu of structure frame info t This pointer is used for initiating the frame transmission by means of function send frame with the appropriate parameters for CSMA CA and frame retry 24 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 4 5 Frame buffer handling during data frame transmission part 2 TAL MCL MAC API Step 4 Step 5 Step 6 A msg_type cmd code cmd_code 9 MCPS_DATA_ CONFIRM B cMCPS DATA CONFIRM 8 buffer_header msduHandle i msduHandle 5 as 328 2 msduHandle 818 status 82 status persistence time E time stamp LE time stamp only for indirect transmission indirect_in_transit s for indirect transmission E time stamp 5 Filled after Tx Y mpdu Free Area Free Area Free Area handle tx end irq gen data cont mcps data conf in and tx done handling mac mcps data c mac callback wrapper c in tal tx c Step 4 Once the transmission of the frame has been finished either successfully or unsuccessfully the transceiver generates an interrupt indicating the end of the transmission This
224. me This application requires a serial connection to send AT commands from host and receive responses from the module Depending on the available Serial I O interface for each board this can be either UART or USB A sniffer is suggested in order to check the proper association and the data transfer between the devices AIMEL 151 9 2 1 8 3 152 AIMEL Implementation amp The host sends commands to the module which replies with text messages information responses and each of the messages is terminated by a result code which is mostly OK or ERROR Each command is prefixed by the AT string followed by the chained commands to be executed consecutively Any result code relates to the latest command performed in the sequence In case of any command executed incorrectly the command sequence is interrupted and the ERROR result code is returned Information responses for any command are returned in an easily recognizable string format Each command in a sequence may be of different syntax depending on whether it is used to execute an action to read or to write parameter s or it is used to test valid parameter range The standard AT command set is extended to support communicate with 802 15 4 network Table 9 1 Example illustrating extended command set Command Response Command to module AT PIB00 0C PIB53 Comment Set the PIB 00 channel to 12 0x0C and show the PIB 53 short address value Information respons
225. me with zero length payload e Setting of Frame Pending bit in the Frame Control field e Adding of address of nodes with pending frames in the beacon frame payload 8412D AVR 5 12 Atmel AVR2025 Figure 4 11 Example of provided functionality for MAC_INDIRECT_DATA_BASIC and MAC_INDIRECT_DATA_FFD Node using Node FFD using MAC_INDIRECT_DATA_BASIC MAC_INDIRECT_DATA_FFD App MAC MAC A wpan mops data req Indirect wpan mlme poll req 2 9 Data Request Frame e a E c S o Data Frame usr mlme poll conf bh p usr mocps data ind h usr mcps data conf 44 3 MAC PURGE REQUEST CONFIRM This feature is a typical FFD feature allows a node to purge pending indirect frames from its Indirect Data queue by means of using functions wpan mcps purge req usr mcps purge conf Since purging of pending data requires handling of transmitting indirect frames the feature MAC INDIRECT DATA FFD is also required 4 4 4 MAC ASSOCIATION INDICATION RESPONSE This feature is a typical FFD feature that allows a node to receive and process association request frames and handle them properly In case the network uses short addresses a short address may be selected and returned to the initiating device by means of association response frame Since the association procedure is perform using indirect traffic and the node using MAC ASSOCIATION INDICATION RESPONSE has to transmit the association r
226. measurement One of the nodes should be connected to the UART terminal program The node connected to the UART is referred as transmitter and other node need not be connected to the UART is referred as receiver 160 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 After the boards are turned on if any character is received on the UART then the node transmitter tries to find its peer node i e receiver The procedure to find the peer node is explained in detail in the Section 9 2 2 1 3 3 and the sequence is proprietary e Press any character on the UART terminal and the device initiates the procedure to find its peer i e Peer Search Process as shown in below Figure 9 10 Initializing PER measurement Character received PER Measurement mode os ENTER to Abort Search for Peer Device and to start single node operation mode Search for Peer Device 1 111 1 Ifthe peer node is found then a menu appears as shown in Figure 9 11 The menu is described in Table 9 6 Figure 9 11 Main Menu after Peer Search Process in PER mode is successful Character received PER Measurement mode Press ENTER to Abort Search for Peer Device and to start single node operation mode Search for Peer Device Initiated Peer device found Starting PER Measurement mode as Transmitter 3 3 JE JE 3 JE JE 3
227. mentation conformance statement PICS 236 12 1 Major roles for devices compliant with IEEE Std 802 15 4 2006 236 12 2 Major capabilities for the 236 12 3 Major capabilities for the MAC 237 12 3 1 MAC sub layer functions esssssssseeeeeeneennenneen nennen 237 12 3 2 eit 238 12 239 E 240 15 User guide revision 241 15 1 Rev 2025M MCU 5 06 12 241 15 2 Rev 2025M MCU 5 10 11 241 15 3 Rev 2025L MCU 5 07 11 241 15 4 Rev 2025K MCU 55 08 11 241 15 5 Rev 2025J MCU 5 03 11 241 15 6 Rev 2025I MCU 55 10 10 242 15 7 Rev 2025H MCU 5 08 10 44 242 15 8 Rev 2025G MCU 5 08 10 000 0 242 15 9 Rev 2025F MCU 55 02 10 242 15 10 Rev 2025E MCU Wireless 01 10 sees 242 15 11 2025B MCU 55 09 09 00 nnne 243 15 12 Rev 2025 AVR 04 089 sss nennen nen
228. mlme_poll_conf c usr mlme rx enable conf c s Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 e Window will pop up indicating the status of the download of the binary After successful download the IAR ARM Workbench will looks as shown in Figure 8 5 After the download of the debug build the main function is displayed since all debug and source code information is included in the build Figure 8 45 IAR ARM Embedded Workbench successful download of debug build X Embedded Workbench IDE Ani xi File Edit View Project Debug mkII Tools Window Help E SX mE 712 HS P BH RR S eb ADEYE jace 51 0035 4 0035 6 COMAC_API TER C3PAL 0035 0 gl C3 Resources E t E main c E C3 Output Log Tue Mar 17 11 51 41 2009 AVR JTAGICE mkll HA version 0 0100 SAV version 0x052C 0 052 Device id 0x970403F Tue Mar 17 11 51 41 2009 JTAG clock approx 98 KHz Target voltage 2 940 V CPU 1281 Tue Mar 17 11 51 45 2009 Loaded debugee c Atmel MAC_v_2_2_0 Applications MAC_Examples Star_Nobeacon AT86RF231_ATMEG4 e Start the application by pressing the F5 or the Go button 8 3 8 Using Atmel SAM BA programming for Atmel SAMSS devices The application can be downloaded using SAM BA software Change to the directory where the Makefile for the application is located for example cd Applications Examp
229. mments and for specifying the generated output files PROJECT ue Add the path for the generic SIO support functions see Section 9 3 PATH SIO SUPPORT MAIN DIR Applications Helper Files SIO Support Enable SIO support for this application via the supported SIO channel In this example UART1 is used Change CFLAGS Wall Werror g Wundef std c99 Os to CFLAGS Wall Werror g Wundef std c99 DSIO DUART1 Os Update the used and or unused compiler flags The base example application Star Nobeacon used the compiler switches FFD and REDUCED PARAM CHECK that are not required anymore for the target application On the other hand the target application requires the build switch PROMISCUOUS MODE Therefore change CFLAGS 226 Atmel AVR2025 DD EBUG 0 8412D AVR 5 12 Atmel AVR2025 CFLAGS DFFD CFLAGS DREDUCED PARAM CHECK CFLAGS DTAL TYPE TAL TYPE CFLAGS DPAL GENERIC TYPE PAL GENERIC CFLAGS DPAL TYPE PAL CFLAGS DBOARD TYPE BOARD TYPE CFLAGS DHIGHEST STACK LAYER HIGHEST STACK LAYER to CFLAGS DDEBUG 0 CFLAGS DPROMISCUOUS MODE CFLAGS DTAL TYPE TAL TYPE CFLAGS DPAL GENERIC TYPE PAL GENERIC CFLAGS DPAL
230. mmunication between mains powered nodes and battery powered nodes applying power management in both directions This is explained in more detail in the following section One way to allow communication from the PAN Coordinator to the End Device is to use a timer which wakes up the End Device periodically allowing this device to receive frames during this time period from other nodes This is implemented in MAC example Basic Sensor Network see Section 9 2 1 1 5 2 Reception of data at nodes applying power management 5 2 1 5 2 2 52 When data shall be received by an End Device that is a node applying MAC power management as default we have several options as described in the subsequent sections Setting of macRxOnWhenldle to true Enabling the receiver Atmel AVR2025 One option is to leave the receiver of the node always on so the device is able to always receive frames This can be done be setting the MAC PIB Attribute macRxOnWhenldle to True 1 by using the API function wpan set req at any time This will immediately wake up the radio and enable the receiver of the node If this scheme is applied the node will not enter SLEEP state anymore and thus use is battery power very extensively So for battery powered End Devices this is not recommended although it might be an easy solution for mains powered End Devices If a PAN Coordinator wants to send data to an End Device periodically the application of the De
231. n 2 4 0 22 Atmel AVR20 Support for AT86RF231 and AT86RF212 with AT91SAM7X256 added Support for ATnega128RFA1 EK1 added Build switch DISABLE TSTAMP IRQ added Support for ATmega1284P removed Support for ATxmega256A3 MAC Porting Guide using ATxmega256A3 as example added MAC Examples App 3 Beacon Payload and App 4 Beacon Broadcast Data added Build switch SYSTEM CLOCK MHZ renamed to F_CPU Updated handling of MAC PIB attribute macRxOnWhenldle and MAC power management 25 8412D AVR 5 12 50 51 52 53 Atmel AVR2025 New build switch BAUD_RATE added Support for AT86RF230A and related hardware platforms discontinued Handling of callback stub functions added Handling of callback stub functions added PICS Table added 15 11 Rev 2025B MCU Wireless 09 09 Released with AVR2025 MAC Version 2 3 1 15 12 Rev 2025 AVR 04 09 Name of Radio Controller Board RCB changed transceiver number suffix is replaced by board suffix Support for ATmega128RFA1 added Handling of Promiscuous Mode updated Migration Guide for previous MAC versions removed Filter tuning section added Description of Performance test application extended Support for ATxmega MCU based AES within SAL Handling of MAC components updated Initial Support for AT91SAM7X256 added DISABLE IEEE ADDR CHECK added Chapter Supported Platforms added Chapter Topics on Platforms Porting added Released with AVR2
232. n depending upon the highest stack used 6 1 1 2 REDUCED CHECK Whenever an application or a higher layer accesses an API function of a lower layer usually a variety of parameter checks are done in order to ensure proper usage of the desired functionality This leads to a more robust application On the other hand if the higher layer is designed to always call an API function with reasonable parameter values this build switch might be omitted This will reduce the code size As an example what this build switch causes please check MAC Src MAC mac_meps_data c In function mcps data request a number of additional checks are performed if this switch is not set It is strongly recommended to disable this build switch at least during the development cycle of the application Usage in Makefiles CFLAGS DREDUCED PARAM CHECK disables the additional parameter checking Usage in IAR ewp files REDUCED PARAM CHECK reduces the additional parameter checking AMEL so 60 Atmel AVR2025 AIMEL 6 1 1 3 PROMISCUOUS MODE This build switch allows for the creation of a special node that can be put into promiscuous mode thus allowing it acting as a very simple frame sniffer on a specific sniffer It can be used a very simple network diagnostic tool amp When this switch is enabled the node is supposed to act as a standard node being part of network that is the node will
233. n to search for existing networks e MAC SCAN ED REQUEST CONFIRM The node is able to perform an energy detect scan e MAC SCAN ORPHAN REQUEST CONFIRM The node is able to perform an orphan scan in case it has lost its parent e MAC SCAN PASSIVE REQUEST CONFIRM The node is able to perform a passive scan to search for existing networks This feature is only enabled if also BEACON SUPPORT is enabled e MAC START REQUEST CONFIRM The node is able to start its own network Depending on the setting of BEACON SUPPORT this can be either only a non beacon enabled network or also a beacon enabled network e MAC SYNC LOSS INDICATION The node is able to report a sync loss condition to its upper layer This can be either the reception of a coordinator realignment frame from its parent or if BEACON SUPPORT is enabled and the node is synchronized with its parent caused by the fact that the node has not received beacon frames from its parent for a certain amount of time Please check IEEE 802 15 4 2006 for further information about the MAC primitives and the implementation of their corresponding features in the MAC 6 2 1 2 RFD feature set The following features are enabled if FFD is NOT set during the build process e MAC ASSOCIATION REQUEST CONFIRM The node is able accept and process a request from its upper layer for example the network layer to associate itself to another node that is its parent MAC BEACON NOTIFY INDICATION The node is able to pr
234. nce_time 9 5 persistence_time al 5 i only for indirect transmission only for indirect transmission eo lt indirect in transit So lt indirect in transit zo indirect_in_transit i indirect_in_transit 2 only for indirect transmission 2 only for indirect transmission To 9 time_stamp time_stamp mpdu Free Area gt Free Area Length of MPDU e gt Length of MPDU MAC Header x p re MPDU az 1 MSDU 44 azis Hu344ng8 35uyvileyng y gyun tal tx frame in tal tx c uint8 t frame ptr uint8 t tal frame to tx Step 1 The application not using dynamic buffer management for frame transmission requires a static buffer for frame to be transmitted such as static uint8 t storage buffer LARGE BUFFER SIZE A large buffer is big enough to incorporate the longest potential frame to be transmitted based on 4 Later a structure of type frame info tis overlaid over the static transmit buffer tx frame info frame info t storage buffer For more information about the frame info t structure see file TAL Inc tal h The static frame buffer is filled with the MSDU that is the actual application payload and the MAC Header information as required by this frame Note that also a free format frame not compliant with 4 can be created within the applica
235. nd call the corresponding function mcps_data_request see file MAC Src mac_mcps_data c The following functions are performed e Parsing of MAC address information e Creation of the actual MAC frame by filling the information structure structure frame info t see file TAL Inc tal h e The frame_info_t structure for the data frame contains a fully formatted MAC frame including the MAC Header information and the MSDU that is the MAC payload of the frame the MSDU is not copied again during this process of the MAC frame creation D Once the MAC frame is properly formatted the corresponding TAL API function is called in order to initiate the actual frame transmission see function tal_tx_frame declaration in TAL Inc tal h The TAL functions required the frame_info_t structure as input E Inside the TAL no further formatting of the MAC frame is done The frame is transmitted using the requested CSMA CA scheme and retry mechanism This is done by means of using PAL functions and the provided hardware F For further information check function tal_tx_frame in file TAL tal_type tal_tx c AIMEL 19 AIMEL 4 1 1 2 Part 2 Data frame clean up and confirmation amp Figure 4 2 Data frame transmission procedure Part 2 usr mcps data conf mac_callback_ wrapper c vos aaa o MAC NHLE Queue F MCL tal tx frame tal
236. ndard 7 enable xOnDuration in hex gt 802 15 4 2006 for request and confirm details Active Pa SCAN lt ScanType ScanChannels Refer section 7 1 11 1 and 4 7 1 11 2 of IEEE Standard SCAN ssive ScanDuration Scan Ch linh 802 15 4 2006 for request annelPage all in hex gt and confirm details AIMEL 153 154 AIMEL Y AT Function a Format Comment Command alities Refer section 7 1 13 1 and Set PIB lt MAC identifier in 7 1 13 2 of IEEE Standard TOUS write Hex gt lt Value gt 802 15 4 2006 for request and confirm details START lt PANId LogicalChannel C Refer section 7 1 14 1 and hannelPage BeaconOrder Superfr Start 7 1 14 2 of IEEE Standard START ameOrder PANCoordinator Battery Request 802 15 4 2006 for request LifeExtension CoordRealignment and confirm details all in hex gt Refer section 7 1 15 1 of SYNC 2 eee IEEE Standard 802 15 4 ge 2006 for details Refer section 7 1 16 1 and POLL Poll POLL lt CoordAddrMode CoordPA 7 1 16 2 of IEEE Standard Request Nid CoordAddress all in hex 802 15 4 2006 for request and confirm details Auto address allocation is used to allocate address by the AT command interface rater than by user as the time out for association indication is very less Auto 1 enables the functionality and AUTOADD Auto AUTOADDR lt auto 0 or 1 short 98008 101 indication is addres
237. ndirect data usage wpan mlme poll req usr_mlme_poll_conf e Transmission of data request frames to its parent e Reception of indirect data frames e Initiation of implicit polling for indirect data that is transmission of data request frame without an explicit call of function wpan mlme poll req o Polling for an association response frame during the association procedure o Polling for more pending data once a received frame from its parent has indicated more pending data at the parent o Polling for pending data in case a received beacon frame from its parent has indicated pending data at the parent MAC INDIRECT DATA FFD This feature is a further extension of the feature INDIRECT DATA BASIC that is in order to use INDIRECT DATA FFD also MAC INDIRECT DATA BASIC is required It is designed for FFDs PAN Coordinators or Coordinators to allow the handling of transmitting indirect data frames This feature includes the following functionality e Initiation of indirect data transmission usage of wpan data req with TxOption Indirect Transmission e Handling of the Indirect Data Queue o Adding and removing of indirect frames o Handling of a persistence timer in order to check for expired transactions e Transmission of association response frame or indirect disassociation notification frames e Handling of received data request frames and the proper responses either with pending frames or a data fra
238. nen nnns 243 AMEL 8412D AVR 5 12 248 AMEL 16 Table of contents eese nna na nhau naa un aaa uaa anas an aaa 244 17 Table of figures Atmel AVR2025 8412D AVR 5 12 17 Table of figures 8412D AVR 5 12 Atmel AVR2025 Figure 2 1 MAC architecture ceccceecceeeceeeeeeeeeeneeceeeeeseaeeeeaaeeeeeeeseaeeesaeeeeaaeseeeeeeaas 2 Figure 2 2 StACK IET E 6 Figure 4 1 Data frame transmission procedure Part 1 18 Figure 4 2 Data frame transmission procedure Part 2 20 Figure 4 3 Data frame reception 21 Figure 4 4 Frame buffer handling during data frame transmission part 1 23 Figure 4 5 Frame buffer handling during data frame transmission part 2 25 Figure 4 6 Frame buffer handling during data frame reception 27 Figure 4 7 Frame buffer handling during frame transmission using TAL API 30 Figure 4 8 Frame buffer handling during frame reception using TAL API 32 Figure 4 9 Configuration file include hierarchy sese 34 Figure 4 10 Essential and supplementary MAC components 37 Figure 4 11 Example of provided functionality for MAC INDIRECT DATA BASIC and MAC INDIRECT DATA
239. ng currently supported SIO channels needs to be enabled well DUARTO DUART1 DUSBO f the build switch SIO HUB is not set no further SIO channel needs to be defined o Other specific build and link options if required e Step 4 Update the IAR project files Usually all required changes for the IAR Workbench are to done in the ewp file This includes changing of the paths for includes and source files referring to the proper MCU Also the proper MCU needs to be selected within the options for this project Other changes may include updating the proper SIO channel etc 11 3 3 1 Step 1 Identify the application to be ported to the target platform The MAC application Star Nobeacon shall be enabled on the target board Atmel AT91SAM7X EK with Radio Extender board REB231 V4 0 on REX ARM adapter Revision 3 REB 4 0 2 REX ARM REV 3 For more information about the platform bring up for this target platform see the previous sections This MAC application is located in directory Application MAC Examples Star Nobeacon 11 3 3 2 Step 2 Identify the best matching base platform The best matching base platform for the target board AT91SAM7X EK with Radio Extender board REB231 V4 0 on REX ARM adapter Revision 3 REB 4 0 2 REX ARM REV 3 is the AT91SAM7X EK with Radio Extender board REB230B V2 3 on REX ARM adapter Revision 2 REB 2 3 REX ARM REV 2 This entire build files for this particular base platform are located in d
240. ng eww file the application can be downloaded onto the desired hardware platform as described below 8 3 4 1 Starting the release build The release build can simply be started as follows e Make sure that only the JTAGICE of the node where the current build shall be downloaded to is switched on Switch off all other JTAGICE e Open IAR Embedded Workbench by double clicking the desired eww file e Select the Release Workspace e Open the Options window for the Release Workspace Select the Debugger window and within this window select the Setup tab AIMEL 109 amp 8412D AVR 5 12 AIMEL quM Figure 8 25 IAR Embedded Workbench Options gt Debugger gt Setup Options for node Star x Category General Options C C Compiler Assembler Custom Build Build Actions 1 200 Use UBROF reset vector JTAGICE Setup macros JTAGICE mkII r Dragon Use macro file Simulator Third Party Driver Device description file Override default TOOLKIT DIR Configiom281 ddf Cancel Within the Setup tab select the Driver JTAGICE mklI and deselect Run to main e Change to the Plugins tab and deselect all entries Figure 8 26 IAR Embedded Workbench Options gt Debugger gt Plugins x Category Factory Settings General Options C C Compiler Assembler Custom Build Setup Plugins
241. nused compiler flags The base example application Star Nobeacon used the compiler switches FFD and REDUCED PARAM CHECK that are not required anymore for the target application On the other hand the target application requires the build switch PROMISCUOUS MODE In file Promiscuous Mode Demo ewp change lt name gt CCDefines lt name gt lt state gt DEBUG 0 lt state gt lt state gt FFD lt state gt lt state gt REDUCED_PARAM_CHECK lt state gt state TAL TYPE AT86RF231 state state PAL TYPE ATXMEGA256A3 state state PAL GENERIC TYPE XMEGA state state BOARD TYPE REB 4 1 CBB lt state gt Xstate HIGHEST STACK LAYER MAC state to lt name gt CCDefines lt name gt lt state gt DEBUG 0 lt state gt lt state gt PROMISCUOUS_MODE lt state gt lt state gt SIO_HUB lt state gt lt state gt UART1 lt state gt state TAL TYPE AT86RF231 state state PAL TYPE ATXMEGA256A3 state state PAL GENERIC TYPE XMEGA state state BOARD TYPE REB 4 1 CBB lt state gt state HIGHEST STACK LAYER MAC state e Update the used and or unused included directories file Promiscuous Mode Demo ewp The base example application Star Nobeacon did not use SIO support so this needs to be added to the target
242. ode larger than 128Kbyte is not supported by this software package Nevertheless there are a number of workarounds to overcome this issue by forcing all functions which shall be accessed via function pointers into the lower 128Kbyte of memory Such a workaround implementation for AVR GCC is not provided by this software package The stack has been modified in order to support function pointers which can address functions residing in the program memory larger than 128Kbyte 8412D AVR 5 12 Atmel AVR2025 4 5 2 1 File avrtypes h The header file avrtypes h residing in directory PAL Inc contains the following construct in the section dedicated to IAR based builds if FLASHEND gt Oxl1FFFF Required for program code larger than 128K define FUNC_PTR void __farflash else define FUNC_PTR void endif ENABLE FAR FLASH In case the utilized AVR MCU provides more than 128Kbyte of flash memory all function pointers defined by FUNC_FAR are defined as 24 bit pointers 4 5 2 2 Function pointers as function parameters Function parameters which are actually function pointers need to be defined as FUNC_PTR in order to allow for 24 bit support This is implemented in the following two PAL API functions e pal_trx_irq_init void pal_trx_irq_init trx_irg_hdlr_idx_t trx num FUNC trx irg cb e pal timer start retval t pal timer start uint8 t timer id uint32 t timer count timeout type
243. of the highest layer of the stack tal config h config h etc is included in order to calculate the resource requirements at compile time This file must not be changed by the end user 4 3 8 PAL resource configuration pal config h The PAL layer does not require own resources such as timer or buffers so this does not need to be taken into consideration in the resource calculation for the application Nevertheless there exists a unique pal config h file for each platform type for example for each board which be found the directories PAL pal generic type name pal type name Boards board type name for example PAL AVR ATMEGA1281 Boards REB 4 0 231 These pal config h files define all platform specific hardware components 4 3 4 TAL resource configuration tal config h 8412D AVR 5 12 The TAL layer uses its own configuration config h located in directory TAL trx name lnc that is each transceiver and thus each TAL implementing code for a specific transceiver has its own TAL configuration file e TAL ATMEGARF TAL 1 Inc for ATmega128RFA1 e TAL AT86RF212 Inc e TAL AT86RF230B Inc e TAL AT86RF231 Inc e TAL AT86RF232 Inc AMEL s 4 3 5 4 3 6 4 3 7 4 3 8 36 IMPORTANT AIMEL amp e Etc These configuration files define the following items e Transceiver dependent values required by any upper layer radio wake up time e Timers and their IDs used within this particul
244. of the normalized LQ value based on RSSI ED value For more information please check the implementation files TAL tal type Src tal rx c 6 1 4 6 ENABLE FTN PLL CALIBRATION This build switch is used to enable the filter tuning and PLL calibration for the transceiver Once this feature is enabled in an application a period timer is started which ensures that the proper filter tuning and PLL calibration is executed after a certain amount of time 7 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 This feature might be required in case the environment conditions that is temperature vary over time The filter tuning and PLL calibration is done automatically when a node periodically enters sleep state or when other specific state changes are performed within the transceiver periodically For more information please check the corresponding transceiver data sheets The current timer interval is five minutes that is whenever the node does not enter sleep state within this timer interval the filter tuning and PLL calibration mechanism will be invoked This switch is currently not enabled in any example application 6 1 4 7 DISABLE_IEEE_ADDR_CHECK This build switch is used to disable the check whether the node has a valid IEEE address that is the IEEE address is different from 0 or OXFFFFFFFFFFFFFFFF Currently all TAL and MAC based applications require a valid and unique IEEE address being present on each node
245. onf o DIR usr mlme beacon notify ind o S TARGET DIR usr mlme disassociate conf o S TARGET DIR usr mlme disassociate ind o TARGET DIR usr mlme get conf o ATTE 227 8412D AVR 5 12 to AMEL TARGET_DIR usr_mlme_orphan_ind o 5 TARGET DIR usr_mlme_poll_conf o DIR usr mlme rx enable conf o DIR usr mlme sync loss ind o Objects that must be built in order to link OBJECTS TARGET_DIR main o TARGET_DIR sio_handler o TARGET DIR pal_uart o TARGET DIR mac api o 5 DIR usr mops data conf o DIR usr mcps purge conf o S TARGET DIR usr mlme associate conf o S TARGET DIR usr mlme associate ind o DIR usr mlme beacon notify ind o TARGET DIR usr mlme comm status ind o S TARGET DIR usr mlme disassociate conf o S TARGET DIR usr mlme disassociate ind o TARGET DIR usr mlme get conf o TARGET DIR usr_mlme_orphan_ind o TARGET DIR usr mlme poll conf o DIR usr mlme rx enable conf o S TARGET DIR usr mlme scan conf o S TARGET DIR usr mlme start conf o DIR usr mlme sync loss ind o e Update the used and or unused list of files to be compiled Change Compile TARGET_DI
246. or Location C Program Files IAR Systems Embedded Workbench 5 4_ ST Link Third Party Driver Originator IAR Systems Version 5 50 0 51907 m DK Cancel e Press e Press the button Download and Debug Figure 8 44 IAR ARM Embedded Workbench start Download and Debug IAR Embedded Workbench IDE m Edit View Project Simulator Tools Window Help 17 Reserved MCI IrqHandler 18 MCI TWIO IrqHandler 19 IWI 0 TWIl IrqHandler 20 i La MAC API SPI_IrqHandler IU fi SPI i SSC IrqHandler 22 SSC TCO_IrqHandler 23 Timer Counter 0 TCl IrqHandler 24 Timer Counter 1 TC2_IrqHandler 25 Timer Counter 2 TC3_IrqHandler 26 Timer Counter 3 a O startup TC4_IrqHandler 27 Timer Counter 4 E TCS_IrqHandler 28 Timer Counter 5 E exce IrqHandler 29 ADC controller D pal c DAC IrqHandler 30 DAC controller D pal_s PWM_IrqHandler 31 PUM pal ti CRCCU_IrqHandler 32 CRC Calculation Unit pal tr ACC_IrqHandler 33 Analog Comparator pal 1 USBD_IrqHandler 34 USB Device Port IrqHandlerNotUsed 35 not used pal a O Resour 000 pg ii a CITAL Exception Table main c Ly La Coordinator Messages usr_
247. or if BEACON SUPPORT is enabled and the node is synchronized with its parent caused by the fact that the node has not received beacon frames from its parent for a certain amount of time The following features are disabled if FFD is NOT set during the build process ASSOCIATION INDICATION RESPONSE The node is not able to handle association attempts from other nodes DISASSOCIATION FFD SUPPORT The node is not able to transmit an indirect disassociation notification frame MAC INDIRECT DATA FFD The node is not able to handle requests to transmit data frames indirectly MAC ORPHAN INDICATION RESPONSE The node is not able to handle orphan indication frames by other nodes MAC PAN ID CONFLICT AS PC The node is not able to act upon the reception of PAN Id Conflict Notification Command frames MAC PURGE REQUEST CONFIRM The node is not able to purge indirect data SCAN ED REQUEST CONFIRM The node is not able to perform an energy detect scan MAC SCAN PASSIVE REQUEST CONFIRM The node is not able to perform a passive scan MAC START REQUEST CONFIRM The node is not able to start its own network Please check IEEE 802 15 4 2006 for further information about the MAC primitives and the implementation of their corresponding features in the MAC 8412D AVR 5 12 AIMEL 79 AIMEL 6 2 1 3 BEACON_SUPPORT feature set If BEACON SUPPORT is set during the build process all functionality required to support beacon enabled n
248. or TAL must not be changed since these layers residing on top of the PAL are completely independent from the selected platform This MAC application is located in directory Application MAC_Examples Star_Nobeacon 11 4 3 2 Step 2 Identify the best matching base platform The best matching base platform for an Atmel ATxmega256A3 placed on the CBB board with Radio Extender board REB231ED V4 1 1 with Atmel AT86RF231 is the Atmel ATxmega128A1 on the same hardware setup CBB board with REB231ED V4 0 see Sections 10 4 2 4 and 10 4 3 2 This entire build files for GCC and IAR for this particular base platform are located in directory AT86RF231_ATXMEGA256A3_REB_4 0 CBB within the application directory Applications MAC_Examples Star_Nobeacon The entire directory Applications MAC_Examples Star_Nobeacon AT86RF231 ATXMEGA128A1 REB 4 1 STK600 is copied and renamed to Applications MAC Examples Star Nobeacon AT86RF231 ATXMEGA256A3 REB 4 0 CBB Usually the directory name for applications consists of the following items to uniquely identify the target platform e TAL TYPE AT86RF230B e PAL TYPE ATXMEGA256A3 e PAL GENERIC TYPE XMEGA e BOARD TYPE REB 4 0 CBB IMPORTANT Make sure that the build switch HIGHEST STACK LAYER is not changed This build switch always needs to reflect the proper highest stack layer that the application is residing on In case of a MAC application such as the Star No
249. or example phyCurrentPage 17 for 2Mbit s support after setting the correct channel page all frames will be transmitted using the corresponding data rate belonging to this channel page Table 4 1 shows which data rate can be selected by setting a specific channel page using a particular transceiver The table entries with yellow background refer to Atmel proprietary channel pages for non standard high rates Please note that the standard channel page is always channel page 0 amp Table 4 1 Channel pages vs data rates MAC 2003 Frequency band compliant MAC 2006 High data High data transceiver channel page 0 compliant rate mode 1 rate mode 2 Sub 1 GHz 20kb s 110dBm Channel Channel 0 40kb s 108dBm Page 2 Channel 1 10 100kb s AT86RF212 250kb s Chinese Band N A Channel Channel 0 3 Page 5 AT86RF212 250kb s 2 4GHz 250kb s 101dBm Channel 11 26 AT86RF231 ATmega128RFA1 Notes 1 PSDU data rate 2 BPSK 3 Reserved channel pages are used to address the appropriate mode non compliant Marked w yellow background color The Atmel AT86RF212 s sensitivity values for the proprietary modes are based on PSDU length of 127 bytes 4 Scrambler enabled 5 Reduced ACK timing Proprietary channel pages can be enabled using build configuration switch HIGH DATA RATE SUPPORT 6 Proprietary channel pages 18 and 19 used for Chinese frequency band Pages 18 and 19 support
250. or example End Devices vs Full Functional Devices FFD PAN Coordinators Coordinators The Atmel MAC provides two build switches that be used in Makefiles or IAR Embedded Workbench project files to enable or disable these configurations Depending on the usage of these switches in the project the MAC provides certain functionality to the user application e Omitting of this build switch only enables functionality required for a simple RFD node e Setting of this build switch additionally enables functionality required for a FFD node SUPPORT 8412D AVR 5 12 Atmel AVR2025 e Omitting of this build switch only enables functionality required for a networks without using a superframe structure that is non beacon enabled networks e Setting of this build switch additionally enables functionality required for a network using a superframe structure that is beacon enabled networks MAC_SECURITY_ZIP e Omitting of this build switch only enables functionality required for a networks without security features e Setting of this build switch additionally enables functionality required for a network using security features Example 1 A node that shall start its own network always has to be an FFD because starting of networks is only supported for an FFD configuration Example 2 A node that shall be able to join both non beacon and beacon enabled networks has to use an application built with BEACO
251. orkbench start Download and Debug IAR Embedded Workbench IDE Edit Project Tools Window Help uae Beals ol a 4 em ex Download and Resources CATAL main c C3 Output m Messages Download the application and start the debugger e A Window will pop up indicating the status of the download of the binary e After successful download the IAR Workbench will looks as shown in Figure 8 After the download of the debug build the main function is displayed since all debug and source code information is included in the build Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 Figure 8 32 IAR Embedded Workbench successful download of debug build Embedded Workbench IDE xl File Edit View Project Debug mkII Tools Window Dc E 1215 gt p ADT ER zl Wo i Debug EMAC 0035 4 0035 6 Low 0035 8 PAL 0035F0 Resources 0035 4 003 8 main c 0035 La C3 Output 0035 0035 003600 003602 003604 003606 003608 0 00360 usr_nlme_reset_conf 00360E 2300 5 4 Log Tue Mar 17 11 51 41 2009 AVR JTAGICE mkll HAW version 0 0100 SAV version 0x052C 0 052 Device id 0x970403F Tue Mar 17 11 51 41 2009 JTAG clock approx 98 KHz Target voltage 2 940 V CPU ATmegal261 Tue Mar 17 11 51 4
252. orm of the corresponding application is located for example cd ApplicationsMMAC Examples MPromiscuous Mode Demo cd AT86RF212 ATMEGA1281 RCB 5 3 SENS TERM BOARD Double click on the corresponding IAR Embedded Workbench file eww file for example Promiscuous Mode Demo eww Select the desired workspace Release or Debug and Rebuild the entire application in IAR Embedded Workbench After building the application the subdirectory IAR Exe contains either an elf file in case the Release or Debug configuration was selected The binaries can be downloaded onto the hardware see Section 8 3 8412D AVR 5 12 Atmel AVR2025 The Release configuration binary elf file can both be downloaded using IAR AVR32 Embedded Workbench directly or AVR Studio The Debug configuration binary elf file can only be downloaded using IAR AVR32 Workbench and can be debugged using IAR AVR32 C Spy 8 2 6 Using IAR ARM Embedded Workbench Each application can be rebuilt using the IAR ARM Embedded Workbench directly Please follow the procedure as describe e Change to the directory where the IAR Embedded Workbench workspace file eww file for the desired platform of the corresponding application is located for example cd ApplicationsMMAC Examples MPromiscuous Mode Demo cd AT86RF231_AT91SAM3S4C_SAM3SEK e Double click on the corresponding IAR Embedded Workbench file eww file for example Promiscuous Mode Demo eww e Sel
253. ormation about build switches for the TFA e Continuous transmission o For specific measurements a continuous transmission a specific is required o In order to support this feature functions are implemented to initiate or stop a continuous transmission e Temperature Measurement Single Chip transceivers only function is implemented to read the temperature value from the integrated temperature sensor in degree Celsius For more information about the TFA implementation see file TFA Inc tfa h and the source code for the various transceivers TFA tal_type Src tfa c amp For further explanation of applications and the included example applications please refer Chapter 9 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 3 Understanding the software package The following chapter describes the content of the MAC software package and explains some general guidelines how the various software layers are structured 3 1 MAC package directory structure 8412D AVR 5 12 Once the MAC package has been extracted into the proper place the directory structure looks as follows MAC_v_2_8_0 Applications Helper Files 510 Support _ 1 I Nobeacon Application I coordinator I AT86RF212 AT32UC3A3256S RZ600 Hinc L sre L _pevice L AT86RF212 AT32UC3A3256S RZ600 I Beacon Application I coordinator 86 231_ 320 3 32565_ 7600
254. ormed by obeying the following steps a Expiration of Pre Beacon timer in MCL Preparation of next Beacon frame within MCL b Calling of TAL API function tal_prepare_beacon including the frame information structure to initiate formatting of frame in TAL Beacon frame is stored inside TAL until transmission time c Expiration of Beacon time in MCL Calling of TAL API function tal tx beacon to trigger immediate Beacon frame transmission d TAL used stored frame and initiates Beacon frame transmission Figure 7 2 Transmission of periodic Beacon Frames Release 2 4 x obsolete Release 2 5 x So tal_tx_beacon tal_prepare_beacon tal_tx_beacon frame info t frame info 4 void Phase 2 Phase 1 Phase 2 Starting with release 2 5 x this has been simplified A Expiration of Pre Beacon timer in MCL Complete formatting of next Beacon frame within MCL not further interaction with TAL function tal_prepare_beacon does not exist anymore B Expiration of Beacon time in MCL Calling of TAL API function tal_tx_beacon to trigger immediate Beacon frame transmission function tal_tx_beacon contains complete Beacon frame already formatted TAL uses parameter of type frame_info_t in function tal_tx_frame to initate Beacon frame transmission In order to reduce code size and to taylor the actually included functionality of the PAL according to the use
255. ory and file structure of the target platform has been established AMEL 207 8412D AVR 5 12 AIMEL SSE The board directory of the target platform contains currently three files same as for the base platform e pal_board c e pal e pal config h Within the next phase all hardware resources need to be adjusted from the base platform to fit the resources of the target platform such as timers IRQs ports LEDs buttons ports and registers for SIO support etc This is explained in the subsequent steps All of these files are now adapted to the target platform needs step by step e Step 6 File pal irq c This source file contains functions to initialize enable disable and install handler for the transceiver interrupts It needs to be updated to match the requirements of the target board when handling the transceiver interrupts see examples in Section 11 3 2 6 and in Section 11 4 2 8 e Step 7 File pal board c This source file contains board specific functions to initialize and handle peripherals such as LEDs buttons GPIO to the transceiver It needs to be updated to match the requirements of the target board when handling these peripherals see Section 11 3 2 7 e Step 8 File pal config h This header file contains configuration parameters for the target platform such as CPU frequency for this particular board IRQ pins pins between transceiver and MCU LED pins button pins timer clock sourc
256. ources This directory contains the buffer and queue management implementation used internally inside MCL and TAL Also hooks for application usage are provided SAL This directory contains the Security Abstraction Layer providing specific security implementations based on available hardware support STB This directory contains the Security Toolbox implementing an independent crypto API TAL This directory contains the Transceiver Abstraction Layer with subdirectories for each supported transceiver providing specific implementations addressing the specific needs of each transceiver TFA This directory contains the Transceiver Feature Access with subdirectories for each supported transceiver providing access to unique transceiver features like receiver sensitivity configuration etc 3 2 Header file naming convention 8412D AVR 5 12 The different modules or building blocks of the stack are structured very similar Once the reader is familiar with the provided file structure it becomes very easy to find any required information Each stack layer directory or building block has a directory named Inc MAC Inc PAL Inc SAL Inc STB Inc TAL Inc AIMEL 18 16 Atmel AVR2025 AIMEL e TFA Inc These directories contain basic header files that are generic for the entire block independent from the specific implementation or required for the upper layer Additionally there are further Inc subdirectories designated to spe
257. out this platform see Sections 10 4 2 4 and 10 4 3 2 For simplicity reason it is assumed that the same platform is used and only the MCU shall be replaced For more information about how to bring up a new board see also Section 11 3 11 4 2 6 Step 6 Rename the target board The file pal boardtypes h contains entries inherited form the base platform All obsolete entries except of REB 4 1 CBB may be removed if desired In this example all entries are kept since this allows for the easy extension of the boards later 11 4 2 7 Step 7 Hename all occurrences of base MCU to target MCU Within the entire directory PAL XMEGA ATXMEGA2564G all occurrences of the string ATXMEGA128A1 searched and replaced by the target MCU ATXMEGA256A3 In this example this needs to be done in the following files PAL XMEGA ATXMEGA256A3 Boards pal_boardtypes h PAL XMEGA ATXMEGA256A3 Boards REB 4 1 CBB pal config h 11 4 2 8 Step 8 File pal irq c Since the target platform is close very close to the base platform no changes need to be done in this file 11 4 2 9 Step 9 File pal board c Since the target platform is close very close to the base platform no changes need to be done in this file 11 4 2 10Step 10 Fila pal config h Since the target platform is close very close to the base platform no changes need to be done in this file 11 4 2 11 Step 11 File pal sio hub c in directory Src No changes need to be
258. perate at channel DEFAULT CHANNEL with the PAN ID DEFAULT PAN ID and use the same short address settings More than two nodes should not be operated with the same settings The application uses a button to determine the mode of operation secure or unsecure mode or to initiate frame transmissions and up to three LEDs to indicate the current status of the node Once the node is powered up the LED 0 switched on permanently If the node is powered while the button is pressed until the LED 0 is switched on the application runs in unsecured mode LED 1 is off Otherwise that is button is not pressed during system start up the application runs in secured mode LED 1 is on AMEL s AIMEL If the button is pressed during operation the node sends a frame which contains the message Toggle light This message is either to be seen in plaintext or it is encrypted A node in secured mode only transmits frames being encrypted using ZigBee CCM security and also expects frames being encrypted A node in unsecured mode only transmits frames with plaintext and also expects frames with plaintext If the transmitter has received an Acknowledgment frame as response to its frame transmission it indicates the successful transmission by toggling the LED 2 If the transmission is not successfully the LED 2 is flashing for a short time Receiver is in secured mode If the node has received a secured frame that could be decrypted pro
259. perly the LED 2 is toggled If the received frame is either unsecured or has a security error for example incorrect key the LED 2 is flashing for a short time Receiver is in unsecured mode If the node has received a plaintext frame the LED 2 is toggled If the received frame is secured the LED 2 is flashing for a short time If a serial terminal is used the used mode security on or off and the status of the last frame transmission or reception are printed The following pictures show the printouts on the serial terminal depending whether the nodes are started in secure or unsecure mode Figure 9 17 Secure remote control application both nodes in secure mode zox Datei Bearbeiten Ansicht Anrufen bertragung App started with security on security on Tx secured ok Security on Tx secured ok Security on Tx secured ok Com4 9600 HyperTerminal Datei Bearbeiten Ansicht Anrufen bertragung App started with security on Security on RX secured decrypyted Toggle light Security on RX secured decrypyted Toggle light Security on Rx secured decrypyted Toggle light Figure 9 18 Secure remote control application both nodes in unsecure mode Datei Bearbeiten Ansicht Anrufen bertragung App started with security off Security off Tx plaintext ok Security off TX plaintext ok Security off Tx plaintext ok Com4 9600 HyperTerminal Datei Bearbeiten
260. ples on how to use security within an application based on MAC or based on the TAL please check the applications in directory Applications STB Examples 6 1 5 1 SAL TYPE Security support is implemented in two different layers The lower layer SAL Security Abstraction Layer implements all portions of security that are dependent of 8412D AVR 5 12 Atmel AVR2025 the used platform for example AES engine implemented in transceiver or microcontroller etc The upper layer STB Security Toolbox implements functionality that is independent from the used platform and provides a generic API to the application for instance securing a frame with CCM security In order to provide the proper code or hardware support for basic security functions the type of the used Security Abstraction Layer needs to be specified as build switch The currently supported SAL types are e AT86RF2xx SAL with transceiver based AES via SPI ATMEGARF_SAL SAL with single chip transceiver based AES ATXMEGA SAL SAL with ATxmega family based AES For more information please check the SAL Inc sal _types h file and see Section 4 6 Usage in Makefiles CFLAGS DSAL TYPE ATS86RFZ2xx enables transceiver based AES security via SPI Usage in IAR ewp files SAL TYPE AT86RF2xx enables transceiver based AES security via SPI 6 1 5 2 STB ON SAL formerly ENABLE STB While the SAL only provides a basic security API most applications
261. plication can be downloaded onto the desired hardware platform as described below 8 3 5 1 Starting the release build The release build can simply be started as follows e Make sure that only the Atmel AVR JTAGICE of the node where the current build shall be downloaded to is switched on Switch off all other JTAGICE e Open IAR Embedded Workbench by double clicking the desired eww file e Select the Release Workspace e Open the Options window for the Release Workspace Select the Debugger window and within this window select the Setup tab 16 Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 Figure 8 34 IAR AVR32 Embedded Workbench Options gt Debugger gt Setup Options for node Wireless Touch E Category Factory Settings General Options C C Compiler Assembler to Extra Options Plugins Custom Build r Build Actions Run to Linker J main AVR ONE Get reset address from UBROF JTAGICE mkII Setup macros Simulator Use macro file B r Device descriptions Override default TOOLKIT DIR configNiouc3lOB4 ddf OK e Within the Setup tab select the Driver JTAGICE mkll and deselect Run to main e Change to the Plugins tab and deselect all entries AIMEL 117 AIMEL ey Figure 8 35 IAR AVR32 Embedded Workbench Options gt
262. plication has been built using AVR Studio 4 directly by double clicking the corresponding aps file the EEPROM settings are handled properly without any user interaction The provided aps files contain an entry that requires the system to preserve the current EEPROM settings lt PRESERVER_EEPROM gt 1 lt PRESERVE_EEPROM gt AMEL s 8412D AVR 5 12 8 3 2 96 Atmel AVR2025 AMEL In order to re build the application and download it onto the desired hardware platform follow the steps below e Select menu Build item Build and Run e Once the application has been built successfully and in case there has been more than one Atmel AVR JTAGICE detected a window pops up asking to select the proper JTAGICE to be used e In case the IEEE address of the node is stored in the internal EEPROM of the microcontroller perform as follows o After successful download of the application check whether a valid IEEE address different from OxFFFFFFFF is stored in the internal EEPROM Select menu View item Memory o If the IEEE address is not set properly write the correct IEEE to the first eight octets of the EEPROM see Figure 8 1 Start the application by pressing F5 or clicking the Run button Figure 8 1 Atmel AVR Studio verifying and setting of IEEE address AVR Studio c Atmel A R2025 MAC_ _2_x_y Applications MAC_Examples Star_Nobea
263. plications using the MAC API on top of the MAC Core Layer TAL applications using the TAL API and STB Applications Secure Remote Control using the TAL API Secure Sensor using the MAC API on top of the MAC Core Layer o Makefiles Atmel AVR Studio 4 Atmel AVR Studio 5 IAR Embedded Workbench project files are available for every supported 14 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 microcontroller transceiver board configuration and can be used as quick start o Hex elf bin files for AVR AVR32 and ARM microcontrollers respectively to be downloaded onto available hardware are provided Build This directory contain Windows batch files that can be easily used to rebuilt any desired MAC TAL or STB application or all applications at once Doc o This directory contains the MAC reference manual in html format which can be started by double clicking file readme html in the root directory of the MAC package Include This directory contains header files that are of general interest both for applications and for all layers of the stack such as IEEE constants data types return values etc MAC This directory contains the MAC Core Layer MCL and the MAC API PAL This directory contains the Platform Abstraction Layer with subdirectories for each microcontroller family It provides all required source and header files for each microcontroller and the supported board configurations Res
264. pplication AT86RF233 ATxmega256A3 Main and Sub menu 2 Transceiver State Selection Present State PLL_ON Reduced Power Consumption RPC enabled 0 ad Desensitization disabled DEEP SLEEP SLEEP OFF disabled PLL ON enabled RK disabled TK Continuous Antenna diversity disabled and antenna selected is A1 K2 Leave sub menu rt_ test r 0 lt 22 o 5 e Press 8 on UART terminal program to configure the PER measurement parameters e g setting the frame length no of frames antenna diversity settings on remote node etc Figure 9 144 PER Test Configuration sub menu Software Version 4 0 Performance test application AT86RF233 ATxmega256A3 Main and Sub menu 3 PER Test Configuration Number of test cedo 100 Frame length PSDU Diversity settings on node CRC settings on remote node Leave sub menu 5 Start test _ 2 lt e Press 4 UART terminal program to analyze other services of transceivers e g energy scan Continuous wave Transmission and reading and writing transceiver registers etc Figure 9 155 Service Functions sub menu Software Version 4 0 Performance test application AT86RF233 ATxmega256A3 Main and Sub menu 4 Service Functions Identify peer device by blinking Energy scan on all channels Continuous
265. ps data c to Po uint8 t buf header 4 LOUP tal frame to tx array Step 1 If an application based on the MAC layer as Highest Stack Layer shall transmit a frame to another node the MAC needs to generate a MAC Data frame Initially the application calls function wpan mcps data req located in file mac apic In this function a new large buffer is requested from the Buffer Management Module BMM by means of the function bmm buffer alloc After the successful allocation of AIMEL 23 AIMEL pu M the buffer the structure of type mcps_data_req_t is overlaid over the actual buffer body mcps data req mcps data req t BMM BUFFER POINTER buffer header For more information about the data req t structure see MAC Inc mac msg types h The data req t structure is filled according to the parameters passed to function wpan mcps data req and the Data frame payload MSDU is copied to the proper place within this buffer This is the only time the actual payload is copied during frame transmission inside the entire stack The MSDU will reside right at the end of the buffer with additional space for the FCS The size of such a buffer fits the maximum possible payload according to 4 Also the parameter is updated to point right at the beginning of the MSDU content The entire frame buffer is then queued as an MCPS DATA REQUEST me
266. r 1 VR heehee The ATmega128RFA1 EK1 is not optimized for RF performance 10 4 6 Atmel RZ600 on Atmel AT32UC3L EK The RZ600 Evaluation board as part of the RZ600 evaluation kit is supported on top of an ATS2UC3L EK evaluation and demonstration kit based on Atmel AT32UC3L064 See PAL AVR32 AT32UC3L064 Boards RZ600_2XX_UC3LEK e Images need to be flashed using Atmel AVR JTAGICE and the JTAG connector e Images can also be downloaded using Atmel AVR ONE e USB driver providing a virtual COM port for the AT32UC3L EK board based the CDC Driver is provided in the software package see at32uc3xxx cac inf in directory PAL Board_Utils AVR32_USB_Driver The debugger connections are explained in the sections below using a squid cable with Atmel AVR JTAGICE or Atmel AVR ONE debugger AMEL 8412D AVR 5 12 AIMEL SEE Figure 10 26 Atmel AT32UC3L EK board with Atmel AVR JTAGICE JTAGICE mkil with AT32UC3L EK connection details e White Pin 2 of JTAG Header of AT32UC3L EK e Purple Pin 4 of JTAG Header of AT32UC3L EK e Red Pin 6 of JTAG Header of AT32UC3L EK Figure 10 27 AT32UC3L EK board with Atmel AVR ONE z3 am NS s 248 049 o AVR ONE with AT32UC3L EK connection details e White Pin 2 of JTAG Header of AT32UC3L EK e Purple Pin 4 of JTAG Header of AT32UC3L EK e Grey Pin 6 of JTAG Header of AT32
267. r with Promiscuous_Mode_Demo Update the required path variables Path variables Update the required compiler options CFLAGS this includes updating the required SIO handling switches o Update the required include directories INCLUDES Update the required list of object files for the linker OBJECTS Update the compile section for the source files Compile e Step 3 Update the IAR project files Usually all required changes for the IAR Workbench are to done in the ewp file This includes updating of the paths for includes and updating of the required source files Other changes may include updating the proper SIO channel etc e Step 4 Update the Atmel AVR Studio Project files aps files This includes replacing occurrences of the name of base application with the target application for example replace Star with Promiscuous Mode Demo All other items are already within the external Makefiles that are called during the build process 11 5 1 Step 1 Identify a matching base application The MAC application Promiscuous Mode Demo target application shall be enabled on the existing platform ATxmega256A3 MCU based on REB231ED V4 1 1 on top of an STK600 board For more information about the platform bring up for this target platform see Section 11 4 This target application is located in directory Application MAC Examples Promiscuous Mode Demo AMEL 2s 8412D AVR 5 12
268. r a new platform need to be done in directory Boards in the subdirectory for the target board In the current example change to directory PAL XMEGA ATXMEGA256A3 Boards REB_4_1_CBB In this directory the following three files are located e pal_board c e pal pal config h All of these files are now adapted to the target platform needs step by step e Step 8 File pal irq c This source file contains functions to initialize enable disable and install handler for the transceiver interrupts It needs to be updated to match the requirements of the target board when handling the transceiver interrupts see example in Section 11 4 2 8 e Step 9 File pal board c This source file contains board specific functions to initialize and handle peripherals such as LEDs buttons GPIO to the transceiver It needs to be updated to match the requirements of the target board when handling these peripherals e Step 10 File pal config h This header file contains configuration parameters for the target platform such as CPU frequency for this particular board IRQ pins pins between transceiver and MCU LED pins button pins timer clock source definitions debug macros etc It needs to be updated to match the requirements of the target board see example in Section 11 4 2 10 e Step 11 File pal sio hub c in directory Src o file pal sio hub c within the Src directory of the target MCU is a source containing the hub functionali
269. r any other editor To open the example application project from the AVR Studio select the file Device aps or from the IAR EWW select the file Device eww If the Atmel AVR Studio is used the source code can be compiled from the menu Build gt Rebuild All If the IAR EWW is used the source code can be compiled from the menu Project gt Rebuild All The main function of the device performs the following steps Initialize the MAC layer and its underlying layers like PAL TAL BMM if wpan_init SUCCESS Stay here we need a valid IEEE address Check kit documentation how to create an IEEE address and store it to the EEPROM pal alert Calibrate MCU s RC oscillator pal calibrate ro osc Initialize LEDs pal led init pal led LED 0 LED ON indicating application is started pal led LED 1 LED OFF indicating network is started pal led LED 2 LED OFF indicating data reception Enable the global interrupts pal global irq enable Initiate a reset of the MAC layer mlme reset req true Run the main loop while 1 wpan task Once the main loop is running the MAC layer will execute the previously requested reset and call the implementation of usr mlme reset conf callback function Depending on the returned status information the program continues either with the request to
270. r application needs the PAL API has been updated The API changes within the PAL API mainly affect the functions handling transceiver interrupts 8412D AVR 5 12 7 2 3 1 7 2 3 1 1 Releaes 2 4 x 7 2 3 1 2 Releaes 2 5 x 7 2 3 2 7 2 3 2 1 Releaes 2 4 x 8412D AVR 5 12 Atmel AVR2025 TRX IRQ Initialization The initialization of transceiver interrupts has been changed from release 2 4 x void pal_trx_irg_init trx_irq_hdlr_idx_t trx num FUNC trx_irg_cb The implementation comprised of exactly one function for interrupt initialization which required an ID for the actual interrupt number Since most applications do not require all transceiver interrupts this approach has been changed starting from release 2 5 x The focus here is clearly on reduced footprint Each single transceiver interrupt is initialized with a dedicated initializiation function The original parameter specifying the dedicated transceiver interrupt is not used anymore Furthermore only required transceiver interrupts are included into the code based on additional build switches that can be used The following functions are provided starting from release 2 5 x Initialization of main transceiver interrupt void pal trx irq init FUNC PTR trx irq cb Initialization of transceiver timestamp interrupt only available if ENABLE TSTAMP is used void pal trx init tstamp FUNC trx_irg_cb Initialization of addition
271. r target platforms boards that shall be used Each step is first described generally and then specifically described in detail for porting the existing code from the base platform REB 2 REX ARM REV 2 using Atmel AT86RF230B with AT91SAM7X256 to the target platform REB 4 0 2 REX ARM REV 3 using Atmel AT86RF231 with AT91SAM7X256 e Step 1 Identify the application that shall be ported This requires that all peripherals required by the application need to be supported such as SIO support LEDs buttons For more information about the requirements of existing applications see Section 9 2 e Step 2 Identify the best matching base platform already supported within this application Duplicate the directory of the base platform within this application and rename it according to your target platform e Step 3 Update the GCC Makefile Independent from whether the target application is built from command line using make or Atmel AVR Studio project file APS files AMEL as 8412D AVR 5 12 AIMEL SSE which also use external Makefiles themselves the Makefile needs to be updated to cope with the target platform This includes o Build specific properties such as TAL TYPE PAL GENERIC BOARD TYPE o MCU type o The selected SIO channel in case stream I O is used within the particular application f the build switch SIO is set in the Makefile DSIO_HUB also one of the followi
272. re 8 28 IAR Embedded Workbench Options gt Debugger gt Setup e Within the Setup tab select the Driver JTAGICE and select Run to e Change to the Plugins tab and select the entries as shown in Figure 8 Figure 8 29 IAR Embedded Workbench Options gt Debugger gt Plugins 8412D AVR 5 12 Atmel AVR2025 e Within the Options window for the Release Workspace select now the JTAGICE window and within this window select the JTAGICE 2 tab Figure 8 30 IAR Embedded Workbench Options gt JTAGICE gt JTAGICE mkll 2 Options for node Star Category Factory Settings General Options C C Compiler Assembler Custom Build JTAGICE mkll 1 JTAGICE mkll 2 Serial Port Extra Options Build Actions Linker Run timers in stopped mode Debugger CCR reserve EEPROM contents even if device is reprogrammed ICE200 i estore fuses when ending debug session Dragon Enable software breakpoints Simulator Third Party Driver System breakpoints on Exit putchar v getchar e Within the JTAGICE 2 tab check the items as shown in Figure 8 Especially make sure that the EEPROM will be preserved if the device is reprogrammed e Press OK e Press the button Download and Debug AIMEL i amp 8412D AVR 5 12 114 AMEL Figure 8 31 IAR Embedded W
273. received frame irq and process incoming frame in tal rx tal rx frame cb in mac data ind c to buf header array Step 1 Once the transceivers raises an interrupt indicating the reception of a frame function handle received frame irq located in TAL tyl type Src tal rx c is called in the context of an ISR Here a structure of type frame info t is overlaid over the current receive buffer body frame info t receive frame receive frame frame info t BMM BUFFER POINTER tal rx buffer After reading the ED value of the current frame and the frame length the entire frame is uploaded from the transceiver and the ED value is stored at the location after the LQI which automatically was uploaded from the transceiver The mpdu pointer of the frame info t structure points to the proper location where the actual frame starts AIMEL amp 8412D AVR 5 12 AIMEL SEE within the buffer Afterwards the entire buffer is pushed into the TAL Incoming_Frame Queue for further processing outside the ISR context After removing the buffer from the TAL Incoming Frame Queue function process incoming frame also located in file TAL tal type Srctal rx c is called Here again a structure of type frame info tis overlaid over the receive buffer body frame info t receive frame frame info t BMM BUFFER POINTER buf ptr Before the callback function inside the MAC is called t
274. rectory Src The application requires up to three LEDs on the board in order to indicate the proper working status A sniffer is suggested in order to check the proper association between the two nodes but in order to see the further data frame exchange a special sniffer is required being capable to except frames at 2Mbit s For further status information this application requires a serial connection Depending on the available Serial I O interface for each board this can be either UART or USB In order to start the application and to see the output of the application please start a terminal application on your host system and press any key for the application to begin Also the TAL Example Performance_Test can be used in promiscuous mode to check the proper frame exchange between the two nodes using the same channel and the correct channel page 17 for 2Mbit s The application works as described subsequently Node one e Switch on node one e LED 0 indicates that the node has started properly e Flashing of LED 1 indicates that the node is scanning its environment Scanning is done three times on each available channel depending on the radio type e f no other network with the pre defined channel and PAN Id is found the node establishes a new network at the pre defined channel channel 20 for 2 4GHz radio This node now becomes the PAN Coordinator of this network The successful start of a new network is indicated by switching LED 1 on
275. rilySWIIChnes eO RED ERREUR GER PERSEO AB 74 6 1 6 Test and debug eene 76 6 2 Build configurations ienai eaea eaan 76 6 2 1 Standard build configurations 76 6 2 2 User build configurations USER BUILD 80 7 Migration History euin iade deiude detur ere 84 7 1 Guide from version 2 6 027 nnns 84 1 1 Guide from version 2 5 x to 2 6 84 7 2 Guide from version 2 4 025 84 7 2 1 MAG API changes tnter diene lawl Fes had tree 84 7 2 2 BEES dEenrie mE 86 7 2 3 PAL API Changes a erbe ree dede 88 8 T UN 92 8412D AVR 5 12 AIMEL Ey o 8 1 General prerequisites 92 8 2 Building the enn 92 8 2 1 Using makefiles sess 92 8 2 2 Using AVR Studio 4 nti e Re eio trei ne diet ees 93 8 2 3 Using AVR StUdio 5 nce ctt aia 93 8 2 4 Using IAR Embedded 93 8 2 5 Using IAR AVR32 Embedded Workbench eee 94 8 2 6 Using IAR ARM Embedded 95 8 2 7 tid eco t co ndi RU EC De den das 95 8 3 Downloading an
276. rstmelNioat81sam3s4 ddf Cancel e Within the Setup tab select the Driver J Link J Trace and deselect Run to main e Change to the Plugins tab and deselect all entries AIMEL 123 amp 8412D AVR 5 12 AIMEL Figure 8 41 IAR ARM Embedded Workbench Options gt Debugger gt Plugins Options for node Coordinator Category Factory Settings General Options C C Compiler Assembler Output Converter Setup Download Images Extra Options Plugins Custom Build Build Actions Linker elect plugins to load imulator Angel GDB Server IAR ROM monitor J Link J Trace M Mp Mp LMI FTDI Description RTOS awareness for Macraigor nel Location C Program Files IAR Systems Embedded Workbench 5 4_ LIN Third Party Driver Originator IAR Systems Version 5 50 0 51907 OK e Press e Press the button Download and Debug 8 3 7 2 Starting the debug build The debug build can simply be started as follows e Make sure that only the JTAGICE of the node where the current build shall be downloaded to is switched on Switch off all other JTAGICE e Open IAR Embedded Workbench by double clicking the desired eww file e Select the Debug Workspace e Open the Options window for the Debug Workspace Select the Debugger window and within this w
277. rts non beacon and beacon enabled networks The MAC software package is a reference implementation demonstrating the use of the Atmel IEEE 802 15 4 transceivers It follows a generic approach and is not optimized to any specific application requirement The user needs can be adapted to its specific application requirements AIMEL amp 8 bit Atmel Microcontrollers Application Note Rev 8412D AVR 5 12 AIMEL amp 2 General architecture 2 1 Main stack layers Atmel AVR2025 The MAC software package follows a layered approach based on several stack modules and applications Figure 2 1 shows the stack s architecture The stack modules are from the bottom up e Platform Abstraction Layer PAL see Section 2 1 1 e Transceiver Abstraction Layer TAL See Section 2 1 2 and Transceiver Feature Access TFA see Section 2 2 4 e MAC including MAC Core Layer and MAC API see Section 2 1 3 e Security Abstraction Layer SAL and Security Toolbox STB see Sections 2 2 2 and 2 2 3 e Resource Management including Buffer and Queue Management BMM and see Section 2 2 1 Figure 2 1 MAC architecture Fdstraction of other PEE Peripherals Access Ti mers GPIO IRO Stream 1 2 Hardware Platform i e Microcontroller Board Configuration For a complete description of the API of each layer and component please refer to the AVR2025 IEEE 802 15 4 MAC Reference Manual MAC readme htm
278. rx flag clr trx hdlr idx t trx num The implementation comprised of exactly one inline function for clearing the transceiver interrupt flag which required an ID for the actual interrupt number Since most applications do not require all transceiver interrupts this approach has been changed starting from release 2 5 x Each single transceiver interrupt flag is cleared using a macro The original parameter specifying the dedicated transceiver interrupt is not used anymore Furthermore only required transceiver interrupts are included into the code based on additional build switches that can be used The following macros are provided starting from release 2 5 x Clearing the main transceiver interrupt flag define pal trx irq flag clr CLEAR TRX IRQ Clearing the transceiver timestamp interrupt flag only available if ENABLE TSTAMP is used 8412D AVR 5 12 8412D AVR 5 12 define pal trx irq flag clr tstamp C Clearing of additionally required transceiver interrupt flags for Atmel AVR2025 EARL AR EAR define pal trx irq flag clr rx end CLE define pal trx irq flag clr tx end C define pal trx irq flag cca ed C EARL define pal trx irg flag_clr define pal define pal define pal define pal trx irq flag clr ami EARL batmon EAR RX IRQ TSTA MEGA RF sin
279. rx enable req 22 839 co CU usr mlme rx enable S wpan_mcps_data_req as Data Frame Direct 22 o 22 88 ciem usr mcps data conf lt 3r usr data ind 7X A Z gt Success N 4 4 12 MAC_SYNC_REQUEST This feature is usually required for any node both RFD and FFD that wants to synchronize with its beacon enabled network tracking beacon frames from its parent by means of using function wpan_mlme_sync_req 4 4 13 MAC SYNC LOSS INDICATION This feature is usually required for any node both RFD and FFD that needs to be able to report a sync loss condition to its upper layer This can be either the reception of a coordinator realignment frame from its parent or caused by the fact that a synchronized node has not received beacon frames from its parent for a certain amount of time 4 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 4 16 Synchronization and loss of synchronization PAN Coordinator Node using using MAC_SYNC_REQUEST and MAC START REQUEST MAC SYNC LOSS INDICATION CONFIRM App MAC MAC App wpan mlme start req Beacon Network Beacon Frame usr mlme start Beacon Frame Start of Beacon enabled Network mlme sync req Beacon Frame 2 a Beacon Frame Synchronization with Parent Loss of Synchronizatio usr mlme sync loss ind 4 4 14 MAC BEAC
280. ry two seconds e LED 0 blinking fast Format error on received frame wrong payload length or security control byte has a wrong value e LED 1 blinking fast Frame with too small frame counter received e LED 2 blinking fast MIC of received frame is wrong 8412D AVR 5 12 9 2 3 2 4 Limitations 9 2 3 3 9 2 3 3 1 Introduction 8412D AVR 5 12 Atmel AVR2025 Figure 9 21 Snapshot of secure sensor application Coms 9600 Hyperterminal _ Datei Bearbeiten Ansicht Anrufen bertragung Dias 213 sole Data Sink Started sensor network Frame 0 MIC ok Frame 1 MIC ok Frame 2 MIC ok Frame 3 MIC ok Frame 4 MIC ok Frame 5 MIC ok Frame 6 MIC ok Frame 7 MIC ok Frame 8 MIC ok Frame 9 MIC ok Frame 10 MIC ok Frame 11 MIC ok 4 9600 HyperTerminal i inl xl Datei Bearbeiten Ansicht Anrufen bertragung i 2 3 sole Sensor Searching network Verbunden 00 Found network Conntected to sensor network Sending frame Sending frame Sending frame Sending frame Sending frame Sending frame Sending frame Sending frame Sending frame Sending frame Sending frame Sending frame PEUOAHUBWNHEO The current channel is coded within the application In order to run the application on another channel change the default channel in file main c and re built the application e t is not recommended operating more than two nodes wit
281. s not passed to the R address in hex dap ETE allocation application Application is notified using Com status User can set the address with short address argument all nodes joining will get address incremented from this value If Auto z 0 then short address parameter is ignored Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 9 3 Serial_AT_Interface program snapshot on node one MAC AT Serial Interface v1 0 at reset RESET 00 OK at assoc 15 08 02 cafe 00090 80 ASSOC 00 0001 OK at pol1 02 cafe 0000 POLL 00 OK INDATA 902 0009 02 0001 01 29 049152 8 Figure 9 4 Serial_AT_Interface program snapshot node two OK 1 2 01 52 00 OK at start cafe 15 00 0f Of 01 00 00 START 00 OK INASSOC 000425 1 amp 80 AUTORSP 01 0001 INCOMM 03 CRFE 000425FFFF173FB6 03 CRFE 000425FFFF173E34 00 at data 02 02 cafe 0001 01 01 05 DRTR 01 00 08C903E0 OK 9 2 1 8 4 Limitations As it is just an interface no associated device data base shall be maintained in the Coordinator so primitives like Orphan Response can not be issued even if is just and AMEL s 8412D AVR 5 12 9 2 2 TAL examples 9 2 2 1 1 156 Introduction Atmel AVR2025 AIMEL interface on which an application sits association response is sent automatically during the association pro
282. s required for specific build configurations See Section 6 2 1 for more information about mac build config h This file must not be changed by the end user User build configuration file mac user build config h Atmel AVR2025 Each application provide its own user build configuration mac user build config h usually located in Inc directory of the application although this is not required This configuration file defines the actual MAC components used for the end user application and can actually reduce resource requirements drastically If the application wants to use its own user build configuration the build switch MAC USER BUILD CONFIG needs to be set See Section 6 2 2 for more information about mac user build config h This file can be adjusted by the end user according to its own needs 8412D AVR 5 12 4 4 components 8412D AVR 5 12 Atmel AVR2025 For more information about user build configurations and its utilization please refer to Section 4 4 and Section 6 2 2 An example for an application using the configuration file mac user build config h to create an application defined stack can be found in Section 9 2 1 3 The MAC is implemented to be fully compliant to the IEEE 802 15 4 2006 standard The MAC components are clustered in essential components and supplementary components Essential components are required for a minimum reasonable application based on the MAC and are thus
283. s for the PHY 236 Atmel AVR2025 mm Support Item number Item description Status N A Yes No FD1 Is this a full function device FFD O 1 X Is this a reduced function device FD2 RFD O 1 X FD3 Support of 64 bit IEEE address M X Assignment of short network address X FDA 16 bit FDIM FED only FD5 pm of short network address 16 M X O1 At least one of these features shall be supported Table 12 2 PHY functions Support RE Item description Status PH number N A Yes No PLF1 Transmission of packets M X PLF2 Reception of packets M X PLF3 Activation of radio transceiver M X PLF4 Deactivation of radio transceiver M X X PLF5 Energy detection ED FD1 MO FFD only PLF6 Link quality indication LQI M X PLF7 Channel selection M X PLF8 Clear channel assessment CCA M X PLF8 1 Mode 1 O 2 X PLF8 2 Mode 2 O 2 X PLF8 3 Mode 3 0 2 X O2 At least one of these features shall be supported 8412D AVR 5 12 Atmel AVR2025 12 3 Major capabilities for the MAC sub layer 12 31 MAC sub layer functions Table 12 3 MAC sub layer functions AIMEL Item Item description Status P number N A Yes No MLF1 Transmission of data M X FD1 M X MLF1 1 Purge data FD2 FFD only MLF2 Reception of data M X 1 FD1 M X MLF2 1 Promiscuous mode FD2 FFD only MLF2
284. sages 2l Download the application and start the debugger Errors 0 Warnings 0 2 A Window will pop up indicating the status of the download of the binary After successful download the IAR AVR32 Workbench will looks as shown Figure 8 After the download of the debug build the main function is displayed since all debug and source code information is included in the build AIMEL a 8412D AVR 5 12 AMEL Figure 8 39 IAR AVR32 Embedded Workbench successful download of debug build X IAR Embedded Workbench IDE x File Edit View Project Debug mkII Tools Window Help Dac 4 melo UY SE esee E Se 2 amp Z2 2 52 2x EE e a Star Debug v _ MAC Resources CATAL main c amp C3 Output e Start the application by pressing the F5 or the button 8 3 6 Using AVR32 GCC commandline programming The application can be downloaded using GNU utility avr32program Change to the directory where the Makefile for the application is located for example cd Applications TAL_Examples Performance_Test_EVK AT86RF212_AT32UC3L064_RZ600_UC3LEK cd GCC Download the project using the following command e For AT32UC3L064 avr32program exe p jtagicemkii part UC3L064 program finternal 0x80000000 eu run R cint elf e For AT32UC3AS32568 avr32program exe p jtagicemkii part UC3A3256S program
285. scan all channels for the coordinator or with a new reset request void usr_mlme_reset_conf uint8_t status if status MAC_SUCCESS AMEL 8412D AVR 5 12 138 AMEL Initiate an active scan over all channels to determine which channel is used by the coordinator wpan mlme scan req MLME SCAN ACTIVE SCAN ALL CHANNELS SCAN DURATION SHORT DEFAULT CHANNEL PAGE Indicate network scanning by a LED flashing pal timer start TIMER LED OFF 500000 IMEOUT RELATIVE void network search indication cb NULL else something went wrong restart wpan mlme reset req true Once the main loop is running this request is processed by the MAC layer and the usr_mlme_scan_conf callback function is called with the result of the scan The usr_mlme_scan_conf function handles three cases e Acoordinator was found No coordinator was found coordinator wpan pandescriptor t ResultList for i 0 i lt ResultListSize i Check if the PAN descriptor belongs to our coordinator Check if coordinator allows association xf if coordinator LogicalChannel DEFAULT CHANNEL amp amp coordinator ChannelPage DEFAULT CHANNEL PAGE amp amp coordinator CoordAddrSpec PANId DEFAULT PAN ID amp amp coordinator 5SuperframeSpec amp 0x80
286. se E addsrksoo 538 c I E Gg SE oiii Gt AVR QTouch Studio int man s Sh Attach to Process mac_dispatcher c IMPLEMENTATION 4 M mac_meps_data c dj mac misc c Lj Code Snippets Manager Ctrl B e orphan c gere j mac_pib c Bbrief Main function of the Add in Manager d mac Extension Manager dj mac_process_beacon_frame c Sint main void iG mac_process_tal_tx_frame_status c External Tools mac rx enable c Initialize the MAC laye Import and Export Settings mac scan c if wpan init SUC Customize mac start c mac sync c Options yt dj mac_tx_coord_realignment_command c Stay here we need a valid IEEE address Check kit documentation how to create an IEEE address and to store it into the EEPROM pal_alert P Initialize LEDs pal led init B yt 100 Output ee I3 12 3 sk al The program Promiscuous Mode Demo elf has exited with code 0 0 0 e After selecting proper Tool Device and Interface press Apply button Figure 8 16 AVR Studio 5 AVR Programming dialog ixi Tool Device Interface Device ID Target Voltage EON Re 55v Interface settings Use external reset Tool information Use external reset Device
287. section describes how the buffers are used inside the stack during the procedure of the transmission of a MAC Data Frame Figure 4 4 Frame buffer handling during data frame transmission part 1 MAC API MCL TAL Step 1 Step 2 Step 3 cmd_code A msg_type g_ty MCPS_DATA_REQUEST z lt 5 MESSAGE MCPS_MESSAGE 8 SrcAddrMode 8 buffer_header ps g buffer header o n DstAddrMode 8 msduHandle msduHandle E 1 I e persistence time persistence_time 3 DstPANId 1 5 only for indirect transmission H E only for indirect transmission G DstAddr 1 2 indirect_in_transit indirect_in_transit j only for indirect transmission z only for indirect transmission o 7 time_stamp S time_stamp E Inepte 8 Only filled after Tx Only filled after Tx S TxOptions Y mpdu mpdu m D 8 msduLength msdu i Free Area Free Area Length of MPDU c Length of MPDU T MPDU i amp MAC Header EN MPDU F 1 9 Data Payload i amp MSDU Data payload EN gt 4 S 5 5 Y E Space for FCS Space for FCS a Space for FCS wpan mcps data req mcps data request tal tx frame tal tx c in mac mc
288. sese 181 Supported 184 10 1 Supported MCU 2 184 10 2 Supported MCUS sviss irte e t eu E 184 10 3 Supported transceivers eessssssssssseee enne enne 184 10 4 Supported Dboafds 184 10 4 4 X Radio controller boards based 185 10 4 2 Radio extender boards REB 189 10 4 3 Radio extender boards REB based 193 10 4 4 Atmel AT91SAM7XC EK 2 2 4 0004100600000 00 0 0 000 nnne nnne 197 10 4 5 ATmega128RFA1 EK1 evaluation kit 197 10 4 6 Atmel RZ600 on Atmel 2 31 199 10 4 7 Atmel STK600 Atmel AT32UC3B1 128 with 201 10 4 8 RZ600 kit enne nennen rennen nnne e nennen 201 10 4 9 Atmel 915 35 0 4000 0 0000 nnne nennen 202 10 4 10 Atmel SAMSS USB 203 10 4 11 ZigBit Modules Top of Meshbean2 204 246 Atmel AVR2025 8412D AVR 5 12 10 4 12 Peripherals curet e ie espe ER dad 204 11 Platform 206 111 Porting to a new
289. sing indirect transmission In order to enable communication with the Device indirect data transmission using polling by the 8412D AVR 5 12 9 2 1 2 2 9 2 1 2 3 Requirements Implementation 8412D AVR 5 12 Atmel AVR2025 device is applied For further explanation of indirect transmission see Section 4 4 1 4 4 2 For power management and indirect transmission see Section 5 2 4 This example application uses MAC API as interface to the stack The application and all required build files are located directory Applications MAC_Examples Beacon_Application The source code of the application can be found in the subdirectories Coordinator Src or Device Src The application requires up to three LEDs on the board in order to indicate the proper working status A sniffer is suggested in order to check frame transmission between the nodes For further status information this application requires a serial connection Depending on the available serial I O interface for each board this can be either UART or USB In order to start the application and to see the output of the application please start a terminal application on your host system and press any key for the application to begin The coordinator in this application creates a beacon enabled network and periodically transmits beacon frames with a specific beacon payload The beacon payload changes after a certain time period Each device of this application joins the
290. smit an encrypted packet to the Coordinator The frames are secured according to ZigBee CCM network layer security e The network header is omitted only the auxiliary security header is constructed 14 byte long The applied security level is 0x05 i e encrypted payload authentication applied MIC 8 byte long e The random payload has 23 byte length The LEDs signal the following status Device LED 0 on Application is running e LED 1 on Device is associated to Coordinator e LED 2 on Data frames are sent one every 2 seconds Coordinator e LED 0 on Application is running e LED 1 on Network is started e LED 2 on Data frames are received one every 2 seconds 9 2 3 3 4 Limitations e The current channel is coded within the application In order to run the application on another channel change the default channel in file main c and re build the application e t is not recommended operating more than two nodes with the application simultaneously 9 3 Common SIO handler Applications that require SIO input or output via UART or USB in order to print data on a terminal or to get input from the end user can utilize a common SIO handler that 172 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 provides helper functions for platform independent processing of serial information These helper functions are e sio_putchar print one character e sio_getchar read one character via SIO blocking
291. sponding IAR project file Applications MAC_Examples Star_Nobeacon any platform Star ewp the following lines can be found in order to add the required source files to the build process group lt name gt MAC_API lt name gt lt file gt lt name gt PROJ_DIR MAC Src mac_api c lt name gt lt file gt lt file gt lt name gt SPROJ_DIRS MAC Src usr_mcps_purge_conf c lt name gt lt file gt lt file gt lt name gt SPROJ_DIRS MAC Srce usr_mlme_beacon_notify_ind c lt name gt lt file gt lt file gt lt name gt SPROJ_DIRS MAC Src usr_mlme_disassociate_conf c lt name gt lt file gt lt file gt 12 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 lt name gt SPROJ_DIRS MAC Src usr_mlme_disassociate_ind c lt name gt lt file gt lt file gt lt name gt SPROJ_DIRS MAC Src usr_mlme_get_conf c lt name gt lt file gt lt file gt lt name gt SPROJ_DIRS MAC Srce usr_mlme_orphan_ind c lt name gt lt file gt lt file gt lt name gt SPROJ_DIRS MAC Src usr_mlme_poll_conf c lt name gt lt file gt lt file gt lt name gt SPROJ DIRSN N N N MACNSrcNusr mlme rx enable conf c name file file name SPROJ DIRSN N N N MACNSrceNusr mlme sync loss ind c name file lt group gt AIMEL i amp 8412D AVR 5 12
292. ss be required by any application of customer specific enhancement These transceiver interrupts can be enable by setting the build switch ENABLE_ALL_TRX_IRQS Usage in Makefiles CFLAGS DENABLE ALL TRX IRQ enables the utilization of all enhanced transceiver interrupts Usage in IAR ewp files ENABLE ALL TRX IRQ enables the utilization of all enhanced transceiver interrupts 6 1 3 14 ENABLE OSC CALIBRATION MEGA only On most AVR based systems the internal RC oscillator is not only used for UART clocking but also as timer clock source In contrary on Mega RF based systems the internal RC oscillator is not used as timer clock source Only megaRF boards using UART instead of USB require an accurate internal RC oscillator In order to enable RC oscillator calibration this feature needs to be enabled explicitly by setting this build switch during compilation Usage in Makefiles CFLAGS DENABLE RC OSC CALIBRATION enables the calibration of the internal RC oscillator Usage in IAR ewp files ENABLE RC OSC CALIBRATION enables the calibration of the internal RC oscillator 6 1 3 15 WATCHDOG Each microcontroller has a Watchdog module whose basic purpose is to trigger a system reset and start executing from the boot vector in case the program hangs due to same fault condition When the system is running fine it regularly services the Watchdog timer by clearing it p
293. ssage into the NHLE MAC Queue Step 2 Once the MCPS DATA REQUEST message has been de queued and the dispatcher has called the corresponding function mcps data request see file MAC Src mac mcps data c the structure of type frame info t is overlaid over the actual buffer body frame info t transmit frame frame info t BMM BUFFER POINTER buffer t msg For information about the info t structure see file MAC Inc mac msg types h Afterwards the corresponding elements of the frame info t structure are filled accordingly e The message type parameter is set to MCPS MESSAGE e The MSDU handle is copied to the proper place e The parameter in transit only utilized during indirect transmission is set to the default value e The buffer header parameter is set to point to the actual buffer header this is required once the transmission has finished to free the buffer properly As the last step the complete frame that is the MPDU is formatted This is done by simply adding the required MAC Header information fields at the correct location in front of the MSDU that is the Data payload The first element of the MPDU fill then contain the length of the entire MPDU to be transmitted and the mpdu pointer within the frame info tstructure is updated to point to the beginning of the frame This step within the MCL is finalized by initiating the actual frame transmission by calling the TAL function tal tx fra
294. support 49 5 MAC power management eese eese eese enne nain nnn n nant 51 5 1 Understanding MAC power 51 5 2 Reception of data at nodes applying power management 52 5 2 1 Setting of macRxOnWhenldle to 2 4 4440 52 5 2 2 Enabling the 2 52 5 2 3 Handshake between end device and 53 5 2 4 Indirect transmission from coordinator to end device 53 5 3 Application control of MAC power 54 5 3 1 MAC PIB attribute 54 5 3 2 Handling the receiver with _ _ 54 5 4 TAL power management 55 6 Application and stack configuration 56 6 1 Build 56 6 1 1 Global stack 58 6 1 2 Standard and user build configuration switches 62 6 1 3 Platform iiie i eite i Ee RR e EUER RA AERE 62 6 1 4 Transceiver specific 70 6 1 5 SecU
295. t of all supported transceivers please refer to the AVR2025 release notes Release_Notes txt in directory MAC_v_x_y_z Doc The actually supported boards can be found in the corresponding PAL Boards directories MAC v x y z PAL pal family name mcu name Boards For example all supported boards for the ATmega128RFA1 Single Chip are located in directory PAL MEGA_RF ATMEGA128RFA1 Boards Each board directory contains a file pal boaradtypes h or vendor boardtypes h which contains a list of all supported boards based on this specific MCU together with a short description The following sections describe the currently supported hardware platforms in more detail All described hardware boards are available from Atmel see 1 or third party vendors for example see 2 8412D AVR 5 12 Atmel AVR2025 For a short list of the supported peripherals of each board see Section 10 4 5 10 4 1 Radio controller boards RCB based platforms The Radio Controller Board RCB is a radio module containing either a MCU for example Atmel ATmega1281 and an Atmel transceiver or an Atmel Single Chip RCBs can be used stand alone as plain RCB or in conjunction with a base board providing additional peripheral capabilities 10 4 1 1 Plain radio controller board RCB230 V3 1 For more information about earlier versions of the Plain Radio Controller Boards prior to V3 2 please contact Atmel support 3 10 4 1 2 Plain radio controller board RCB230 V3 2
296. task functions The MAC Core layer provides an API that reflects the IEEE 802 15 4 standard 4 2 1 3 1 Stack task functionality The stack consisting of PAL TAL and MCL task functionality consists of the following API e Initialization The function wpan_init initializes all stack resources including the microcontroller and transceiver using functions provided by the TAL and the PAL e Task handling The function wpan_task is the stack task function and is called by the application It invokes the corresponding task functions of the MCL TAL and PAL Using the MAC software package it is required to call this function frequently supporting a round robin approach This ensures that the different layers state machines are served and their queues are processed 2 1 3 2 MAC API The application interfaces the MAC stack via the MAC API see file mac_api h in directory MAC Inc It sends requests and responses to the stack by calling the functions provided by the MAC API The MAC API places these requests and responses in the NHLE MAC 8412D AVR 5 12 2 1 4 Usage of the stack 8412D AVR 5 12 Atmel AVR2025 Queue It also invokes the confirmation and indication callback functions implemented by the user 2 1 3 3 core layer functionality The MAC Dispatcher reads the NHLE MAC Queue and passes the requests or responses to the MAC Data Service or the MAC Management Service The MAC Dispatcher also reads the
297. te functionality added for AVR32 Watchdog support added for SAM3S MAC Application Power Management Support Star Push Button a MAC Example demonstrates the feature Accelerometer Display App added for KEY RC platform as a part of TAL Example to demonstrate the LCD and Motion Sensor on it 15 2 Rev 2025M MCU Wireless 10 11 Released with AVR2025 MAC Version 2 7 1 9 Performance_Test_EVK and Performance Test Application merged as a single application 10 Serial_AT_Interface added as a MAC application 11 Atmel AT86RF232 Radio support added for Atmel ATXmega256A3 and Atmel AT32UC3B1128 as a part of MAC amp TAL applications 15 3 Rev 2025L MCU Wireless 07 11 Released with AVR2025 MAC Version 2 7 0 12 New applications added along with this release namely a Beacon_Application b Nobeacon Applications 13 Added Security Example Application to demonstrate MAC security 14 Atmel AVRStudio 5 Support for all AVR 8bit amp AVR 32bit 15 Filtered and removed some of the platforms amp MCU families 16 Added Performance Test EVK application description 15 4 Rev 2025K MCU Wireless 08 11 Released with AVR2025 MAC Version 2 6 1 17 mac security c file contents are completely removed for the web release 18 UART software driver issue working on SAMSS EK Platform got fixed 15 5 Rev 2025J MCU Wireless 03 11 Released with AVR2025 MAC Version 2 6 0 19 Platform description for AVR32 SAM3S CBB boards added AMEL 2n
298. ted MCU family is explained in general within this section and furthermore by the example of a platform based on the Atmel ATxmega256A3 in Section 11 4 2 The same steps are to be performed for all other MCUs that shall be used 11 4 1 1 Phase1 General preparation for target platform The first phase is a simple preparation phase It provides the required directory and file structure for the target MCU and defines proper build switches required for the target platform e Step 1 Identify the MCU family for the target MCU Each supported MCU family is identified by a specific value of the build switch PAL_GENERIC_TYPE For a list of all currently supported MCU families check file PAL Inc pal_types h for defined values of PAL_GENERIC_TYPE For more information see also Section 10 1 e Step 2 Add the target MCU to the selected PAL GENERIC TYPE in file PAL Inc pal_types h e Step 3 Identify an already supported MCU that best fits the target MCU to start the porting base MCU Each supported MCU is identified by a specific value of the build switch PAL_TYPE For list of all currently supported MCU check PAL Inc pal_types h for defined values of PAL_TYPE within the selected PAL_GENERIC_TYPE For more information see also Section 10 2 e Step 4 Copy the PAL directory of the base MCU in a separate directory within the same MCU family and name it according to the target MCU e Step 5 Identify an alrea
299. tems within this file need to be updated according to the target board s needs or at least checked for correctness e Enum definition for PlOs LEDs and buttons Remain unchanged e Clock frequency selection F CPU and corresponding defines Remain unchanged e Mapping of TRX IRQs to MCU pins TRX INTERRUPT PIN o This defines the interrupt pin used for the transceiver interrupt and is derived from the actual pin on the MCU where the transceiver interrupt line is connected to o In case the transceiver interrupt is routed to a different MCU pin providing interrupt handling this interrupt vector needs to be updated too o Remain unchanged e Configuration of Advanced Interrupt Controller AIC CPONFIGURE Remain unchanged e IRQ Macros Change the comments AT86RF230B TRX MAIN HDLR IDX 212 Atmel 2025 8412D AVR 5 12 Atmel AVR2025 TRX interrupt mapped to MCU IRQO pin and TIOA line of timer channel 0 TRX_TSTAMP_IRQ_HDLR_IDX Not used ay to ATSGRE 231 TRX_MAIN_IRQ_HDLR_IDX interrupt mapped to MCU IRQO pin TIOA line of timer channel 0 TRX TSTAMP IRO HDLR IDX Time stamping interrupt not used for this board since the DIG2 pin of the 231 transceiver is not routed an additional interrupt to the MCU Timestamping is done similar to the 230 implementation Make sure that the build switch DISABLE TSTAMP IRQ
300. that is not yet supported and shall be utilized within a new platform Base board Board that is already supported within the base MCU PAL directory and is used as base code for the target board Target platform Platform consisting of target MCU and target board Base platform Platform consisting of base MCU and base board If the target platform is not provided by the MAC software package this platform needs to be brought up A new target platform can be one of the following cases a Bring up of a new customized board for already supported MCU This is usually the case of the customer has designed its own hardware board using a standard Atmel MCU for example Atmel ATmega1281 This is the simplest case and is described in Section 11 3 Bring up of a new platform based on a not yet supported MCU but within a supported MCU family This is usually the case if the customer wants to use a dedicated MCU for example with different memory resources such as using the Atmel ATxmega256A3 that is based on an existing MCU family Atmel ATxmega family This case is described in more detail in Section 11 4 Bring up of a new platform based on a not yet supported MCU within a not yet supported MCU family such as an ARM device not based on the ARM7 family 11 3 Bring up of a new hardware board 11 3 1 Implementation of PAL for target platform The task of bringing up a new platform target platform for an already supported MCU
301. the data Frame Pending Bit set the device sends a data request frame to the coordinator On the other hand the coordinator every 5 seconds queues a dummy data frame for each associated device into its Indirect Data Queue If the coordinator receives a data request frame from a particular device it transmits the pending data frame to the AMEL us 9 2 1 2 4 9 2 1 3 1 9 2 1 3 2 144 Limitations Introduction Implementation Atmel AVR2025 AIMEL SSE 0 device While the device is idle when the timer is running the transceiver enters sleep in order to save as much power as possible e The current channel is coded within the application In order to run the application on another channel change the default channel in file main c and re built the application e Currently 100 devices are allowed to associate to the PAN Coordinator This can be easily extended by increasing the define MAX_NUMBER_OF_DEVICES 9 2 1 3 Basic Sensor Network The application Basic Sensor Network implements a basic sensor network The network consists of devices being sensor nodes called LEAF nodes called ROUTER that provide router functionality and a central node collecting all data called ROOT The network route is a static route The network and its routing path are configured during network setup A tree topology is created from ROOT to LEAF nodes during the network setup The network uses a pre defined PAN Id OXBEEF and channel 1
302. thin the TAL frame handling functions e Simplification of frame indication callback function tal rx frame cb e Simplification of Beacon handling Simplification of structure frame info t Frames being exchanged between the MCL and the TAL layer that is frames to be transmitted and frames being received are handled at the TAL API by means of a specific frame structure containing all relevant frame information This structure has the type frame info t and is defined in file ta h in directory TALVnc It is used in the following functions e tal rx frame cb e tal tx frame e tal tx beacon new since 2 5 x Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 Figure 7 1 Content of frame_info_t structure Release 2 4 x obsolete Release 2 5 x ame onto tag typedef struct frame_info_tag frame_msgtype_t msg_type frame_msgtype_t msg_type ndn Ae buffer t buffer header immi t frame ctrl S i uint8_t seq_num Bo ps in e uint16 t dest panid oo im transit uint64 t dest address umts time stamp sp c uint8 t mpdu uint 6 t src panid frame dee _ uiht64 t src addrees frame info t uint8 t payload length Qus m ps Contains frame_info_t both MAC Header and MSDU Contains Address info now removed from only MSDU MAC frame header since already MAC Header included in assembled received payload Fields frame The MAC header in
303. tion The octet in front of the MAC header needs to store the actual length of the frame Afterwards the mpdu pointer member of the frame info t structure is updated to point at the start of the MPDU that is the octet containing the length of the actual frame Since dynamic buffer management is not used for frame transmission the other members of the frame info t structure are not used in this frame transmission approach Atmel AVR2025 8412D AVR 5 12 8412D AVR 5 12 Atmel AVR2025 Once the frame formatting is completed the frame is handed over to the TAL for transmission by calling function tal_tx_frame Step 2 Within the TAL in function tal_tx_frame see file TAL tal_type Src tal_tx c a pointer is set to the location of the actual MPDU inside the frame buffer member mpdu of structure frame info 1 This pointer is used for initiating the frame transmission by means of function send frame with the appropriate parameters for CSMA CA and frame retry Step 3 not included in Figure 4 7 After the frame has been transmitted the TAL acts as similar at described in Section 4 2 1 1 Once the TAL frame transmission callback function tal tx frame done cb residing inside the application is called no further handling is required in case of the usage of a static frame transmission approach The static frame buffer can immediately be re used for further transmission attempts In case of dynamic buffer handling the
304. tmel AT86RF232 e Atmel AT86RF212 For more information please check the TAL Inc ta _types h file Usage in Makefiles CFLAGS DTAL TYPE AT86RF212 selects the AT86RF212 transceiver Usage in IAR ewp files TAL TYPE AT86RF231 selects the AT86RF231 transceiver Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 6 1 42 ENABLE This build switch enables the usage of non standard compliant features of the transceiver based on the block Transceiver Feature Access TFA Currently the following features are implemented in the TFA e Changing of Receiver Sensitivity e Perform CCA e Perform ED Energy Detect measurement e Reading the current transceiver supply voltage transceiver battery monitor Reading the current transceiver supply voltage transceiver battery monitor The reading of the supply voltage can also be enabled separately by setting the build switch TFA_BAT_MON Reading of current temperature only Atmel ATmega128RFA1 only CCA and ED measurement are an inherent part of the MAC TAL so there is no need for a standard application to use this On the other hand there could be special test applications which might use such functionality If only standard defined behavior is required or code size is important this switch should not be set Usage in Makefiles CFLAGS DENABLE TFA enables the usage of the TFA Usage in IAR ew files ENABLE enables the
305. to the hardware see Section 8 3 e The above procedure for building the Makefiles is common for Atmel AVR8 Atmel AVR32 and ARM Platforms Each application can be rebuilt using the Atmel AVR Studio directly Please follow the procedure as described e Change to the directory where the AVR Studio project file aps file for the desired platform of the corresponding application is located for example cd ApplicationsMMAC Examples MPromiscuous Mode Demo cd AT86RF212 ATMEGA1281 5 3 SENS TERM BOARD e Double click on the corresponding AVR Studio 4 Project file aps file for example Promiscuous Mode Demo aps e Select the desired configuration Release or Debug Depending on the selected configuration the corresponding external Makefile is chosen during the build process These Makefiles are exactly those Makefiles located in subdirectory GCO that are used to build the application from command line see Section 8 2 1 e Rebuild the entire application in AVR Studio 4 e After building the application the subdirectory GCC contains both a hex file and an elf file which can be downloaded onto the hardware see Section 8 3 Each application can be rebuilt using the Atmel AVR Studio 5 directly Please follow the procedure as described Change to the directory where the AVR Studio 5 project file avrsin file for the desired platform of the corresponding application is located for example cd ApplicationsMMAC Exampl
306. transmission on current channel Transmit a continuous wave pulse on current channel Read Write Transceiver Registers Leave sub menu E U MI Get sensor data i e supply voltage 8 Start test 5 162 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 e Press 5 on UART terminal program to start PER measurement test anytime irrespective of in which sub menu user is in presently e f search for peer node is aborted failed then a minimal set of test can be performed with only single node The menu shown in Error Not a valid bookmark self reference 6 describes the test Figure 9 166 Main menu after Peer Search process aborted failed aracter received on UART PER Measurement mode ENTER to Abort Search for Peer Device and to start single node operation m ode Search for Peer Device failed Starting Performance Test flpplication in single node operation mode Software Version 4 0 Performance test application AT86RF233 ATxmega256A3 Main menu 1 Transceiver Configuration 2 Transceiver State Selection 3 Service Functions gt Table 9 6 Description for Sub menu Transceiver Configuration 1 Menu Functionalities Comment Option Value User can change channel 20 Allows the user to enter ISM frequencies also in case of AT86RF233 transceiver P Channel Page 0 User can change channel page Toggling RPC Reduced Power Consumption Only
307. ts allows e A node both RFD and FFD to initiate a disassociation procedure from its parent PAN Coordinator or Coordinator e a node both RFD and FFD to handle a received disassociation notification frame from its parent e node both RFD and FFD to poll for a pending indirect disassociation notification frame 4 Atmel AVR2025 8412D AVR 5 12 Atmel AVR2025 e anode FFD only to initiate a disassociation procedure to its child Since the disassociation notification frame may be received indirectly also the feature MAC_INDIRECT_DATA_BASIC is required 44 7 MAC DISASSOCIATION FFD SUPPORT This feature is a typical FFD feature that allows a node to transmit an indirect disassociation notification frame to one of its children The following components are required as well MAC DISASSOCIATION BASIC SUPPORT e MAC INDIRECT DATA BASIC MAC INDIRECT DATA FFD 4 4 8 MAC scan components These components allow a node to perform a specific type of scanning e MAC SCAN ACTIVE REQUEST CONFIRM The node is able to perform an active scan to search for existing networks e MAC SCAN ED REQUEST CONFIRM The node is able to perform an energy detect scan e MAC SCAN ORPHAN REQUEST CONFIRM The node is able to perform an orphan scan in case it has lost its parent e MAC SCAN PASSIVE REQUEST CONFIRM The node is able to perform a passive scan to search for existing networks This feature is only available if beacon enabled networks
308. ts of the application 4 6 Application security support 48 Atmel AVR2025 The MAC stack supports application security features such as the algorithm plain AES encryption support by means of two different layers SAL Security Abstraction Layer see Section 2 2 2 e STB Security Toolbox see Section 2 2 3 The SAL as low level AES functionality API is supported for various hardware AES engines in MCUs and transceivers The STB as high level security abstraction API is e Supported for SAL based systems the STB requires either one of the SAL implementations see Sections 6 1 5 2 and 6 1 5 1 or e Used stand alone without using any SAL implementation for ARM systems with incorporated hardware crypto engine see Section 6 1 5 3 such as the Atmel AT91SAM7XC256 SEM 773 4 17 Usage of the security layers by an application HW based Security 8412D AVR 5 12 Atmel AVR2025 Figure 4 17 gives an overview which combinations of the two security layers are meaningful It can be seen that the following security combinations are supported 12 Utilization of hardware AES in transceivers such as Atmel AT86RF212 Atmel AT86RF231 and Atmel AT86RF232 by using the STB on top of the SAL SAL TYPE AT86RF2xx This combinations can be used in conjunction with any MCU 13 Utilization of hardware AES in single chip transceivers such as Atmel ATmega128RFA1 by using the STB on top of the SAL SAL TYPE
309. ty for all serial I O related functionality This included currently UART and or USB AMEL 2s 8412D AVR 5 12 AIMEL SESE Depending on the available and utilized serial I O peripherals on the target MCU please check the corresponding data sheet of the target MCU and board this file needs to be updated 11 4 2 Example implementation of PAL for Atmel ATxmega256A3 This section describes the porting activities explained in the previous sections in general more specifically for the example of porting an existing software package to the new target MCU ATxmega256A3 on CBB board with radio extender board REB231ED V4 1 1 11 4 2 1 Step 1 Identify the MCU family of the new MCU The target MCU is the ATxmega256A3 It is a member of the Atmel AVR ATxmega family Therefore new code of this MCU is based the PAL_GENERIC_TYPE XMEGA 11 4 2 2 Step 2 Add the new MCU to file pal_types h To add support for ATxmega256A3 open PAL Inc pal types h and add the ATxmega256A3 to the section where all ATxmega MCUS are listed Use a non existing unique value for the target MCU Example elif PAL GENERIC TYPE XMEGA PAL TYPE for XMEGA MCUs define ATXMEGA128A1 0x01 define ATXMEGA256A3 0x02 elif PAL GENERIC TYPE AVR32 For better readability the target MCU has been added to reflect the alphabetical order of the MCU directory name Also the existing val
310. ual COM port for the Atmel RZ600 board based on the CDC driver is provided in the software package see at32uc3xxx cdc inf in directory _ UtilsV AVR32 USB Driver The debugger connections are explained in the sections below using a 10 JTAG connector Figure 10 28 RZ600 Atmel AT32UC3A3256S connection details 10 4 9 Atmel AT91SAM3S EK The 915 35 can be used to create platforms using Atmel SAM3S MCUs such as Atmel AT91SAM3S4C MCUs It provides currently three LEDs and Atmel QTouch for user interaction See PAL SAM3 AT91SAM3S4C Boards RZ600_2XX_SAM3SEK Images need to be flashed using SAM ICE Images can also be downloaded using SAM BA CDC e A USB driver providing a virtual COM port for the AT91SAM3S EK board based on the CDC Driver is provided in the software package see AT91SAM3S EK inf in directory PAL Board_Utils SAM3SEK_USB_Driver 22 Atmel 2025 8412D AVR 5 12 Atmel AVR2025 Figure 10 29 Atmel AT91SAM3S EK connection details 10 4 10 Atmel SAM3S USB sticks SAM3S USB sticks are based on Atmel AT91SAMSSAB It provides currently three LEDs for user interaction e See PAL SAM3 AT91SAM3S4B Boards DERF_USB_XXEXX e Images need to be flashed using Atmel SAM ICE and SAM ICE adaptor Images can also be downloaded using Atmel SAM BA CDC e A USB driver providing a virtual COM port for the SAM3S USB sticks based on the CDC Driver
311. uded in the build e MAC SYNC LOSS INDICATION MAC ASSOCIATION REQUEST CONFIRM or SYNC REQUEST 6 2 2 3 7 Dependency from BEACON SUPPORT Whenever the feature MAC SYNC REQUEST is used also the switch BEACON SUPPRT is required to be included in the build If the requirement is not met the C pre processor will indicate an error AIMEL 83 8412D AVR 5 12 7 Migration History AIMEL amp 71 Guide from version 2 6 x to 2 7 x Atmel AVR2025 version 2 7 x contains mac security and example applications to demonstrate the mac security feature AVR Studio 5 support got added for all the Atmel AVR 8bit and 32bit families Two new MAC applications got added which covers most of the features of Beacon and No beacon MAC 1 1 Guide from version 2 5 x to 2 6 x With the release of Atmel AVR2025 version 2 6 x a number of significant hardware platforms added Different families of MCUs are added to the current release and naming few of them are Atmel AVR32 Atmel SAM3S and CBB kit The kits supported on AVR32 Family are Atmel RZ600 Atmel AT32UC3A3256 Atmel AT32UC3L EK Atmel AT32UC3L04 and Atmel STK 600 Atmel AT32UC3B1128 The kits supported on SAM8S family are Atmel SAM3S EK Atmel AT91SAM3S4C DERF_USB_13E00 DERF_USB_23E00 USB Kits Atmel AT91SAM3S4B 7 2 Guide from version 2 4 x to 2 5 x 7 2 1 7 2 1 1 84 MAC API changes Atmel AVR2025 With the release of Atmel AVR2025 version 2 5 x a number of
312. ues of the defines have been updated The actual numerical value of each define is not important as long as each MCU within a specific PAL GENERIC TYPE has a unique value 11 4 2 3 Step 3 Identify an already supported MCU that best fits the new MCU as base MCU From all currently supported MCUs within the Atmel ATxmega family the Atmel ATxmega128A1 is selected as base MCU to start the porting to the target MCU ATxmega256A3 11 4 2 4 Step 4 Copy the PAL directory of the base MCU Example Copy the entire directory PAL KMEGA ATXMEGA128A1 and rename it to directory PAL XMEGA ATXMEGA256A3 Your directory PAL XMEGA now contains the following entries ATXMEGA128A1 ATxmega256A3 Generic 220 Atmel 2025 8412D AVR 5 12 Atmel AVR2025 The directory ATxmega256A3 currently contains the identical code from the directory ATXMEGA128A1 from the base MCU It comprises of the following directories Boards Inc Sre 11 4 2 5 Step 5 Identify the base board best fitting the target board Within the board directory of the target MCU PAL XMEGA ATXMEGA256A3 Boards a variety of subdirectories are existing Please remove all directories except REB 4 1 CBB Now the following entries exist e Directory REB 4 1 CBB e File pal boardtypes h The directory REB 4 1 CBB contains the board implementation for the Atmel AT86RF231 transceiver based on the board REB231ED V4 1 1 on top of a CBB board For more information ab
313. uild can simply be started as follows e Start AVR Studio 4 e Display the Connect dialog 8412D AVR 5 12 Atmel AVR2025 Figure 8 2 AVR Studio 4 Connect dialog 1 File Project Build Tools Debug Help Ld od cio I7 7 751 5 Display the Connect Dialog a ea Loaded plugin 5 500 Address Value Bits Message Sd rind in Files Breakpoints and Tracepoints CAP NUM e Select the proper Atmel AVR Programmer for example Atmel AVR JTAGICE and press Connect Figure 8 3 Atmel AVR Studio 4 Select AVR Programmer dialog Baud rate COM5 fi 15200 X DES Baud rate changes are Tip To auto connect to the programmer used last time press the Programmer active immediately button on the toolbar Note that a tool cannot be used for programming as long as it is connected in a debugging session In that case select Stop Debugging first Disconnected Made e In case more than one JTAGICE are detected by AVR Studio select the proper Id Figure 8 4 AVR Studio 4 Select JTAGICE dialog 008000000808 0080000020 2 008000004 ik AMEL or 8412D AVR 5 12 AMEL e After the JTAGICE selection the JTAGICE dialog opens Select the Main tab Within this tab select the proper Device and Signature Bytes for example Atmel ATmega1281
314. uint32 t UnscannedChannels uint8 t ResultListSize void ResultList We are not interested in the actual scan result because we start our network on the pre defined channel anyway Start a nonbeacon enabled network wpan mlme start req DEFAULT PAN ID DEFAULT CHANNEL DEFAULT CHANNEL PAGE Bg L5 true false false The wpan mlme start req will be confirmed with usr_mlme_start_conf void usr mlme start conf uint8 t status if status MAC_SUCCESS Network is established Waiting for association indication from a device pal led LED 1 LED else something went wrong restart wpan mlme reset req true AIMEL 135 8412D AVR 5 12 AIMEL EEE The PAN Coordinator is waiting for devices to associate If a device initiates the association procedure the Coordinator s MAC layer indicates this with the callback function usr_mlme_associate_ind The coordinator either responds with a short address for this device passed to wpan mlme associate resp or denies the request with the error code PAN CAPACITY The function get next short addr is application specific implementation and checks if an association request is accepted or not void usr mlme associate ind uint64 t DeviceAddress uint8 t CapabilityInformation Any device is allowed to join the network
315. urrently always the 32MHz Internal RC Oscillator is utilized In order to gain the proper system clock the corresponding prescaler needs to be set The corresponding implementation can be found in file board c in function clock init which is called during PAL initialization 11 6 1 3 Event system initialization The hardware timer used for this board is always driven by the event system This is implemented in file pa board c in function timer init non generic by using the macro TIMER SRC DURING TRX SLEEP This macro is implemented in file pal config h Currently always the Event Channel 0 is used as timer source Since the timer runs at 1MHz speed the Event Channel 0 is configured to provide events at 1 rate The is implemented in pal_board c in function event system init where the proper Prescaler for this particular Event Channel is set As already mentioned the SPI between the MCU and the transceiver needs to be initialized properly with the border condition that the SPI rate must not reach 8MHz Thus the largest trivially selectable SPI speed is 4MHz The SPI is initialized in file pal config h in function macro TRX INIT This macro is called by function trx interface init see file pal trx access c for the ATxmega family In order to comply whit he data sheet for the transceivers and the corresponding Software Programming Model certain very small delays are required such as 1 or even 500ns Since
316. used within the entire application In order to save code size and simply the application if the Timestamp parameter is not required the Timestamp parameter as well as the complete handling to timestamping in the entire stack can be omitted This can be controlled via the build 8412D AVR 5 12 7 2 1 2 8412D AVR 5 12 Atmel AVR2025 switch ENABLE TSTAMP For more information about this build switch see Section 6 1 Starting with release 2 5 x timestamping is excluded as default i e the Timestamp parameter is not included into the mentioned callback functions If an application utilizes the build switch in its Makefile or project files timestamping is performing within the stack and thus the Timestamp parameter is included in the callback functions An example of a MAC application using timestamping can be found in App3 Beacon Payload The updated API for the corresponding callback functions is defined as if defined ENABLE TSTAMP void mcps data conf uint8 t msduHandle uint8 t status uint32 t Timestamp else void usr_mcps_data_conf uint8_t msduHandle uint8 t status endif ENABLE TSTAMP and void usr mcps data ind wpan addr spec t SrcAddrSpec wpan addr spec t DstAddrSpec uint8 t msduLength uint8 t msdu uint8 t mpduLinkQuality ifdef ENABLE TSTAMP uint8 t DSN uint32 t Timestamp else uint8_t DSN endif ENABLE TSTAMP
317. vice can be implemented as such that the Device maintains a timer with the same time interval that the Coordinator wants to transmit its data to the Device Upon expiration of this timer the application of the Device can then enable its receiver for a certain amount of time or until it receives data from the Coordinator and turn off the receiver again The receiver can be enabled or disabled by using the MAC API function wpan mlme rx enable req The parameter RxOnDuration contains the value number of symbols for example one symbols is 16 for 2 4GHz networks that the receiver shall be enabled If this parameter is zero 0 the receiver of the node will be disabled The parameters DeferPermit and RxOnTime shall be set to 0 for a nonbeacon enabled network since these parameters are obsolete for nonbeacon enabled networks If this scheme is used handling of power management is done by the device itself When the RxEnable timer expires or if parameter RxOnDuration is zero the MAC will 8412D AVR 5 12 Atmel AVR2025 initiate its standard power management scheme and put the transceiver again into SLEEP if allowed that is in case macRxOnWhenldle is False 5 2 3 Handshake between end device and coordinator Another scheme is based on a combination of enabling the receiver in conjunction with a handshake scheme between End Device and the Pan Coordinator The End Device enables its receiver periodically as in Section 5

Download Pdf Manuals

image

Related Search

Related Contents

Privatização e regulação do sector da água  Media Converter User Manual  Dale Tiffany 7655/1LTA Installation Guide  govecs go! s1.2  PASCO Specialty & Mfg. ME-6828 User's Manual  User Manual for 500kW Photovoltaic Grid  Samsung PS-42V6S Bruksanvisning  Salsbury Industries 4975GRY Installation Guide  CMA5000a  ASSMANN Electronic AKB-1 cable tie  

Copyright © All rights reserved.
Failed to retrieve file