Advice on debugging atmega

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

Background to question:
As a hobbyist with a lot of C/C++ experience and a day-job involving C#, I picked up an atmega8 3 years ago and got hacking the hard way with a parallel port cable. I started buying the 168 (for more flash) after a while, and have just switched from my home-brewed ISP to an STK500. But after 3 years of debugging via LEDs or a serial port, I need to step up to the next level in debugging power.
I am thinking getting atmega32-16pu as a direct upgrade to the atmega168 experience? - I want to be able to use the JTAG from my STK500, and for that purpose installed Avr Studio for the first time, and am considering which micro will work without expense of any DEV-board, since I even managed to dodge Arduinos thus far. I know a Jtag will not let me debug peripherals, I just want to peek at variables and the stack and even assembly code. I'm not looking for professional or well considered answers - since I am just playing/hobby.

Q: What chip is debuggable, but not too complex to just drop into a breadboard?

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:
I am thinking getting atmega32-16pu as a direct upgrade to the atmega168 experience?
I would not call a mega32 an upgrade to a mega168, the mega32 is a fairly old chip. There is a mega328 that is a direct upgrade. There is also a mega324 that is a more modern version of a mega32
Quote:
I want to be able to use the JTAG from my STK500
The STK500 is not capable of JTAG, no matter what chip you have.
Quote:
I know a Jtag will not let me debug peripherals
Why would JTAG not let you debug peripherals?
Quote:
What chip is debuggable, but not too complex to just drop into a breadboard?
The one you already have, the mega168. It is debugable through DebugWire. You need either a Dragon, a JTAG!CE MkII, or a JTAGEICE MkIII.

Regards,
Steve A.

The Board helps those that help themselves.

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

Why mess about? Buy a Mega1284P and be done with it. Buy a Dragon too, while you're at it :)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

Thanks Koshchi and gregsmithcts, I shall go and get a Dragon, I suspected the STK500 was not going to give me debug capability and should have kept the money over for a Dragon, which is only slightly more expensive. One barely used STK500 will be on ebay shortly I suppose :-)

Quote:

Why would JTAG not let you debug peripherals?

Since a JTAG does not actually stop the chip clock, hardware interrupts ADC and SPI still keep running, debugging code around them requires a bit more homework, I believe.

Quote:

The one you already have, the mega168. It is debugable through DebugWire. You need either a Dragon, a JTAG!CE MkII, or a JTAGEICE MkIII

Yay - no need to learn a new pinout or buy stuff I don't really need - big bonus ,since I have built a good few breadboard "shields" to use with the atmega168, and the 16k is plenty of space. Anything bigger than 16K is not a weekend warrior project anymore, or a good reason to learn how to build and drive a new peripheral; a fun activity in it'self.

Thanks for all the community work here, I hope my thread adds a little value.

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:

One barely used STK500 will be on ebay shortly I suppose

BAD idea. I'd have said the STK500 *and* a Dragon make a cracking little dev. environment. It would be madness to dispose of an STK500 if you are lucky enough to have one.
Quote:

Since a JTAG does not actually stop the chip clock, hardware interrupts ADC and SPI still keep running, debugging code around them requires a bit more homework, I believe.

Time to do a bit more reading.
Quote:

Yay - no need to learn a new pinout or buy stuff I don't really need - big bonus ,since I have built a good few breadboard "shields" to use with the atmega168, and the 16k is plenty of space.

Yes and no - for "serious" debugging I'd use a JTAG not a dW chip - there's to many reports of problems with getting into/out of dW and it is just more complex to use - it also wears the flash out as it reprograms a page every time you set a breakpoint. With JTAG you make one 10 pin connection to the chip and never change it. You get JTAG in the 40 pin devices. As already mentioned the "modern" 164P/324P/644P/1284P "family" is a great place to start with 40 pin (and JTAG) and of those the 1284P is unusual in that it's the only AVR8 with 16K of SRAM. If you can think of an app that needs more resources than the 1284P delivers it's time to move on to "bigger" processors!

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

I have encountered with several problems when I connected JTAG ICE MKII to Atmega 168 through debugwire.

1. I connect JTAG ICE MKII to my computer through USB port.
2. I am using AVR STudio v4.16
3. My reset line is clear(there is no capacitor at the reset pin. I have tried 10 kohm and 47 kohm pull-up resistors)
4. My debugwire is enabled. Altough debugwire is enabled, sometimes MKII cannot connect to microcontroller. When I try the same thing for the second or the third time it connects. This situation is completely random.
5. Then I can download the program to board and run it. But when I try to reset the program AVR studio becomes locked and after a while AVR STudio gives an error “Timed out while waiting response from emulator. Please check cables and emulator power.”. I have checked all cables, several times, and I have changed all cables also the problem continues. Then AVR studio says “Platform has been disconnected, leaving debug mode” then finally it exits debug mode.
6. I have checked this with several microcontrollers from different types. Ihave used ATmega168A, Atmega168P, Atmega168PA. But problem continues for each of them. Only for one board I have no problem. But there is no difference between this good board with the other boards.

Could you suggest me some method to overcome the problem?

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

I would guess that you have a wire broken (or intermittent) in your squid cable.

The fact that you problem appears with different chips suggest that it is a wiring and not an individual chip problem.

10k or 47k pull-up should both be fine on the /RESET line.

David.

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

Quote:
Only for one board I have no problem.
Quote:
But there is no difference between this good board with the other boards.

If this is true *all* the time, then contrary to your claim, there *is* a difference.
debugWire is reliable when used as instructed by the documentation. If you are not expecting what happens, to happen, you can mistakenly be led to believe that something has gone wrong.
If a single board *always* works, and the others *sometimes* work, then the conclusion is clear. How many cables have you tried, by the way?

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

apologies :)

Last Edited: Wed. Jul 20, 2011 - 01:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please use [code] tags.
Please do not hijack other people's threads.

Moderator.

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

Are the links inside the database going corrupt?
I just replied to another post and get the error 'Sorry you can only reply to posts in this forum'.
Now Cliff is stating something about using code tags and hijacking in what appears to be a meaningless context?

EDIT: never mind, I see whats happened now :?

[he went that way... https://www.avrfreaks.net/index.p... ]

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

This may be an explanable case, but I have been seeing some strange things happening with the database. I'm convinced it got FUPed over the weekend.

"I may make you feel but I can't make you think" - Jethro Tull - Thick As A Brick

"void transmigratus(void) {transmigratus();} // recursio infinitus" - larryvc

"It's much more practical to rely on the processing powers of the real debugger, i.e. the one between the keyboard and chair." - JW wek3

"When you arise in the morning think of what a privilege it is to be alive: to breathe, to think, to enjoy, to love." -  Marcus Aurelius