AVR/Arduino Hardware Debugger on the Cheap (revisited)

2/17/2018 Update: I've removed the code links at the bottom of this page except for the link to the DebugWireTest, as new code is now available.  For the latest code, see my most recent article AVR/Arduino Hardware Debugger on the Cheap (part 3) 

This page presents updated information and code for my project "AVR/Arduino Hardware Debugger on the Cheap".  Since publishing that article (and its companion video), I've made several improvements and enhancements to the code.  However, if you're interested in using my new code, you should still review my original article, as there is a lot of information there which I will not repeat here.

New Features and Changes

I've revised and renamed my original Arduino sketch to reflect its new capability.  The new sketch, which you can download below, is now named DebugWireDebuggerProgrammer because it now includes the ISP programming abilities of the ArduinoISP sketch.  This means you can use my new code to both upload code to a target device as well as debug code running on it.  Note: if you have not done so already you'll need to also download and install my OnePinSerial library and the DebugWireTest sketch for ATTiny85 (both also available below, or on my original page.)  I'm also working on a demo video that will show all the steps you need to follow to compile code for the ATTiny85 (or some other target) and then upload it.  You can subscribe to my YouTube Channel of you to want to be notified when I release a new video.

Because the ArduinoISP sketch requires you to install a 10uF capacitor from the Arduino's RESET line to Ground in order to use it, you'll need to use a modified version of the test circuit to both program and debug code.  This circuit (shown below) adds a SPDT switch that let's you toggle between Program (upload) mode and Debug mode:

Click for Larger View

Click for Larger View

When the switch is in the "Program" position, you can compile and upload code to the ATTiny85 (or other target device) and, when in the Debug position, you can open the Arduino IDE's "Serial Monitor" window (set to 115200 baud) to invoke the debugger.  Note: in addition to connecting the 10 uFd capacitor to the Arduino's RESET line when switched to Program mode, pin D8 is used to detect the setting of the switch and change the baud rate to/from 115200 for Debug mode or 19200 for Program mode.

Important: as mentioned in my original article, you cannot use Program mode as long as the DWEN fuse is enabled and you'll be unable to debug code when it is not enabled.  However, you can use a special feature in Debug mode to flip this fuse back and forth, as needed: 

If DWEN Fuse is enabled and you want to Upload new code, follow these steps:

If DWEN Fuse is not enabled and you want to Debug your code, follow these steps:

If DWEN Fuse is already enabled and you want to debug some more, follow these steps:

Stay Tuned!

I'm still making improvements to the DebugWireDebuggerProgrammer sketch, so stay tuned for future develops by subscribing to my YouTube channel, or checking here at "Wayne's Tinkering Page" from time to time.  Some of things that are hopefully coming in the near future, are:

Update - For the latest code, see my most recent article AVR/Arduino Hardware Debugger on the Cheap (part 3)