Author Topic: debugWire question  (Read 4921 times)

0 Members and 3 Guests are viewing this topic.

Offline Dan MoosTopic starter

  • Frequent Contributor
  • **
  • Posts: 359
  • Country: us
debugWire question
« on: September 19, 2016, 02:01:58 am »
Using debugWire  with an AVR Dragon, an atmega328P,  and AVR Studio 7.

Here's a dumb question. When debugging with debugWire, in the register window, am I seeing what the actual hardware registers are doing, or just what the code should make them. I assume its the first, and that its an actual peek inside the mcu, but I just want to be sure. In circuit debugging wouldn't make much sense to me if it were any other way, but I been wrong about such simple things before.

 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12498
  • Country: us
    • Personal site
Re: debugWire question
« Reply #1 on: September 19, 2016, 03:50:30 am »
You see the actual register contents.
Alex
 
The following users thanked this post: Dan Moos

Offline Dan MoosTopic starter

  • Frequent Contributor
  • **
  • Posts: 359
  • Country: us
Re: debugWire question
« Reply #2 on: September 19, 2016, 03:52:58 am »
Thanks. It seemed silly that it would be otherwise.
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3653
  • Country: us
  • If you want more money, be more valuable.
Re: debugWire question
« Reply #3 on: September 19, 2016, 05:13:19 am »
FWIW, I wondered the same thing. Although it is logical that it would report the actual register/variable values - I was not sure the system had access to them.

Thanks for asking. Do you have any suggestions for setting up and using debugWire? I am wasting a lot of time by not using it.
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12498
  • Country: us
    • Personal site
Re: debugWire question
« Reply #4 on: September 19, 2016, 05:15:31 am »
Do you have any suggestions for setting up and using debugWire?
There is not much to set up. Just enable DWEN fuse bit and select debugWire as a debug/programming interface.
Alex
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3653
  • Country: us
  • If you want more money, be more valuable.
Re: debugWire question
« Reply #5 on: September 19, 2016, 05:18:39 am »
Uses the SPI interface?

Does it work in realtime or do I need to set breakpoints? My first hope would be to see what everything looks like if the MCU locks up - stuck in a loop, overrun an array, whatever bad things I do.
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12498
  • Country: us
    • Personal site
Re: debugWire question
« Reply #6 on: September 19, 2016, 05:22:15 am »
Uses the SPI interface?
No, it actually uses RESET pin in a really weird way, and you have to stop debug session by properly exiting it. If you disconnect the target, then reset pin will be stuck in that mode, and you will have to do some dancing to get it back.

Does it work in realtime or do I need to set breakpoints? My first hope would be to see what everything looks like if the MCU locks up - stuck in a loop, overrun an array, whatever bad things I do.
It works like any other debugger. You can run, pause execution, do single stepping, etc.

Here is some text about that http://www.atmel.com/webdoc/avrdragon/avrdragon.dw_description.html

And I guess you don't need to set it manually:
Quote
It is HIGHLY ADVISED to simply let Atmel Studio handle setting and clearing of the DWEN
Just select debugWire and hit Debug.
« Last Edit: September 19, 2016, 05:24:17 am by ataradov »
Alex
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3653
  • Country: us
  • If you want more money, be more valuable.
Re: debugWire question
« Reply #7 on: September 19, 2016, 05:35:03 am »
It works like any other debugger. You can run, pause execution, do single stepping, etc.

I have not used a debugger before, so this is all juicy info. Thank you. I guess one should ensure the target is attached reliably to not brick the chip or create a challenge to get it back to normal. I have an STK500 that I think can do high-voltage - would that be suitable to get back to normal if the debug wire session gets terminated improperly?
Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12498
  • Country: us
    • Personal site
Re: debugWire question
« Reply #8 on: September 19, 2016, 05:40:03 am »
I have not used a debugger before, so this is all juicy info.
dW is not the best debug protocol, so don't base your opinion on debuggers based on this.

I have an STK500 that I think can do high-voltage - would that be suitable to get back to normal if the debug wire session gets terminated improperly?
I think there is a way to recover even with low voltage.  If I'm not mistaken, you can't program though dW, so you need ISP for that. And if you stuck in dW mode, you lose ISP. To recover, you just need to start a new debug session without uploading the program, and exit this session right away, which will recover the fuse.
Alex
 

Online 2N3055

  • Super Contributor
  • ***
  • Posts: 8848
  • Country: hr
Re: debugWire question
« Reply #9 on: September 19, 2016, 05:53:20 am »
I think there is a way to recover even with low voltage.  If I'm not mistaken, you can't program though dW, so you need ISP for that. And if you stuck in dW mode, you lose ISP. To recover, you just need to start a new debug session without uploading the program, and exit this session right away, which will recover the fuse.


That is correct..

I agree it's a bit clunky, and slow, but it can be helpful at the times...

I would suggest that this topic really needs a good look in  the documentation... There are many details.. From how you implement the connection to other details..
"Just hard work is not enough - it must be applied sensibly."
Dr. Richard W. Hamming
 

Offline rx8pilot

  • Super Contributor
  • ***
  • Posts: 3653
  • Country: us
  • If you want more money, be more valuable.
Re: debugWire question
« Reply #10 on: September 19, 2016, 06:06:02 am »
If all the JTAG pins are used in the circuit, debugWire seems like the only option. Time to figure this out......

Sent from my horrible mobile....

Factory400 - the worlds smallest factory. https://www.youtube.com/c/Factory400
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2867
  • Country: us
Re: debugWire question
« Reply #11 on: September 20, 2016, 05:47:03 pm »
Uses the SPI interface?
No, it actually uses RESET pin in a really weird way, and you have to stop debug session by properly exiting it. If you disconnect the target, then reset pin will be stuck in that mode, and you will have to do some dancing to get it back.
  You should be able to leave parts in dW mode and come back to them later without (much) trouble.  I've been doing this these past couple of days with a couple of little gadgets where I only wanted to bring out a 3-pin programming connection.

Uses the SPI interface?

Does it work in realtime or do I need to set breakpoints? My first hope would be to see what everything looks like if the MCU locks up - stuck in a loop, overrun an array, whatever bad things I do.

You can set breakpoints, or if the chip seems to have locked up you can do Debug->Break All which will show you exactly where the chip is in the program.  Just be aware that after optimization the actual program flow will be rather different from what the source code shows, and when stepping through the program may seem to jump around wildly.  Sometimes you may need to look at the assembly (which will reflect actual program flow) to understand what's going on.

PDI (used on AVR XMEGA parts) and SWD (ARM) are generally more robust and faster without taking up too many pins, but debugWire will certainly get the job done. 
 
The following users thanked this post: rx8pilot


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->