3
\$\begingroup\$

Compiling an existing PIC32 project using the v2.00 C compiler produces a continual watchdog reset. This problem does not appear using the previous v1.12 compiler. Changing the watchdog postscaler value (up to 1048 seconds) has no effect. The watchdog reset occurs almost immediately after startup, definitely not enough time for the timer to expire. Disabling the watchdog allows the code to run as expected.

There was a change to the startup code in v2.00, but I am not using any custom startup code to my knowledge. Could there be a problem with the timer used by the watchdog not being enabled correctly? Where should I look to try and debug this issue?

MORE INFO

The reset occurs when I clear the watchdog timer. If I use

WDTCONSET = 0x01;
// or
WDTCONbits.WDTCLR = 1;
// or
ClrWdt();

The reset will occur.

If I don't reset the watchdog timer (let the timer expire), I get a reset after the time specified by the postscalar, as expected.

\$\endgroup\$
  • 1
    \$\begingroup\$ Have you already read the Migration Issues to Version 2.0? \$\endgroup\$ – Daniel Grillo Jul 11 '11 at 17:07
  • \$\begingroup\$ Yes. I had to change 2 #define definitions that used the peripheral freeze bits (FRZ). That was the only compiling issue I had. I didn't see anything else other than the startup code that concerned me. \$\endgroup\$ – Erik Jul 11 '11 at 17:31
3
\$\begingroup\$

All the PIC32 Starter Kit examples turn the WDT off during initialisation with:

#pragma config FWDTEN = OFF // Watchdog Timer

You should do the same.

\$\endgroup\$
  • \$\begingroup\$ He already says disabling fixes it, but I think the question is more along the lines of what is wrong/different. \$\endgroup\$ – Kellenjb Jul 11 '11 at 15:41
  • \$\begingroup\$ @LeonHeller, he is getting resets, says that disabling fixes it, asks how to go about the finding the actual reset. pin outputs and such are obvious to us, but not to new users. \$\endgroup\$ – Kortuk Jul 11 '11 at 16:02
  • \$\begingroup\$ I already use FWDTEN = OFF. I enable the watchdog after my init code and before the main loop with WDTCONSET = 0x8000; I kick the watchdog at the top of the loop with WDTCONSET = 0x01; \$\endgroup\$ – Erik Jul 11 '11 at 16:17
0
\$\begingroup\$

You can import the HEX files into MPLAB and analyze the disassembly. It should be fairly trivial to identify the watchdog timer control registers and initialization code.

\$\endgroup\$
  • \$\begingroup\$ And if he still has both versions available he can compare what was done differently. \$\endgroup\$ – Kellenjb Jul 11 '11 at 16:03
  • \$\begingroup\$ @Madmanguruman, does pic not run the watchdog while on debug. It had to be disabled on MSP430 always due to the watchdog counting time regardless of it you were on breakpoint. \$\endgroup\$ – Kortuk Jul 11 '11 at 16:04
  • \$\begingroup\$ @Kortuk I've clarified my comment. I wasn't intending him to single-step, more read through the disassembly line-by-line. \$\endgroup\$ – Adam Lawrence Jul 11 '11 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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