1
\$\begingroup\$

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?

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ I found that even with no breakpoints, usb enumeration would not work. \$\endgroup\$ – uglyoldbob May 30 at 18:51
  • \$\begingroup\$ @uglyoldbob Not terribly surprising, but without break points debug wire is fairly useless anyway. \$\endgroup\$ – vini_i May 30 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.