Atmel Studio 7 executes the previous instruction instead of the current one

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

Hi guys it's hard to describe my problem so I attach several screenshots

On the first screenshot everything is fine if i press 'step into' button I get into the function. It's ok 

 

if i execute code to the next breakpoints and press ''step into'' button i get to the next breakpoint without getting into the function 'SPIWriteReg'

 

And if i press 'step into' once again on the "temp = 0xf0;"  i get into the previous function! and temp doesn't change value.

'temp' will change its value when i execute next line here

 

And in all the following code the previous line will be execute instead current one.

I turned off all optimizations. How to fix this?

 

upd

mcu Xmega128A1

jtagice mk2

AtmeStudio 7.0.1417

Last Edited: Wed. May 31, 2017 - 11:31 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Probably down to optimisation ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried different configurations, now its -O0

 

Last Edited: Wed. May 31, 2017 - 12:40 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Switch to the mixed C+asm view and step it an opcode at a time - that will give a much clearer picture of the path of execution.

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

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

That source is not in the right place compared to the code. For example you have a call to SPIWriteReg(0x0B) but you see the LDI R22, 0x0B and RCALL about 10 opcodes later. Similarly there is a SPIWriteReg(0x23) but the LDI R22, 0x23 then RCALL about 10 opcodes later.

 

When source annotation and code get "out of step" like this it's often something to do with "funny line endings" in the source files.

 

Or this could simply be a bug in Studio.

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

clawson wrote:
When source annotation and code get "out of step" like this it's often something to do with "funny line endings" in the source files.

Or the source code on your machine does not match what's running in the target; eg, because you forgot to build and/or download it ...

 

Been there, done that!

 

That's why I always have a "hello" message that appears at startup with a build timestamp ...

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
...I always have a "hello" message that appears at startup with a build timestamp
+1yes

David (aka frog_jr)

Last Edited: Wed. May 31, 2017 - 03:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've tried my project on another PC and it works fine, I hope re-installation will help me

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

That certainly sounds like the source on the PC out of sync with what's burned in the target, then!

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wonder if the Norway boys are all on vacation? I'd expect to hear from them on this one.

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

Well, re-installation doesn't help. I make and  debug code in Atmel Studio so I'm sure that the target in mcu is right. I think the problem is in the debugger or drivers, sometimes i've got "Failed to connect: MPLABCOMM_INVALID_HANDLE" and it seems that debugging in my pc is working different than in another with the same mcu and the same debugger.

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

I have also a lot of Debugging problems with the Studio V7!!!

 

I have moved from V6.2 to Atmel Studio V7.0.1417 (Naggy 0.4.0 installed) and I'm getting crazy during Debugging with the new Studio (CPU: ATxmega256D3, Debugger Atmel-ICE).

When using STEP OVER or STEP INTO, the Debugger jumps in the source code like there was no debug-information at all.

It jumps back and forth without any sense and without any relation to my source code lines....???

I have tried optimizations O0, O1, Og. None of them is usable.

 

Currently I went back to V6.2 (with the same source code) and I have absolute NO PROBLEMS at all.

STEP OVER and STEP INTO do what I expect them to do.

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

Do not cross post.

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

This is happening to me. It has only started happening in the latest version of AS7 1417. The older version (1188) worked fine for me. I am currently in the process of downgrading.

 

I can't exactly put my finger on what it is that has happened, but I usually understand the optimisations and how that affects debugging quite well. I have always in the past defined a variable as volatile to force a break point such that:

volatile uint8_t x = 5;
x++;    //set break here

Breaking on the x++ in the past has guaranteed a break within my code while debugging. The newer toolchain seems to have done something differently where this is not always the case. Either this or the breakpoint in my 1500 line file starts being...missed. This can be proven by having multiple "else if" statements. Where the functions is defined 1400 lines in. Each "else if" would be defined with two lines of code within them. When I do a "Step Over" it doesn't break on the "else if" at all, it breaks on either the first or second line of code within the statement. "Step over" this line and it jumps to the first or second line of code in the next statement. In my 20 condition "else if" this is very consistent. Thus breaking in the wrong locations in comparison to the older version. I am only talking about comparisons between r1188 and r1417 and how things have appeared to have gotten much worse.

 

There is another debugging issue that also been identified, where the variables don't get updated after executing lines of code. Sometimes it would take several lines or even entire functions before those variables are updated, while I couldn't comment on how the optimisations affect this, r1188 did do this sometimes, but very rarely. r1417 seems to consistently do with almost every variable I have.

 

EDIT: Just finished my downgrade to r1188 and all my breakpoints are breaking on the correct locations again and my variables while debugging are showing the correct values once more!

Last Edited: Wed. Jun 14, 2017 - 01:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Atmel: last time this happened it was because the tools were always assuming '\n' line endings in source not the "\r\n" in Windows source files.

 

Wonder if the 4.x to 5.x compiler switch has regressed this fault?

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

Duely noted, I've logged a bug so that we can investigate (AVRSV-7889). 

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

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

meolsen wrote:

Duely noted [...]


I read that as "duly". OTOH since Cliff suggests a possible regression, and a bug that needts to be fixed a second time, it could be "dually". Then of-course, if this is a shoot-out between different EOL conventions it might be "duelly". Sorry, couldn't resist..

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl wrote:

meolsen wrote:

Duely noted [...]

I read that as "duly". OTOH since Cliff suggests a possible regression, and a bug that needts to be fixed a second time, it could be "dually". Then of-course, if this is a shoot-out between different EOL conventions it might be "duelly". Sorry, couldn't resist..

Hang down your head, Tom Dooley
Hang down your head and cry
Hang down your head, Tom Dooley
Poor boy, you're bound to die

-- Kingston Trio, circa 1958  https://www.youtube.com/watch?v=...

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.