Debugwire blocks ISP

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I built a proto with a tiny2313, programmed it with ISP, then enabled debugwire. At this point I got stuck: AVR Studio tells me to use ISP when I am using debugwire, and debugwire when using ISP.

After some search I found it was a well known problem. I tested the solutions there: put a pullup on RST, connected extra ground wire, checked RST on scope, all with both AVRICE mkII, and Dragon. No success at all, the device is dead-locked. It looks like the only known fix is parallel programming - which is not easy with smd. All this trouble is just because I set DWEN active.

Having a deadline I finally replaced 2313 and went on without debugwire. But I am still curious, how to use it?

I'd really appreciate any experiences here.

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

I have had similar issues (coincidentally also with 2313's). When trying to debug it said "must be in DW mode" and when trying to program/view fuses it said "must be in SPI mode" indicating that it was actually in a third mode that is unrecoverable with DW/SPI.

This problem can be caused by several factors and most commonly by extranneous circuitry hanging on the DW/SPI lines. The parts will go into this "Twilight Zone" (one Atmel engineer's terminology) and only HV erasing will revive them.

In my case they were MLFs with 0.2mm wide pins! I can barely see these parts let alone make connections to them.

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

You use DW by doing a "build and run" after you have your code assembling/compiling correctly and follow the prompts EXACTLY. You can also use the programmer to enable DW but it's one way only. ISP is disabled once you enter DW.

Do your testing debugging by "build and run" untill you are all done.

When finished debugging you MUST EXIT DW from within a debug session just like the manual says. This will restore normal ISP.

edit and of course no caps on the reset line and the pullup resistor, if used, should be 10K minimum. (even though I have always used 4K7 without problems)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Reset line is completely free and connected directly to the ISP header.

Which manual should I check? Atmel ATtiny2313/V doesn't seem to explain it. I followed the JTAGICE mkII user guide: created an AvrStudio gcc project, wrote a piece of code, and built. However neither I could load it with ISP nor I could start debugging (ISP says DWEN is enabled, StartDebugging says DWEN is not enabled).

It seems others can do it, so I keep trying :) . as I said, this very board is smd, which makes it a bit harder. I am not under a pressure with it, I just always thought DW was a bright idea, so I'd like figure out how to use it. The best move will probably be to source a DIP version and test it in an STK500.

Thanks for your comments!

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

Never touch the DWEN fuse.

1. Connect the JTAGICE-2 via all the ISP lines.
2. Build your Studio project with F7
3. Start Debugging by pressing ctrl-F7
4. Follow the prompts to enter debugWire mode.
5. Debug your code.
6. Disable debugWire via the Debug menu.

During a compile-debug session you do steps 12345, 235, 235, 235, ... 2356

Make sure that you finish with step (6).

DebugWire works very well.

David.

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

Quote:
ISP says DWEN is enabled, StartDebugging says DWEN is not enabled
But if DWEN is enabled then ISP cannot tell you anything.

The manual you would want to look up is the manual for the tool you use like the JTAG Mk2 or the Dragon. The latest version is built into Studio as you may be aware. ie JTAGICE mkII User Guide "Connecting to a debugWIRE target".

Remember that when you go into and out of DW you MUST have the full 6 pin ISP header connected and not just the reset line.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Thanks all. I'll give it a go.

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

js wrote:
and of course no caps on the reset line and the pullup resistor, if used, should be 10K minimum. (even though I have always used 4K7 without problems)

The datasheet actually says to "disconnect" any caps when running debugWIRE, and it left me scratching my head. How would you switch them in and out? Do you just leave them out of your reset circuit? What does your circuit look like? I'm working on a new design (ATMega328) and dealing with this same issue. I was going to use a 4.7K pullup in parallel with a reverse-biased diode, plus a cap to ground. Now everything except the pullup looks suspicious. Thanks for your help

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

Just leave out the cap during debug, no diode required. OK to put cap back in after you finish debug ie production units.

In theory you don't need anything on the reset line....but as I said before I have used 4K7 pullup for many years and a 100nF cap to ground for field boards.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly