Home
Debugging in AVR Studio
Contents
1. Meshlletics CD ZigBeeNet Software 1 0 Application Note Creating building amp debugging ZigBeeNet applications in AVR Studio Doc AN 481 07 v 2 0 March 2008 2008 MeshNetics a u Meshhetics nc BUILDING 8 DEBUGGING ZIGBEENET APPLICATIONS IN AVR STUDIO APPLIGATION NOTE Document Summary This document gives a brief introduction to the process of creating building and debugging ZigBeeNet based projects using Atmel s IDE AVR Studio 1 WinAVR compiler 2 3 and JTAGICE mkll hardware 4 on a PC running Microsoft Windows 2000 XP In this tutorial we will create a small project that controls one of the LEDs on MeshNetics MeshBean development board and try to debug it using AVR studio and JTAGICE mkll hardware Document Conventions Buttons Dialog button names are denoted in Courier OK Cancel Menu Menu items are denoted in Courier and shown in order they must commands be selected File Open Keyboard Several keys should be pressed simultaneously in the order they shortcuts are listed F7 Ctrl Shift F5 Source code Code snippets are shown in colored text S EEK K K K k k k k k k k k k YK K K K K K YK KOK K KOK K K K KOK KOK K K KOK KOK kk e eG e K User s entry KCKCkCkCk k k k k ckck K K K AX KA kA k ck kck k kc kck ck kckckck ckck ck kk k k void fw userEntry FW ResetReason t resetReason Intended Audience This document is intended for developers wanting to get familiar
2. Project name Atmel AVR Assembler JDebugTest S AVR GCC IV Create initial file V Create folder Initial file JDebugTest T Location C Azdk release API S ampleApplication Ver 4 13 55 lt lt Back Next gt gt Finish Cancel Help Figure 2 Creating new project 2008 MeshNetics Page 4 12 a Meshheties n BUILDING amp DEBUGGING ZIGBEENET APPLICATIONS IN AVR STUDIO APPLICATION NOTE 4 Inthe next screen that appears see Figure 3 select JTAGICE mkII from the Debug platform list and ATmega1281 from the Device list Press Finish to close the wizard Welcome to AYR Studio 4 Select debug platform and device Debug platform Device AVR Dragon ATSOUSBE4 AVR Simulator ATSOUSBS2 AVR Simulator V2 preview ATmegal 28 ICE 200 ATmegal 280 ICE40 ICE 50 ATmegal6 JTAG ICE ATmeqalb2 JTAGICE mkll ATmegal64P ATmegal65 ATmegal65P ATmegal68 Port Auto ti Open platform options Ver 4 13 557 lt lt Back Finish Cancel Help Figure 3 Selecting debug platform and device Setting the Project Options The WinAVR toolchain requires using a so called makefile a plain text file that contains all the project options source target library file names and everything else needed to build the target image This is somewhat more difficult than using GUI but gives more control over the build process To use make
3. BSP lib X L STACK DIR Security BuildingBlocks lib X L STACK DIR PersistDataServer lib Libraries LIBS lMain lAPS lZDO 1 HAL LIB 1BSP 1NWK lSystemEnvironment 1 MAC LIB 1lAPS 1ZDO 1 HAL LIB 1BSP 1NWK lSystemenvironment 1SSPsw lPersistDataServer AS CROSS COMPILE as LD CROSS_COMPILE ld CC S CROSS COMPILE gcc CPP CROSS_COMPILE gt AR S CROSS COMPILE ar NM S CROSS COMPILE nm STRIP CROSS COMPILE strip OBJCOPY CROSS COMPILE objcopy OBJDUMP CROSS COMPILE objdump SIZE S CROSS COMPILE size 2008 MeshNetics Page 7 12 a Meshiletics errno BUILDING amp DEBUGGING ZIGBEENET APPLICATIONS IN AVR STUDIO APPLIGATION NOTE BUILDDIR objects N BUILDDIR objs DebugTest o N STACK DIR ConfigServer objs ConfigServer o Build all objects PROJECT PROJNAME srec PROJNAME hex objects CC S CFLAGS INCLUDEDIRS o SQ BUILDDIR objs DebugTest o BUILDDIR DebugTest c STACK DIR ConfigServer objs ConfigServer o STACK DIR ConfigServer src configServer c s s s S PROJECT objects CC objects STACK DIR S HAL PATH lib WdtInit o CFLAGS INCLUDEDIRS S LIBDIRS S LIBS lm o PROJECT SIZE td PROJECT S PROJNAME srec OBJCOPY O srec srec len 128 S PROJECT S PROJNAME srec S PROJNAME h
4. JEJE JE JE JE JE JE JE JEJE E JE JEJE JE XXE JE JE JEJE ASIA JE JEJE JE JE JE JEJEJE JE JE JEJE X JEJE JE E JE JE JE JE JE JE XE ASA AAAS B CPU Application task JE IEE FEIE EJE EIEE IE XXIII JEJE IE JEJE IEE JEJE IEE JEJEJE IE IEIE IEE JEJEJEJE JEJE IE IEE JEJEJEJE IEE JEJEJEJE IEEJA og void APL_TaskHandler E EEPROM EXTERNAL INTERR Ba JTAG t e StartBlinkTiner void StartBlinkTimer E PORTC t m T blinkTimer interval BLINK DELAY E SPORTO blinkTimer mode TIMER REPEAT MODE E SE PORTE blinkTiner callback TimerFired E PORTF HAL Start ppTimer amp blinkTimer ES PORTE aJ SPI TIMER COUNTER 0 TIMER COUNTER 1 TIMER COUNTER 2 H void TimerFired e BSP ToggleLed LED RED amp TIMER_COUNTER_3 TIMER_COUNTER_4 S TIMER_COUNTER_5 d TYMI ZZ The following functions MUST be present to build the executable image rod ZDO StartNetworkConf ZDO StartNetworkConf t confirmInfo ES as 3 5 USARTO all 4 E void ZDO_MgntNwkUpdateNot f ZDO_MgmtNwkUpdateNotf_t nwkParans Name Address Vaue H void ZDO WVakeUpInd void ZDO SleepInd y ZZ eof DebugTest c La E c zdk ZigBeeNet Applications DebugTest DebugTest c 4b Build x avr gcc objs DebugTest o Components ConfigServer objs ConfigServer o Components HAL atmegal281 lib WdtInit o mncu atuegal281 0s E Environment include I Components APS inc
5. k K K K K K KOK K K KOK k kok k OK KOK kk ck kok k k kk kck ck kk kk kk Application task Fe k kk kk k K k K k K K K K kc k kc k k AX AX K kc k Ck k kc k kckckck ck ck k KOK kokckckck KOK KOR void APL TaskHandler StartBlinkTimer void StartBlinkTimer blinkTimer interval BLINK_DELAY blinkTimer mod TIMER REPEAT MODE blinkTimer callback TimerFired HAL StartAppTimer amp blinkTimer void TimerFired BSP ToggleLed LED RED The following functions MUST be present to build the executable image void ZDO StartNetworkConf ZDO StartNetworkConf t confirmInfo I void ZDO_MgmtNwkUpdateNotf ZDO_MgmtNwkUpdateNotf_t nwkParams 2008 MeshNetics Page 9 12 A u Neshletics errno BUILDING 8 DEBUGGING ZIGBEENET APPLICATIONS IN AVR STUDIO APPLICATION NOTE void ZDO WakeUpInd void ZDO SleepInd I eof DebugTest c Adding existing source file to the project To add an existing source code file to the AVR Studio project click the Source files item in the AVR GCC panel normally located on the left of the AVR Studio window and select Add Existing Source File s from the pop up menu Select your source file using the dialog that appears and press OK to add this file to the project File Project Buld View Tools Debug Help DB ag o 4 54 Bhi hee A o race Disabled RA ak T 1080 Wb e
6. with writing ZigBee 802 15 4 applications using MeshNetics ZigBeeNet ZigBee stack Related Documents 1 2 3 4 5 2008 MeshNetics AVR Studio User Guide Available in HTML Help with the product hitp www atmel com dyn products tools card asp tool id 2725 WinAVR User Manual Ed by Eric B Weddington Using the GNU Compiler Collection By Richard M Stallman and the GCC Developer Community JTAGICE mkll Quick Start Guide hitp www atmel com dyn resources prod documents doc2562 pdf ZigBit Development Kit User s Guide MeshNetics Doc S ZDK 451 Page 2 12 A u Meshheties n BUILDING amp DEBUGGING ZIGBEENET APPLICATIONS IN AVR STUDIO APPLICATION NOTE Pre requisites Make sure you have the latest versions of AVR Studio Service Pack http atmel com dyn products tools_card asp family id 6078family name AVR 8 2DBit RISC amp tool_id 2725 and WinAVR http winavr sourceforge net installed on your PC You ll also need one MeshBean board 5 and Atmel JTAGICE mkll device Creating a New project in AVR Studio 1 Start AVR Studio A project wizard window appears see Figure 1 Welcome to AYR Studio 4 New Project Recent projects Modified E C 2dk SampleApplication RemoteControl 111 aps 01 Oct 2007 18 27 54 d CAzdka KA PIS ample amp pplicationsBlink blink aps 24 Aug 2007 12 06 21 3 C 2dk Powerl anagementPowerM anage aps 27 Aug 2007 18 43 29 K C 2dk SimpleD ataE xc
7. Bean board Now select Debug gt Start debugging from AVR Studio application menu or press Ctr1 Alt Shift F5 Note that this command becomes available only after you ve run the Build command If you restart AVR Studio you will have to build the target image again AVR Studio will start programming the device with the built image indicating the progress with a progress bar at the bottom of the window 2008 MeshNetics Page 11 12 a Meshheties n BUILDING amp DEBUGGING ZIGBEENET APPLICATIONS APPLICATION NOTE IN AVR STUDIO Once the image download is complete AVR Studio will break execution at the first line of your program Press F5 to continue execution AVR Studio will now break and pause execution at the first breakpoint you ve set in your code see Figure 5 AYR Studio C zdk ZigBeeNet Applications DebugTest DebugTest c lB xi iE File Project Build Edit view Tools Debug Window Help 8x ing dd 354 BA BA SN ii aE oo z jo 9 ts aa Trace Disabled E r sk ss E x e Processor x Ei 1 0 View x ZHRRKREKKKKKKEKKKKKEKKKKKEKKKEKKKKKKEKKKKKKKEKKKKKKEKKKKKKKKKKKKKKKKKKKKKKEK Program Counter 0x000443 Application task 3 tela ANALOG COMPARATOR EJ Stack Pointer 0x21E5 ERE DAD CONVERTER X pointer 00871 void APL TaskHandler DANALOG_COMPARA Y pointer 0x21E7 e Star
8. Se am AVR GCC 8 DebugTest default Add Existing Source File s Create New Source File Sy Heade 3 Extern By Other Show File Paths Edit Configuration Options Building the Image 2008 MeshNetics Once you ve finished writing your code you can build the executable image from it by selecting Build gt Build from menu or just pressing F7 You can also use the Rebuild all command if you have a large project and want to be sure all changes to code are compiled Build window bottom of the screen will display output from the avr gcc compiler see Figure 4 Page 10 12 a Meshheties n BUILDING amp DEBUGGING ZIGBEENET IN AVR STUDIO APPLICATIONS APPLICATION NOTE AVR Studio C zdk ZigBeeNet Applications DebugTest DebugTest c zlelxi Fie Project Buld Edit View Tools Debug Window Help 8x Ded dad c Dw da ss 22 20H E i Es Trace Disabled Y LT D Q e Se un R avr ecc KIJ void StartBlinkTiner 1 0 View x EQ DebugTest default void TimerFired s LH anatoc_comparator lt Pea SE void ZDO StartNetworkConf ZDO StartNetworkConf t confirmInfo void ZDO_MgntNwkUpdateNot f ZDO MgntNwkUpdateNotf t nwkParans TD AD CONVERTER void ZDO WakeUpInd DebugTest c S Debug D ANALOG COMPARA E Header Files void ZDO Sleepind External Dependencies 8001 LOAD m e Other Files LHRH IE IEE E JE JE IE DE JEJE JE JEJE JE XXE JE E JEJE JE E
9. ex S OBJCOPY O ihex PROJECT PROJNAME hex burn avarice 2epf TARGET j dev ttyS0 Clean target clean rm rf TARGET objects PROJECT S PROJNAME hex PROJNAME eep PROJNAME srec T Writing Source Code You can write your source code either in AVR Studio or using any suitable text editor General file structure is the same you would use in any other C based project headers definitions code Here s the code we re going to use in this tutorial k kok k k K k kok k K K K K K K KOK K k kok k kok k K kk kk kok k kk KOR OK I kk kk LED Blinking Implementation Project C source Kk k k kCk ck kCkCk k K KOK K K KOK K K k kk KOK k k kc k KOK KOK kck ck kck ck ckck ck ckck ck kk e kx include lt apsTimer h gt include lt leds h gt include lt taskManager h gt include zdo h 2008 MeshNetics Page 8 12 A u Meshiletics errno BUILDING amp DEBUGGING ZIGBEENET APPLICATIONS IN AVR STUDIO APPLIGATION NOTE include lt configServer h gt include lt aps h gt variables defines define BLINK_DELAY 500 Period of blinking static HAL AppTimer t blinkTimer functions void StartBlinkTimer void TimerFired void ZDO StartNetworkConf ZDO StartNetworkConf tr confirmInfo void ZDO MgmtNwkUpdateNotf ZDO MgmtNwkUpdateNotf t nwkParams void ZDO WakeUpInd void ZDO SleepInd k k kok k k k k K K k
10. feq MAC AT86RF212 MAC LIB MACrf212 else MAC LIB MACrf230 endif endif endif endif ifeq HAL ATMEGA1281 HAL PATH HAL atmegal281 HAL LIB HALatmegal281 else HAL PATH HAL at91sam7x256 HAL LIB HALat91sam7x256 endif STACK DIR Components 2008 MeshNetics Page 6 12 a Neshletics errno BUILDING 8 DEBUGGING ZIGBEENET APPLICATIONS APPLICATION NOTE IN AVR STUDIO INCLUDEDIR S I include N IS STACK DIR SystemEnvironment include N I STACK DIR APS include I STACK DIR NWK include N I STACK DIR ZDO include N I STACK DIR MAC PHY include I STACK DIR MAC PHY MAC HWD PHY include N I STACK DIR MAC PHY MAC HWI include N I STACK DIR HAL PATH HAL HWI include N IS STACK DIR HAL PATH HAL HWD include N I STACK DIR BSP include IS STACK DIR ConfigServer include X IS STACK DIR PersistDataServer include N I STACK DIR Security BuildingBlocks include FEEFFE LIB P PATHS FLAGS OF INCLUDES LIBDIRS LS STACK DIR APS lib X L STACK DIR ZDO lib X L STACK DIR NWK lib N L STACK DIR MAC PHY lib N L STACK DIR HAL PATH lib X L STACK DIR SystemEnvironment lib N L STACK DIR
11. file in AVR studio go to Project gt Configuration Options menu and check the Use external makefile checkbox Press the button next to the text box and select your makefile usually located in the same folder as AVR Studio project Press OK to close the window Here s a sample makefile that you can use as a reference in future projects HEHE HEHE EEE AE FE AE FE E FE FE HH EEE FE FE FE FE FE EEE TE AE FE AE FE FE FE FE EH EEE FE HE FE HE FE EEE H Makefile for the project DebugTest FE HE E HE FE HEHE FE AE FE AE FE AE FE AE FE FE FE FE HERE FE FE FE FE EEE FE HE FE HE FE EEE H CROSS COMPILE CPU atmegal281 avr PROJNAME PROJECT DebugTest S PROJNAME elf 2008 MeshNetics Page 5 12 a u Meshheties errno BUILDING 8 DEBUGGING ZIGBEENET APPLICATIONS IN AVR STUDIO APPLIGATION NOTE SHELL bin bash COMPILER FLAGS CFLAGS mmcu CPU CFLAGS Os CFLAGS g CFLAGS Wall W CFLAGS ffunction sections CFLAGS Wl gc sections Initial DebugTest interval ms CFLAGS DDebugTest PERIOD 1000 DEFINES FLAGS Can be AT86RF230 AT86RF230B AT86RF231 AT86RF212 MAC AT86RF230 Can be ATMEGA1281 AT91SAM7X256 HAL ATMEGA1281 ifeq MAC AT86RF230 MAC LIB MACrf230 else ifeq MAC AT86RF230B MAC LIB MACrf230b else ifeq MAC AT86RF231 MAC LIB MACrf231 else i
12. hange aps 14 Sep 2007 19 31 00 3 C 2dk peer2peer_r2 peer2peer aps 12 Sep 2007 16 14 41 8 D zdk 5 ample amp pplicationNS ensorR ead Light aps 12 Sep 2007 18 25 27 C 2dk pingpong_r2 pingpong aps 12 Sep 2007 16 16 38 C zdk lowpower r3 coordinator aps O6 Apr 2007 21 49 37 4 D SzdkRZ200 API S ample amp pplicationhvsnml wsnml 09 Feb 2007 12 35 50 C 2dk RemoteControl RemoteControl aps 28 Aug 2007 15 49 33 Finish Cancel Help Figure 1 Project wizard window 2 Press the New Project button If the wizard window does not appear select Project gt New project from AVR Studio main menu 2008 MeshNetics Page 3 12 a u Neshletics errno BUILDING 8 DEBUGGING ZIGBEENET APPLICATIONS IN AVR STUDIO APPLIGATION NOTE 3 In the window that appears next see Figure 2 select AVR GCC in the Project type list enter project name in the Project name text box If you want AVR studio to create initial source file for you check the Create le checkbox and enter file name without extension in the sa initial f Initial file text box If you want AVR studio to create a folder with the name of the project check the Create folder checkbox Finally press the button next to the Location text box and select a directory for your project Press Next gt gt to go to the next screen Welcome to A R Studio 4 r Create new project Project type
13. lude I Components WWK include I Components ZD0 include I Components MAC PHY incl H L atmegal281 HAL HWI include I Components HAL atmegal281 HAL_HWD include I Conponents BSP include I Components ConfigServer Conponents APS lib L Components ZD0 lib L Components MUK lib L Components MAC PHY lib L Components HAL atmegal281 lib b L Components PersistDataServer lib lMain lAPS 1ZDO lHALatuegal281 1BSP 1NWK 1SystemEnvironment 1MACrf230 lAPS 1ZDO lHALatmege avr size td DebugTest elf text data bss dec hex filename r 4 message SS Find in Files PBreakpoints and Tracepoints ElBuild al M ATmegal281 JTAGICE mkII USB Inso coli2 CAP NUM OVR Figure 4 Building the image If the code contains no errors you will get a DebugTest e1f file in the same directory where project source files are located unless you ve specified a different output directory in makefile This is the executable image that will be used by debugger Debugging the Image You can now start the debugging session for the image you ve just built First connect your MeshBean to JTAGICE device and power up the devices both can be powered from USB To test the debugging features of AVR Studio set a breakpoint press F9 on any line of code that is sure to be executed In our case we do it for the TimerFired function that is going to be called periodically to blink on of the LEDs on Mesh
14. sions You can resume execution any time by pressing F5 Press Shi ft F5 to restart the debugger session To stop the debugger select Debug gt Stop debugging from menu or press Ctrl Shift F5 This command is available in stop mode only i e you first have to pause execution break and then stop it completely Page 12 12
15. tBlinkTimer Beoor LOAD Z pointer Ox0E83 cru Cycle Counter 0 a E EEPROM hura void StartBlinkTimer EXTERNAL INTERR Stop Watch blinkTimer interval BLINK DELAY BaJTAG SREG nommscimcim blinkTiner node TIMER REPEAT MODE 8 PORTA Registers blinkTiner callback TimerFired HAL Start ppTimer amp blinkTimer aS PORTE zgPORTC void TimerFired BSP_ToggleLed LED_RED Y The following functions MUST be present to build the executable image void ZDO StartNetworkConf ZDO StartNetworkConf t confirmInfo F YTIMFR COUNTER 1 El H Name Address Value Bits void ZDO MgntNwkUpdateNotf ZDO MgntNwkUpdateNotf t nwkParans 1 void ZDO WakeUpInd H H void ZDO SleepInd 1 H eof DebugTest c Rar GCC Processor E C zdk ZigBeenet Applications DebugTest DebugTest c 4 b Watch x Name Value Type Location 4 gt h NWatch 1 Watch 2 Watch 3 Watch 4 7 Message x gcc plug in CProjectTree OnSize al gcc plug in CProjectTree OnSize CProjectTree Onsize cx 254 cy 595 nType 9 ElBuld wessage SS Find in Files Breakpoints and Tracepoints ATmega1281 JTAGICE mkII USB Stopped e Ln 66 Col 1 CAP NUM OVR 2008 MeshNetics Figure 5 Debugging In the view menu you can select additional debug windows processor I O disassembler watch memory registers etc Pressing the right mouse button in the code editor also offers a few debugging options such as adding removing breakpoints and watch expres
Download Pdf Manuals
Related Search
Related Contents
Hotpoint RLS150G refrigerator Serie TT02 Guía del usuario - Mark-10 none 32323MBRZ Installation Guide Into the Dark — User Manual pdf 18kb ・ ・ リモコン付き冷風扇 (家庭用) A5523T 取扱説明書 LIGNE 3 - Marbache Philips 206V3LSB28 Copyright © All rights reserved.
Failed to retrieve file