Dragon DebugWire to mega168 not working

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

So as not to resurrect threads, I have similar problem to and have tried suggestions from this thread https://www.avrfreaks.net/index.p...

Basically, I can get into debug mode, but after a few steps, the debugger stops stepping, and it looks like my stack got munched.
I followed suggestions from the thread, and used a shorter cable, tried using 8mhz and then 125Khs internal clock - no joy, same symptoms - I can step into main about 3 lines, but once in a function, it's like the debugger refuses to step.
I'm just a hobbyist, this Dragon is like the max I can spend - should I try getting an atmega324 chip?

Besides it not doing much debugging, just downloading, I have managed to get the Dragon to "loose" comms by changing the ISP clock a few times, in order to try different setting, and had to reboot the Dragon.
I got a Dragon specifically to debug my programs which are becoming less trivial. Does DebugWire on your Dragon work with atmega168 or 324?

Conrad Braam - www.softcircuitry.blogspot.com - www.plcsimulator.org
Always start off poorly, that way when you finally figure it out, you can get a few surprise hits in.

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

It should work just fine.

The RESET line should not have any capacitors on it.
The pull-up resistor must be >= 10k.
The wires from the Dragon should be < 20cm or so.

Yes. The JTAG devices (like the mega324) will be easier / better for debugging than a debugWire chip (like mega328). You have several hardware breakpoints with JTAG.

All the same, dW works very well. You normally step through some code or run to a known breakpoint.

Do you have proper soldered joints?
Do you have 100nF decoupling capacitors close to the VCC,GND pins?

David.

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

More background and data:
I'm running on a breadboard, which will add about 10pf when least wanted, normally I use external clock source @16Mhz. Have tried using internal 8Mhz and 125Khz clock, and upload works, but not debugging (but without removing my external 16Mhz clock chippery - gaagh, will have to try remove it if it's interfering).
Before the Dragon, I always used a homemade usb ISP, and was hoping for a rudimentary yet reliable debugger. I have used a JTAG at work before on a PIC with DSP, so I know to expect a bit of forethought to debugging on a target.

When I go into DW mode (because the atmega168 has exclusive modes, either SPI or debugWIRE), AVRSudio starts my debug session by uploading to the target each time, that bit works.

Assumptions time?
1. In DebugWIRE mode, the binary gets uploaded over DW? Why can't I just use DW to do uploads manually?
2. Does the ISP speed selected in AVRStudio also set the debugWIRE speed, since all indications are it does?

I know that 73.6% of people using debugWIRE via a Dragon never ever read this thread because it just works for them, thanks to all those who do stop by, I'd love to join you.

Conrad Braam - www.softcircuitry.blogspot.com - www.plcsimulator.org
Always start off poorly, that way when you finally figure it out, you can get a few surprise hits in.

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

Be realistic. Breadboards may be 'easy' but they are hardly good wiring practice!

All the same, I have mounted a 6-way ISP header on a breadboard and used a Dragon to debugWire via a 15cm ribbon quite successfully.

Yes. You can upload flash when in debugWire mode. Look at avrdude. However Studio does not give you that option, nor does avrdragon.exe.

No, I am not too sure how dW works. I would guess that the comms speed is related to the AVR clock, but you do not seem to get a user option to set any speed. So I would just be honest. Tell Studio what your clock is. Whether it uses it or not is up to Studio. (projects and ISP seem to have no relationship in AS4)

David.

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

Quote:
Why can't I just use DW to do uploads manually?
Why would you want to do that? DW is meant for debugging only so you keep the chip in that mode until you finish then you turn off DW during the last debug session to restore ISP.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Thanks John
Going in and out of DW mode is a bit of an effort involving pulling out wires, and writing fuses, I suppose I'm reticent to be writing fuses too often too, but I have been switching mode a lot because I'm not debugging, I'm trying to fix my hardware:-) I'm still getting used to AVRStudio too.

DebugWIRE appears to be working for me in dissasembly view, but not in C code view, maybe something to do with the _delay_ms implementation macro in the AVRStudio version of toolchain (I'm using it to blink a LED as a sanity test).

Since DW seems to be working (in assembly mode at least) I can try and debug my code, and will have to share how I got it working smoothly with everyone when I figure it out fully and read the AVRStudio guides on creating new project, they have some interresting include files :-] ,I need to learn all the AVR Studio project setting tweaks too.

Conrad Braam - www.softcircuitry.blogspot.com - www.plcsimulator.org
Always start off poorly, that way when you finally figure it out, you can get a few surprise hits in.

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

Quote:
Going in and out of DW mode is a bit of an effort involving pulling out wires, and writing fuses,
HUH? Why? :) You can leave the full 6 wire ISP connector plugged in at all times.

And you can definetely debug your hardware in DW mode, in fact I don't start any debugging (apart from checking power) without having the chip in DW or JTAG if the chip has JTAG.

You can turn port bits on and off manually in DW mode, great for hardware debugging.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly