I just got an AVR Dragon, and I'm messing with debugWire.
I'm using Atmel Studio 7 and an atmega328. All seems to be working well, although the hassle of switching between debugwire and programming mode is a bit annoying. My understanding is that that is a common complaint, so I won't go on about that.
Anyway, here is the simple code snippet in question. I put an 'X' where debugger breakpoints are.
While(1)
{
X PORTB = 0b00000001;
_delay_ms(500);
X PORTB = 0b00000000;
_delay_ms(500):
X PORTB = 0b00000001;
_delay_ms(500);
X PORTB = 0b00000000;
_delay_ms(500):
}
Ok, here's what happens when I run the debugger. On the first pass through the while loop, execution stops at every breakpoint, the LED attached to the relevant pin does what I expect, and the IO port view window tells me what I expect. All is good.
But on every subsequent pass through the loop, the first breakpoint is ignored, and execution stops at the second one. It is only this one breakpoint that gets skipped. I made sure it was a generic, conditionless breakpoint like the others. In my first version, the redundant second half of the routine didn't exist. I added that to see if the behaviour had something to do with the code. The second half of the routine's breakpoints work as expected.
So why would a breakpoint only work on the first pass through a loop?
The only parameter I'm not super comfortable with is the clock speed I set the Dragon's interface to run at. I know it's supposed to be less than 1/4 of the target's clock speed, but that leaves allot of possibilities. Is there a more specific rule of thumb here? Is this possibly relevant to my issue? I'm running on the MCU's internal 8 mghtz clock btw.
Finally, is there a way in atmel studio with debugWire to execute the code one statement at a time with a keypress, regardless of breakpoints?