User manual

Atmel-ICE [USER GUIDE]
42330A-MCU-07/2014
34
See “Debug Options” on page 28 for details on how to set the target clock frequency using the software front-
end.
JTAGEN and OCDEN fuses
The JTAG interface is enabled using the JTAGEN fuse, which is programmed by default. This allows access to
the JTAG programming interface. Through this mechanism, the OCDEN fuse can be programmed (by default
OCDEN is un-programmed). This allows access to the OCD in order to facilitate debugging the device. The
software front-end will always ensure that the OCDEN fuse is left un-programmed when terminating a session,
thereby restricting unnecessary power consumption by the OCD module. If the JTAGEN fuse is unintentionally
disabled, it can only be re-enabled using SPI or PP programming methods.
If the JTAGEN fuse is programmed, the JTAG interface can still be disabled in firmware by setting the JTD bit.
This will render code un-debuggable, and should not be done when attempting a debug session. If such code
is already executing on the Atmel AVR device when starting a debug session, the Atmel-ICE will assert the
RESET line while connecting. If this line is wired correctly, it will force the target AVR device into reset, thereby
allowing a JTAG connection.
If the JTAG interface is enabled, the JTAG pins cannot be used for alternative pin functions. They will remain
dedicated JTAG pins until either the JTAG interface is disabled by setting the JTD bit from the program code, or
by clearing the JTAGEN fuse through a programming interface.
Note
Be sure to check the "use external reset" checkbox in both the programming dialog and debug
options dialog in order to allow the Atmel-ICE to assert the RESET line and re-enable the JTAG
interface on devices which are running code which disables the JTAG interface by setting the JTD
bit.
IDR events
When the application program writes a byte of data to the OCDR register of the AVR device being debugged,
the Atmel-ICE reads this value out and displays it in the message window of the software front-end. The IDR
register is polled every 50ms, so writing to it at a higher frequency will NOT yield reliable results. When the
AVR device loses power while it is being debugged, spurious IDR events may be reported. This happens
because the Atmel-ICE may still poll the device as the target voltage drops below the AVR’s minimum operating
voltage.
9.2.2 debugWIRE OCD
The debugWIRE communication pin (dW) is physically located on the same pin as the external reset (RESET).
An external reset source is therefore not supported when the debugWIRE interface is enabled.
The debugWIRE Enable fuse (DWEN) must be set on the target device in order for the debugWIRE interface
to function. This fuse is by default un-programmed when the Atmel AVR device is shipped from the factory. The
debugWIRE interface itself cannot be used to set this fuse. In order to set the DWEN fuse, SPI mode must be
used. The software front-end handles this automatically provided that the necessary SPI pins are connected. It
can also be set using SPI programming from the Atmel Studio programming dialog.
Either:
Attempt to start a debug session on the debugWIRE part. If the debugWIRE interface is not enabled, Atmel
Studio will offer to retry, or attempt to enable debugWIRE using SPI programming. If you have the full SPI
header connected, debugWIRE will be enabled, and you will be asked to toggle power on the target - this
is required for the fuse changes to be effective.
Or:
Open the programming dialog in SPI mode, and verify that the signature matches the correct device.
Check the DWEN fuse to enable debugWIRE.
Note
It is important to leave the SPIEN fuse programmed, the RSTDISBL fuse unprogrammed! Not
doing this will render the device stuck in debugWIRE mode, and high-voltage programming
will be required to revert the DWEN setting.
To disable the debugWIRE interface, use high-voltage programming to unprogram the DWEN fuse. Alternately,
use the debugWIRE interface itself to temporarily disable itself, which will allow SPI programming to take place,
provided that the SPIEN fuse is set.