ATmega328PB-fails to enter debug and then won't program either

Go To Last Post
6 posts / 0 new
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Using ATmega328PB-mini Xplained board and Atmel Studio 7 (Version 7.0.1645)

I have been programming part successfully for past week, now attempting to user debugger.


Attempted to enter debug mode: got the "do you want to use SPI to enable the DWEN fuse?" message.

Clicked Yes.

Now I get "Failed to enable DW. Failed to enter programming mode.Error status received: Got 0xC0. Expected 0x00."

Now if I try to program part I get same "Failed to enter programming mode" error.

Maybe it is stuck in programming mode? Debug->Stop debugging is greyed out.

Cycle power? Tried multiple times, no help.

If I try Debug->Start Debugging and Break or Debug->Start without Debugging, I get "Failed to launch debug session with debugWire."

Then asks that the reset line be checked. This Xplained board has no jumpers on it. The schematic shows a 3.3K pullup on RESET.

Do I need to unsolder this resistor?

Am I doing something else wrong?





Last Edited: Tue. Nov 28, 2017 - 04:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


There seem to be an endless number of threads about folks getting stuck in debug mode, which appears to be what is happening to me.


In my case, when I attempt to enter debug mode, the DWEN is getting enabled, but I get the following error: "Setting debugWire fuse seems to have failed. Check your clock and fuse settings".

At this point the debugger is not running so I can't "Disable debugWire and Close" (it is greyed out).

Nor can I program the part because the DWEN fuse is actually enabled.


Someone on the forum provided this backdoor way of disabling DWEN-

Tools->Command prompt.

atprogram -i debugwire -d atmega328pb dwdisable


Tools->Device Programming->Fuses->unselect HIGH.DWEN and program.


This clears the errant DWEN and restores the device so that it can be programmed.


Next I need to find out why debug is not working, but the larger question that this raises in my mind is how safe is this part to use in a professional application where software upgrade are likely?


I can't imagine needing to rev the software in this part in system and finding the part has been bricked in the process.  Disassembling a $50k piece of customer owned equipment in order to unsolder and replace a $1.00 uC?


Do most folks always make sure that high voltage programming is available on their target hardware or is everyone assuming that suitable "backdoors" can always be found?


And related -> The prescribed method of entering & exiting debug (when it works) seems to require a power cycling. How do folks debug on target hardware that is not easy to just plug and unplug?

Last Edited: Mon. Nov 27, 2017 - 07:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Further update: (I tried to steer this discussion into the "Evaluation and development kits" forum where it belongs, didn't work out).


Summarizing: I have ATmega328pb mini eval board connected with USB to PC running Atmel Studio 7 (7.0.1645).


I can program the part, but debug does not launch.


Debug->Start Debugging and Break

I get the expected "Failed to launch ... Do you want to use SPI to enable the DWEN fuse?"

I say "Yes"


"Setting debugWire fuse seems to have failed. Check your clock and fuse settings."


BTW this does set the DWEN fuse, and "bricks" the part ("Disable debugWire and Close" is greyed out since debug session never got started, and can't program part because DWEN is set).

But I have learned the atprogram method of clearing DWEN (thanks to this forum).


I have verified 16MHz clock (programmed timer to flash light once per sec from 16MHz clock).

I have verified all fuses are set to the correct values per "AT08401 Getting started with ATmega328pb"

Extended 0xFE

HIGH        0x9F

LOW        0xE0


I noticed that there is a 3.3K pullup on the Reset line on this kit. Changed it to 20k (did not help either way).

I tried several different new USB cables.

Tried starting from fresh project:

     File->New->Project->GCC C Static Library Project->ATmega328PB->and just kept the while (1) in main (void).


I also tried going to a different PC and starting from scratch. Downloaded latest Atmel Studio 7. Sadly same results.


I suspected the first PC because the install was not clean. The installer failed, (System validation error), indicating that I needed specific, quite old, Windows upgrade and provided a link to the Microsoft page where it is located. However, according to Microsoft, that upgrade was not applicable to my system. It had been rolled into a more recent upgrade which was present.

I did a C:\sfc /scannow and verified that Windows 7 had no integrity violations.

Eventually I came across the hack for bypassing the "System validation error" and installed the software.


On the new PC the web install went without a hitch, but sadly, debug still behaves the same.


I can't imagine what else I could be doing wrong.


Does this work for anyone else?

Last Edited: Tue. Nov 28, 2017 - 04:32 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Moved to "In-System Debuggers and Programmers"

John Samperi

Ampertronics Pty. Ltd.

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried debugwire debugging and isp programming on my 328PB Xplained Mini.


Windows 10. Atmel Studio 7.0.1645.


I had no problems.


Fuses:  Ext:  FE

             Hi :  D7

            LOW: E0


Changed to debugwire:   Project  -> Tools


Start Debug session:   Debug ->  Start Debugging and break.   (got the Launch Failed message, selected YES) (stepped through a few instructions)


Exit Debug:  Debug -> Stop Debugging.


Changed to ISP :  Project- > Tools.


Try to program with ISP:    Tools -> Device programming.  (Got Error message; Failed to enter programming mode.


Changed back to Debugwire:  Project ->Tools


Start Debug Session:   Debug -> Start Debugging and Break.  (didn't get Launch Failed message.   Now could step trough instructions).


Exit Debug:  Debug -> Disable Debugwire and close.


Switch to ISP mode:  Project -> Tools


Program the board with ISP:   No problem, read fuses, program.


Switch to Debugwire:  Project -> Tools


Program the board:  Debug -> Start without Debugging.


Start Debug session:   Debug ->  Start Debugging and break.   (got the Launch Failed message, selected YES) (stepped through a few instructions)


I have no problem.


Note:  I never unplug the USB cable from the computer or the 328PB XPLD mini








Last Edited: Tue. Nov 28, 2017 - 09:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Windows 10


In Studio 7.0.1645


Select ATmega328PB Xplained Mini - 4257 tab


In Project select XplainedMini328PB Properties


In Selected debugger/programmer select - mEDBG-ATML2523030200004275 (device ID may vary) Interface debugWIRE


Resolves "Atmel Studio 7 Failed to launch debug session with debugWIRE error" 

Dr. Veese