AVR Program Coding Help

Before I post my code and what issues I'm having, would anyone here be willing to help me figure out why my latest program in AVR Studio 5 is driving me absolutely insane?! I go to debug it by stepping through, and the cursor seems to be randomly jumping all over at times, and as it does step through code that changes the values of a variable it sets them to random values! I've re-written the program, commented out so much code, created a new project, cleaned the build, etc., and it's still doing it. Could this be an optimization setting issue?

Anyways, any help would be appreciated because I'm completely stuck :(

EDIT: I should state, I have successfully written other programs that are working great in my lights. I'm trying to do something more complicated now, but technically no different than the programs before - and now this is happening.

I haven't used the AVR Studio 5 (yet), but that sounds exactly like debugging an optimized binary in "normal" Microsoft Visual Studio.

You may want to try creating a separate debug build.

Thanks for the reply. I'm not sure what you mean by creating a separate debug build, but I've tried running the debug with optimization off and it doesn't work because delay.h requires optimization (?). I tried removing all of the delays, and you can't step through the code when it's not optimized. Setting it back to optimize causes the original issue then. Ugh.

Holy crap I give up. After getting things to seemingly work again by going back to AVR Studio 4 (which is a pain to install on Windows 7), and after debugging code by making changes, flashing, testing the light, and repeating the process, it's now back to it's "broken" state. When debugging the cursor just loves to jump around randomly when stepping through, and the program is not working the way it was on a previous flash even with the same code.

There seems to be nothing for me to do but simply give up (although I really, really don't want to). Time to crack open another beer :(