1

I am writing some firmware for the atmega16u2 and have noticed that the usb device hardware does not work correctly if debugwire is enabled. The usb device does not enumerate. Disabling debugwire immediately causes the usb device hardware to work as expected (enumerates correctly). Debugwire debuggin works correctly except for the functionality of the usb device hardware.

Is there a way to allow/make the usb device to work correctly with debugwire?

uglyoldbob
  • 162
  • 8

1 Answers1

1

Unfortunately no. Debug wire messes with the way a processor operates allowing the core to be stopped. While the core is stopped variables can be read out and written in. USB requires an always "on" type connection with stringent timing requirements. When the core stops so does the USB peripheral. That breaks both timing and always-on requirements. The host then rejects the device.

I'm willing to bet if you run the processor in debug wire mode and no break points it would run just fine. Then when you hit pause the device would disconnect from USB.

Debug using UART and capture the events using an FTDI cable.

vini_i
  • 7,048
  • 3
  • 32
  • 49