Debugging

Connecting to target through the JTAG Interface

A minimum of 6 wires is required to connect AVR Dragon to the target board. These Signals are TCK, TDO, TDI, TMS, VTref and GND.

Optional line is the nSRST. The nTRST signal is not used, and is reserved for compatibility with other equipment.

nSRST is used to control and monitor the target reset line. This is however not necessary for correct emulation. But if the application code sets the JTD bit in the MCUCSR, the JTAG Interface will be disabled. For the AVR Dragon to reprogram the target AVR, it will need to have control of the Reset Pin.

The figure below shows which JTAG lines should be connected to the target AVR to ensure correct operation. To avoid drive contention on the lines it is recommended that series resistors are placed between the JTAG lines and external circuitry. The value of the resistor should be chosen so that the external circuitry and the AVR do not exceed their maximum ratings (i.e. sinks or sources to much current).

Connecting AVR Dragon to Target Board

Figure 3.13. 


Figure 3.14. 


Connecting AVR Dragon to several devices placed in a JTAG Chain

AVR Dragon support emulation of devices placed in a JTAG Chain. When connecting N devices in a JTAG scan chain all devices should connect to TMS and TCK in parallel. The first device should connects it's TDI to the emulator while the TDO should be wired to TDI of the next device up to device N. The last device should connects it's TDO to the emulator.

Connecting AVR Dragon to STK500

STK500 does not have a dedicated JTAG interface connector. To connect the AVR Dragon to the STK500 board, the JTAG Probe must be strapped to the appropriate JTAG Port Pins of the target device using a squid cable. Check the target device datasheet for the location of the JTAG pins on the appropriate device. Figure below shows an example on how the pins should be connected for an ATmega32 on the STK500. Remember to remove the reset jumper on the STK500 if the reset pin is going to be controlled from the AVR Dragon.

Note: Add-on cards for the STK500 like e.g. STK501/502 may have a dedicated JTAG connector.

Example: Connecting AVR Dragon to STK500 with ATmega32

Figure 3.15. 


STK500 JTAG Adapter

The STK500 JTAG Adapter, that comes with the JTAGICE mkII, can be used to simplify the connection to the STK500 for AVR devices with JTAG that mates with socket SCKT3100A3 and SCKT3000D3 on the STK500.

Figure 3.16. 


Enabling the JTAG Enable fuse

If the JTAGEN fuse (JTAG Enable) in the target device is un-programmed, the JTAG Interface will be disabled. This fuse cannot be programmed through the JTAG Interface and must therefore be programmed through the ISP Interface or High Voltage Serial or Parallel Interface.

Connecting to target through the debugWIRE Interface

A minimum of 3 wires is required for communication between AVR Dragon and the target board with the debugWIRE interface. These Signals are RESET, VTref and GND.

Important!

This interface uses only 1 pin, (RESET pin) for communication with the target. To enable the debugWIRE interface on an AVR Device, the debugWIRE Enable fuse (DWEN) must be programmed, (DWEN=0). AVR devices with debugWIRE interface are shipped with the DWEN fuse un-programmed from the factory. The debugWIRE interface itself cannot enable this fuse. The DWEN fuse can be programmed through ISP mode, which requires connection to a 6-pin header. For this reason it is recommended to place the full 6-pin ISP connector on your target board to simplify emulation and programming.

NOTE: When the DWEN fuse is set, the ISP Interface normal functionality is disabled. This because the debugWIRE must have control over the RESET pin. When DWEN is set it is no longer possible to use ISP. Use debugWIRE or High Voltage programming to disable the DWEN fuse.

If using this connection from AVR Dragon on a STK500, be sure to detach the RESET jumper on the STK500. And connect to the correct ISP header for the actual AVR device, guided by the colour code in the STK500 silk-print.

AVR Dragon debugWIRE connector

Figure 3.17. 


Figure 3.18. 


Figure 3.19. 


Connecting AVR Dragon probe to 6-pins ISP header using a 6-pin cable

When DWEN fuse is programmed, there is only need for GND, VTref and RESET line for using the debugWIRE interface. However to ease the task of changing between ISP mode and debugWIRE mode, it is recommended to do debugWIRE with all six lines connected. The AVR Dragon will automatically tristate all unused ISP pins when running debugWIRE.

Re-enabling the ISP interface

By following the description below, the ISP Interface is re-enabled.

  1. Connect the AVR Dragon to the target with ISP (6-pin connection) as described above.

  2. Load a project and Start a debug session using the "Start Debugging" command (found under the Debug pulldown-menu in AVR Studio)

  3. Open "AVR Dragon Options" (found under the Debug pulldown-menu in AVR Studio) and select the "Connections" tab.

  4. Click on the button "disable DebugWIRE" as shown in the figure below. And click "Yes" in the next message box.

Figure 3.20. 


Note: Some precautions regarding the RESET line must be taken to ensure proper communication over the debugWIRE interface. If there is a pull-up on the RESET line, this resistor must be larger than 10Kohm, and there should be no capacitive load. The pull-up resistor is not required for debugWIRE functionality. Other logic connected to the RESET line should be removed.

It's not possible to use the debugWIRE Interface if the lockbits on the target AVR are programmed. Always be sure that the lockbits are cleared before programming the DWEN fuse and never set the lockbits while the DWEN fuse is programmed. If both the debugWIRE enable fuse (DWEN) and lockbits are set, one can use High Voltage Programming to do a chip erase, hence clear the lockbits. When the lockbits are cleared the debugWIRE Interface will be re-enabled.

The ISP Interface is only capable of reading fuses, signature and do a chip erase when the DWEN fuse is unprogrammed.