Programming and Debugging with the Dragon and JTAG

Slides:



Advertisements
Similar presentations
EMS1EP Lecture 4 Intro to Programming Dr. Robert Ross.
Advertisements

Jason Howard. Agenda I. How to download robotc II. What is tele-op used for? III. How to build a basic tele-op program IV. Getting the robot to drive.
Lab7: Introduction to Arduino
Chung-Ta King National Tsing Hua University
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
ECE 353 WinAVR and C Debugging Tutorial By Adam Bailin ECE 353 Fall ‘06.
How to Debug VB .NET Code.
1-1 Embedded Software Development Tools and Processes Hardware & Software Hardware – Host development system Software – Compilers, simulators etc. Target.
Using PDG with e2studio: Example
LSU 06/04/2007BASIC Stamp Editor1 The BASIC Stamp Editor Programming Unit, Lecture 3.
Introduction Purpose Objectives Content Learning Time
Part 1 Using the ARM board And start working with C Tutorial 5 and 6
Silicon Labs ToolStick Development Platform
Driver Station MVRT 2009 – 2010 Season. Add information Breadboard Classmate PC USB Hub Joysticks Stop Button.
Getting started with Microsoft.NET Gadgeteer Comberton Village College Gadgeteer Club.
CHAPTER 1 XNA Game Studio 4.0. Your First Project A computer game is not just a program—it is also lots of other bits and pieces that make playing the.
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
Embedded Systems Programming 1 ETEE 3285 Topic HW3: Coding, Compiling, Simulating.
High Speed Data Converter University
Keith Elder Microsoft MVP
CPSC1301 Computer Science 1 Overview of Dr. Java.
Development of a microprocessor project with LPC2388 development board.
Bit-DSP-MicrocontrollerTMS320F2812 Texas Instruments Incorporated European Customer Training Center University of Applied Sciences Zwickau (FH)
Renesas Technology America Inc. 1 SKP8CMINI Tutorial 2 Creating A New Project Using HEW.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
Embedded C- Language Lets Learn fundamentals !!. An Embedded system is combination of computer hardware and software, and perhaps additional mechanical.
Programming and Debugging with the Dragon and JTAG Many thanks to Dr. James Hawthorne for evaluating the Dragon system and providing the core content for.
Chapter 1: Introduction to Computers and Programming
Lets Learn fundamentals !!
Workshop Setup The software/hardware used in this workshop are:
Making a 24hr Timer.
Introduction of Embedded C and demo programs
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Chapter 2: The Visual Studio .NET Development Environment
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
14 Compilers, Interpreters and Debuggers
Click through this presentation at your own pace.
Use of MPLab software Paul Cockshott.
The first change to your project files that is needed is to change the device to the correct FPGA. This is done by going to the Assignments tab on the.
Getting Started with ATMEL Studio 6
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Microcontroller Applications
Computer Programming I
Arduino Part 1 Topics: Microcontrollers Programming Basics
PRU-ICSS Programming with CCS
Programming Scratch to Control a K’NEX Fairground Ride
Introduction to Arduino Microcontrollers
Using Visual Studio with C#
Programming Boe-Bots (Part 1)
Arthi Varadarajan and Dr. James M. Conrad
Roller Coaster Design Project
CIS 470 Mobile App Development
Welcome to Digital Electronics using the Arduino Board
Tim Sumner, Imperial College, Rm: 1009, x47552
Tonga Institute of Higher Education
Turning Point (zapper) quick guide Turning Point 5
ECE 3567 Microcontroller Lab
Software Setup & Validation
CIS 470 Mobile App Development
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Arduino Leonardo Setup
Lab #1: Getting Started.
Introduction to Arduino IDE and Software
Workshop for Programming And Systems Management Teachers
CIS 694/EEC 693 Android Sensor Programming
ECE 3567 Microcontrollers Lab
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Programming and Debugging with the Dragon and JTAG

Why dynamic debugging Embedded systems require the development environment (Atmel Studio on the PC) is different from the run-time environment (the microcontroller). Thus, whilst the compiler finds syntax errors, it is much harder to find logical / semantic errors while the code is in the development environment – i.e. We can’t run it to see what happens! Debugging provides information such as ‘Does the program reach a certain line of code?’. ‘Is the program doing what I expect at the line of code?’ ‘What happens to a certain variable at a particular line of code?’ You need to find out where the error is in a program even if you just output some ‘debug’ text to the screen at critical points in your code → easy to do when developing desktop applications in Java (e.g.) but not so easy for an embedded application. The only output you have by default on STK300 boards are the LED’s – you can display patterns to signal the state of the program – but this is limited. The Dragon device fills this gap – it allows us to run the program on the deployment platform, whilst viewing the output and status on the PC screen. Efficient debugging tools and techniques save you a lot of time.

STK300 and AVR Dragon hardware setup Plug the STK300 power supply lead into the board and plug the power unit into the wall. Plug the IDC ribbon cable into the JTAG ports on the STK300 board and on the AVR Dragon board (Be very careful to make sure the connectors are in the right place and the right way round – see the pictures, and pay attention to the red strip which marks bit 0). Plug the USB cable into a spare port on the computer and the other end into the Dragon. The Dragon can be interfaced directly from AVR studio to both program and debug the chip.

STK300 Board ATmega1281 microcontroller DRAGON Programmer/Debug board Power cable for STK300 Board USB cable connects Dragon Board to PC and also provides power IDC10 cable connects Dragon Board STK300. Take great care with the orientation of this cable, note the position of the red wire and connector at each end

Verify that the AVR Dragon and the STK board are connected correctly and that the Dragon is interfaced to Atmel Studio 6 1. In Atmel Studio 6 go to Tools→Device Programming. 2. Select Tool: AVR Dragon tool, Device: ATmega1281, Interface: JTAG, and click Apply. 3. Target voltage should read approximately 5.0V. 4. Read the unique Device Signature. If Atmel studio can read the device signature (displayed as a hexadecimal number) then the interface between PC and Atmel, via the Dragon, is correct.

Building your code (creating a .hex file) To program the Atmel microcontroller, you first need to create a .hex file. This is essentially the machine language version of your C or assembly program. In Atmel studio 6, Click Build -> Build solution If there are no errors it should report: Build succeeded. ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ========== A .hex file will be created within your project folder. Note, if using C, the .hex file will be placed in either a ‘debug’ or ‘release’ sub-folder.

Programming through AVR Studio 6 By ‘programming’ we mean uploading our code (the .hex file) to the Atmel microcontroller via a device called the programmer (the Dragon in this case). 1. Select 'Memories' tab in Tools→Device programming 2. Select a hex file to program (browse to the file) 3. Make sure Erase Device and Verify flash are checked 4.Click 'Program’.

Debugging through AVR Studio 6 This C program can be used to demonstrate debugging with the Dragon. The while loop doubles the ‘ledValue’ value and displays its 1s compliment on the LED’s connected to Port B. Delay() adds about 1 second delay to the loop so you can see the LED’s moving. The call to Delay() has been commented out to simplify single-step debugging. You can enter debug mode by pressing the green triangle ‘play’ button at the top of Atmel studio (or F5). To end your debug session, click the ‘stop’ button (or Cntl + Shift + F5). See also the sample code that has been provided with dynamic debug instructions added: Dragon_Debug_BinaryCount_1281_asm Dragon_Debug_BinaryCount_1281_C

Breakpoints Place a breakpoint by clicking in the margin next to the if statement (the line will become highlighted red). Run the debugger again and the program will pause when it hits this line. Several important things should be noticed: - Hover the mouse pointer over the ledValue variable and it will show you the real value. It should be 2. - Click continue or press F5. ledValue should be 4 this time round, next 8, 16 etc. - Also notice that the LED’s change every time you press F5. You can directly change the value of ports and registers by opening the interface and clicking to toggle the individual bits. One of the biggest advantages of debugging with the dragon is that you can physically see the state of the hardware in relation to the state of the software.

Stepping through code and editing code “on the fly” Use F9 to set / remove a breakpoint on a line of code. F5 is interpreted as “run to breakpoint” – very useful if you want to place a breakpoint in a loop, and run one full loop on each press of F5. Once the program is paused (at a breakpoint), you can even step through the code one line at a time or edit a line of code while the program is running. For stepping through code use step into (F11), step over (F10) and step out (Shift+F11) which steps into a method which we are paused on, steps over and steps out respectively. Change a line of code before it gets executed then run it to see the result all while the program is still running. Ultimately, effective debugging will save you a lot of time, so learn how to use it ASAP.