29.6 Using the On-chip Debug System

As shown in Figure 29-1, the hardware support for On-chip Debugging consists mainly of:

  • A scan chain on the interface between the internal AVR CPU and the internal peripheral units
  • Break point unit
  • Communication interface between the CPU and JTAG system

All read or modify/write operations needed for implementing the Debugger are done by applying AVR instructions via the internal AVR CPU Scan Chain. The CPU sends the result to an I/O memory mapped location which is part of the communication interface between the CPU and the JTAG system.

The Break point Unit implements Break on Change of Program Flow, Single Step Break, two Program Memory Break points, and two combined break points. Together, the four break points can be configured as either:

  • 4 Single Program Memory break points
  • 3 Single Program Memory break points + 1 single Data Memory break point
  • 2 Single Program Memory break points + 2 single Data Memory break points
  • 2 Single Program Memory break points + 1 Program Memory break point with mask (“range break point”)
  • 2 Single Program Memory break points + 1 Data Memory break point with mask (“range break point”)

A debugger, like the Studio®, may however use one or more of these resources for its internal purpose, leaving less flexibility to the end-user.

A list of the On-chip Debug specific JTAG instructions is given in On-chip Debug Specific JTAG Instructions.

The JTAGEN fuse must be programmed to enable the JTAG Test Access Port. In addition, the OCDEN fuse must be programmed and no Lock bits must be set for the On-chip Debug system to work. As a security feature, the On-chip Debug system is disabled when any Lock bits are set. Otherwise, the On-chip Debug system would have provided a back-door into a secured device.

The Studio enables the user to fully control execution of programs on an AVR device with On-chip Debug capability, AVR In-Circuit Emulator, or the built-in AVR Instruction Set Simulator. Studio supports source level execution of Assembly programs assembled with AVR Assembler and C programs compiled with third party vendors’ compilers.

For a full description of the Studio, please refer to the Studio User Guide found in the Online Help in Studio. Only highlights are presented in this document.

All necessary execution commands are available in Studio, both on source level and on disassembly level. The user can execute the program, single step through the code either by tracing into or stepping over functions, step out of functions, place the cursor on a statement and execute until the statement is reached, stop the execution, and reset the execution target. In addition, the user can have an unlimited number of code break points (using the BREAK instruction) and up to two data memory break points, alternatively combined as a mask (range) break point.