# DebugWIRE

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/DebugWIRE
> Markdown URL: https://mediated.wiki/source/DebugWIRE.md
> Source: https://en.wikipedia.org/wiki/DebugWIRE
> Source revision: 1353547746
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Lowercase title}}
{{short description|Communication protocol for on-chip debugging}}
'''debugWIRE''' is a serial communications protocol, designed by [Atmel](/source/Atmel). It is used for [on-chip debugging](/source/on-chip_debugging) of [AVR microcontrollers](/source/AVR_microcontrollers).

== Protocol ==
debugWIRE is designed as a simpler alternative to [JTAG](/source/JTAG), aimed at [microcontrollers](/source/microcontrollers) (MCUs) with limited resources. It is supported by the classic [ATtiny](/source/ATtiny) and some smaller ATmega MCUs, such as the [ATmega328](/source/ATmega328). By using debugWIRE one has full read and write access to all memory and full control over the execution flow. It supports single-step, run-to-cursor, step-out, and software break instructions. A [breakpoint](/source/breakpoint) (run-to-cursor) will be set by reprogramming the ''BREAK''<ref>[https://ww1.microchip.com/downloads/en/DeviceDoc/AVR-InstructionSet-Manual-DS40002198.pdf AVR Instruction Set Manual]</ref> [opcode](/source/opcode) into the [flash memory](/source/flash_memory) of the MCU. Care must be taken due to the limited number of guaranteed write cycles (10000) of the device.<ref>[http://ww1.microchip.com/downloads/en/DeviceDoc/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet-Summary.pdf ATtiny25-ATtiny45-ATtiny85_Datasheet-Summary.pdf ]</ref> To avoid reprogramming the flash use single-step or run-to-cursor which will use the single hardware breakpoint.

== Programmer models ==
debugWIRE is supported by all modern hardware debuggers from [Microchip](/source/Microchip_Technology). This includes Atmel-ICE,<ref>[https://www.microchip.com/en-us/development-tool/ATATMEL-ICE Atmel-ICE]</ref> JTAGICE3, AVR Dragon, JTAGICE mkII, and SNAP.<ref>[http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB%20Snap%20In-Circuit%20Debugger%20IS%20DS50002787A.pdf MPLAB SNAP In-Circuit Debugger]</ref> It is also possible to build a cheap debugWIRE hardware debugger<ref>[https://hinterm-ziel.de/index.php/2022/01/13/a-debugwire-hardware-debugger-for-less-than-10-e/ A debugWIRE Hardware Debugger for Less Than 10 €]</ref> based on an open-source [Arduino](/source/Arduino) sketch,<ref>[https://github.com/felias-fogg/dw-link dw-link---An Arduino-based debugWIRE debugger]</ref> using a general USB-Serial adaptor or ATtiny85 board,<ref>[https://github.com/dcwbrown/dwire-debug dwire-debug]</ref> or a CH552 microcontroller.<ref>[https://github.com/DeqingSun/unoDebugTestPackage/tree/main Arduino Board Package to Debug Uno/ATmega328P with CH552 debugger in Arduino IDE 2.0.0]</ref>

== debugWIRE specifications ==
debugWIRE is activated by setting (programming to zero) of the fuse DWEN (debugWIRE enable), normally located in the high fuse byte. After this action the /RESET pin function isn't available anymore and the ISP protocol cannot be used.
debugWIRE can be disabled with any of the mentioned debuggers by sending a special reset command that disables temporarily the debugWIRE function and reenables /RESET and also ISP until next power down cycle. debugWIRE is not able to program the fuses of a device.
If you want to disable debugWIRE permanently you have to disable the function temporarily and program the fuse using the now available ISP function.<ref>[https://www.mikrocontroller.net/articles/DebugWIRE debugWIRE article (in German)]</ref>
debugWIRE uses a 1 wire [open drain](/source/open_drain) serial connection. The default baud rate used is MCU clock/128. Sending a [BREAK](/source/Universal_asynchronous_receiver%2Ftransmitter) will return 0x55 which is used to detect the baud rate. The MCU will return a BREAK when a breakpoint is hit or a collision is detected on the debugWIRE connection. 0x06 is used to disable debugWIRE and reenable /RESET and ISP, 0x07 resets the MCU, 0xF0 returns the PC, 0xF3 the debugWIRE ID.<ref>[http://www.ruemohr.org/docs/debugwire.html The debugWIRE protocol]</ref><ref>[https://github.com/dcwbrown/dwire-debug Simple stand-alone debugWIRE debugger (open source)]</ref><ref>{{cite web|url=https://www.youtube.com/watch?v=4sMhRCOQCC0|title=Advanced Debugging with Arduino Boards|last=Microchip Makes|date=25 November 2015|publisher=|via=YouTube}}</ref>

== References ==
{{Reflist}}

{{Microcontrollers}}

Category:Serial buses
Category:Debugging

---
Adapted from the Wikipedia article [DebugWIRE](https://en.wikipedia.org/wiki/DebugWIRE) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/DebugWIRE?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
