PIC18 weird variable assignment bug
Without seeing your code it's difficult to give advice (your screenshot is too small to read). What you see can be typically attributed to dynamic memory or auto variables when at certain point the debugger will (erroneously) show you the stack location previously occupied by a variable defined inside a function. Move the code inside a function to see if it makes a difference.