I have two educated guesses for you.
1) How big is your program? Could it be too big for the available memory?
2) What MCU does the Hiware Simulator/Debugger display? (The value is located in the right portion of the status bar on bottom of this program's window.) If that value doesn't match the part that you're targeting, you can get sporadic behavior like what you've seen.
---Tom