4.1 Introduction to On-chip Debugging (OCD)
A traditional Emulator is a tool which tries to imitate the exact behavior of a target device. The closer this behavior is to the actual device’s behavior, the better the emulation will be.
The Atmel JTAGICE3 is not a traditional Emulator. Instead, the JTAGICE3 interfaces with the internal On-Chip Debug system inside the target Atmel AVR device, providing a mechanism for monitoring and controlling its execution. In this way the application being debugged is not emulated, but actually executed on the real AVR target device.
With an OCD system, the application can be executed whilst maintaining exact electrical and timing characteristics in the target system – something not technically realizable with a traditional emulator.
Run Mode
When in Run mode, the execution of code is completely independent of the JTAGICE3. The JTAGICE3 will continuously monitor the target AVR 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, program execution is halted, but all I/O will 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 AVR OCD module contains a number of program counter comparators implemented in 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 AVR target. Usually one such hardware comparator is ‘reserved’ by the debugger for internal use. For more information on the hardware breakpoints available in the various OCD modules, see the OCD implementations section.
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 AVR devices have OCD modules supporting the BREAK instruction. For more information on the software breakpoints available in the various OCD modules, see the OCD implementations section.