AVR REGISTERS FOR DEBUGGING

Hi all
Is it possible to see the AVR micro registers at run time for debugging ?
Maybe transferring a register value into a VAR so it will be displayed at run time ?

Thanks
Elico

Almost anything is possible if you are clever enough, but there's no easy way to do it. In any case, debugging at the chip level is usually a last resort and you would usually be far more interested in what's happening at the source code level i.e. variable values rather than register values. However there's no easy way to do that either, and the easiest and most practical approach to debugging is simply to have your sketch print out debug/trace messages to tell you what's happening.

Here's a code snippet from an AVR monitor program I wrote ages ago

    case  CMD_PC:
       address = (byte*)(SPL + (SPH << 8));
       address += 35; // skip 33 preamble bytes, 
                      // +1 to allow for SP post decrement
                      // +1 because it seems to work ??

This puts the PC into variable "address" but relied on intimate knowledge of the stack frame size (which I controlled by using ISR_NAKED for the ISR and pushing all the regs myself so I knew exactly where they where on the stack).

In the Arduino world there really is no provision for such low-level debugging, in that regard I prefer working with platforms that allow a real debugger (like LPCXpresso) . Another option may be to use Atmel Studio with the Visual Micro plugin, it does have an optional debugger but I can't remember if it allows such low-level debugging.


Rob