Watchdog reset using C32 v2.00 compiler

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?

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.

• Have you already read the Migration Issues to Version 2.0? – Daniel Grillo Jul 11 '11 at 17:07
• 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. – Erik Jul 11 '11 at 17:31

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

#pragma config FWDTEN = OFF // Watchdog Timer

You should do the same.

• He already says disabling fixes it, but I think the question is more along the lines of what is wrong/different. – Kellenjb Jul 11 '11 at 15:41
• @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. – Kortuk Jul 11 '11 at 16:02
• 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; – Erik Jul 11 '11 at 16:17

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.

• And if he still has both versions available he can compare what was done differently. – Kellenjb Jul 11 '11 at 16:03
• @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. – Kortuk Jul 11 '11 at 16:04
• @Kortuk I've clarified my comment. I wasn't intending him to single-step, more read through the disassembly line-by-line. – Adam Lawrence Jul 11 '11 at 17:29