Location not valid - Watch window

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

I can't use the watch windows in AVR Studio :(
I get this every time. Whats wrong ?

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

Without seeing any code I'd suspect that the variables might be assigned but their value actually never used so they are optimized away.

Did you try to search in these forums for previous discussions on this error message? I found these two threads that supports my assumption:

https://www.avrfreaks.net/index.p...
https://www.avrfreaks.net/index.p...

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

Quote:
Without seeing any code I'd suspect that the variables might be assigned but their value actually never used so they are optimized away.

Or the optimization is putting them into registers. Either way, turning optimization off should correct this.

Regards,
Steve A.

The Board helps those that help themselves.

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

madid87 wrote:
I can't use the watch windows in AVR Studio :(
I get this every time. Whats wrong ?

Very often the optimizer tries to keep variables in registers. If you move the cursor over the variable in the code window variables show their contents and if in register the registers are shown.
Also if that variable isn't global, e.g. a function local variable or a modul static variable, the definition scope of the variable may be violated.

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

Another way rather than turning off the optimisation for the entire program is to make the variables you are interested in looking at 'volatile'. This works because 'volatile' basically just means "turn off optimisation for any accesses to this particular variable".

Either way, whether you globally turn off optimisation or locally (with volatile) don't forget to switch this back when you've finished debugging though this will mean (and is epsecially true for complete program optimisation) that the behaviour of the program will now be QUITE different and new "bugs" may then crop up to be fixed.

Personally I very rarely use watch windows for this very reason. Instead I generally debug using a mixed C and Asm view (right click, "goto disassembly") and just see which registers the C compiler has put the variables into and watch their contents. You get a far better idea of how the program is working and it's also a VERY quick way to learn the assembler of the target CPU

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

Thank you all very much !

I know AVR assembler very well :) just started programming in C (AVR MCU) and bumped into that problem.
Watching register with particural variable is very good idea. Thank you.

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

I was having the same problem. I have the optimization set to 00 and it doesn't make any difference. I set one of the variables as volatile and now all of the varibales show up when in scope.

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

it's so helpful.
Thanks clawson