Author Topic: strange debugwire behaviour  (Read 1881 times)

0 Members and 1 Guest are viewing this topic.

Offline Dan MoosTopic starter

  • Frequent Contributor
  • **
  • Posts: 359
  • Country: us
strange debugwire behaviour
« on: September 22, 2016, 03:47:30 am »
My rig: atmega328p running on the internal 8mgHtz clock, AVR Dragon, Atmel Studio 7. Programming in C.

Cooking up an I2C library, mostly just for the experience.

For quite awhile, debugWire has worked well, but all of a sudden, out of the blue, its acting crazy.

The problem is that the debugger seems to be jumping all over the place. As I step through the code, it will follow things correctly for a couple instructions, and the all of a sudden be in a completely different function. Keep stepping, and it goes back to where it was. Step some more, and all of a sudden, it goes somewhere weird again. It even ends up in a function that has been written, but is never called. In other words, there should be no way to end up there.

If you run the debugger multiple times, it always follows the same weird jumps, so it isn't random. Also, from the way the TWI registers read, things are somewhat working, although its hard to say. Its almost like the code is running properly, but the debugger only stops every so often. Since all these functions get called multiple times in the code, the random stops give the appearance that things are running out of order, when in fact, they are are not, but rather the debugger just lets whole chunks of code run without stopping, even in single step mode. Break points are getting missed also.

could this be a clock issue? When you setup the AVR Dragon as an ISP, you have to pick a clock speed, but when you do debugWire, you don't. Does debugWire use the clock speed you chose for ISP? I have the I2C stuff running at 100kHtz, so does that mean I need a slow running debugger? The relationship if any between the ISP clock speed, and the speed of the debugWire interface is a point of confusion to me.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12498
  • Country: us
    • Personal site
Re: strange debugwire behaviour
« Reply #1 on: September 22, 2016, 04:00:10 am »
Have you changed optimization options recently?

Go to disassembly view and do single stepping there, if it also jumps from instructions that are not branches, then something is really wrong.
Alex
 

Offline Dan MoosTopic starter

  • Frequent Contributor
  • **
  • Posts: 359
  • Country: us
Re: strange debugwire behaviour
« Reply #2 on: September 22, 2016, 04:12:41 am »
Never mind, as usual, I spend hours on a problem, finally decide to ask for help, only to solve it within minutes of posting.

One misplaced semi colon in he code cause much mayhem. Whats more, I didn't consider that every time I rebuilt my solution, the offending file wasn't getting looked at because it was part of a library I'd made.

I'm good now. Many thanks!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->