0
\$\begingroup\$

I am having problems with the MPLAB X debugger (although the release build works fine). It behaves very weirdly with my PIC16LF1937-based PICKIT3. Specifically:

  • It gets caught in random infinite loops
  • The step over function doesn't work most of the time
  • It only seems to debug the first few instructions
  • Setting a breakpoint on a late instruction will cause the PIC to freeze early

What could I be doing wrong? What things should I check?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

I question the stability of your release build if you cannot debug it at all.

Building for debugging adds some extra meat to your HEX file, meaning things aren't always in the same RAM and flash locations they are in a production build. This has (for me) sometimes shown some software bugs that I didn't see in production mode (case in point - I think I found a bug in the XC16 string library where sscanf is throwing address errors when dealing with chars, which only showed up after I started debugging and a char moved to a different RAM location)

If you're debugging and you have WDT enabled, disable it - the WDT doesn't play well with the debugger freezing time by stopping the micro.

Before you add breakpoints and other stuff, simply run the program as-is in debug mode - no single steps, just execute. The code should just 'work'.

For detailed help, you'll need to post a minimum code sample that works fine in production mode but hangs up when debugging. (This exercise may show you some buggy code that you didn't realize you had.)

\$\endgroup\$
1
  • \$\begingroup\$ Thanks. I think I have just found the problem. I have disabled all interrupts and now all seems to work just fine. Disabling the WDT, and trying to run the code without any breakpoints are good tips. \$\endgroup\$
    – Randomblue
    Commented Nov 19, 2012 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.