4. On-chip Debugging
4.1. Introduction
On-chip Debugging
An on-chip debug module is a system allowing a developer to monitor and control execution on a device
from an external development platform, usually through a device known as a debugger or debug adapter.
With an OCD system the application can be executed whilst maintaining exact electrical and timing
characteristics in the target system, while being able to stop execution conditionally or manually and
inspect program flow and memory.
Run Mode
When in Run mode, the execution of code is completely independent of the Atmel-ICE. The Atmel-ICE
will continuously monitor the target device to see if a break condition has occurred. When this happens
the OCD system will interrogate the device through its debug interface, allowing the user to view the
internal state of the device.
Stopped Mode
When a breakpoint is reached, the program execution is halted, but some I/O may continue to run as if no
breakpoint had occurred. For example, assume that a USART transmit has just been initiated when a
breakpoint is reached. In this case the USART continues to run at full speed completing the transmission,
even though the core is in stopped mode.
Hardware Breakpoints
The target OCD module contains a number of program counter comparators implemented in the
hardware. When the program counter matches the value stored in one of the comparator registers, the
OCD enters stopped mode. Since hardware breakpoints require dedicated hardware on the OCD module,
the number of breakpoints available depends upon the size of the OCD module implemented on the
target. Usually one such hardware comparator is ‘reserved’ by the debugger for internal use.
Software Breakpoints
A software breakpoint is a BREAK instruction placed in program memory on the target device. When this
instruction is loaded, program execution will break and the OCD enters stopped mode. To continue
execution a "start" command has to be given from the OCD. Not all Atmel devices have OCD modules
supporting the BREAK instruction.
4.2. SAM Devices with JTAG/SWD
All SAM devices feature the SWD interface for programming and debugging. In addition, some SAM
devices feature a JTAG interface with identical functionality. Check the device datasheet for supported
interfaces of that device.
4.2.1. ARM CoreSight Components
Atmel ARM Cortex-M based microcontrollers implement CoreSight compliant OCD components. The
features of these components can vary from device to device. For further information consult the device's
datasheet as well as CoreSight documentation provided by ARM.
Atmel Atmel-ICE [USER GUIDE]
Atmel-42330C-Atmel-ICE_User Guide-10/2016
24