Optimized Out During Debugging

All design tool related questions: compiler, assembler, linker. Embedded programming questions: assembler, C code.

Moderator: nferre

euphoricnoise
Posts: 13
Joined: Wed Jun 11, 2014 8:21 pm

Optimized Out During Debugging

Wed Jul 16, 2014 5:30 pm

Hi everyone, I'm relatively new to microcontrollers so hopefully this is just a simple question.

I've been messing with the audio codec examples from the ASF documentation and trying to use it in my own code. However, when I'm debugging it (SAM-ICE), some variables are optimized out and not assigned a real value. Whereas if I just run the ASF example by itself, the same variables are not optimized out. This is a problem because it is stalling my program (one while loop can never exit because of this error).

So what does optimized out mean? If I got it right, it means that the compiler has deemed it unnecessary/not needed for runtime. Is the optimized out message really the issue or something more rooted in my own code? I've imported most of the TWI code from the ASF example (leaving the codec and SSC the only thing I programmed, but only the codec is involved with the TWI part that stalls).

EDIT: Using Atmel Studio 6
EDIT2: I think it'd also be important to write that I'm using 81% of the memory. Is that safe?
Glorfindel
Posts: 8
Joined: Mon Dec 11, 2006 8:05 pm

Re: Optimized Out During Debugging

Wed Jul 16, 2014 5:46 pm

try to use volatile, e.g.

Code: Select all

volatile int MyOptimizedVar;
http://www.barrgroup.com/Embedded-Syst ... e-Keyword
euphoricnoise
Posts: 13
Joined: Wed Jun 11, 2014 8:21 pm

Re: Optimized Out During Debugging

Wed Jul 16, 2014 6:43 pm

Thanks for the quick response! That did solve the optimized out issue but I found out one of my variables was also set incorrectly and thus stalled the program.

Return to “Development Tools”

Who is online

Users browsing this forum: No registered users and 1 guest