PIC: Watchdog timer off by a factor of 4

pictimerwatchdog

I have a PIC16 (datasheet here) for which I use the watchdog timer. I configure the watchdog timer as follows:

WDTCONbits.WDTPS = 0b01110;

According to page 105 of the datasheet, this should configure the watchdog timer for 16 seconds. However, the timer interrupt is called after only 4 seconds. (I have tested the timer with other values and the 4x discrepancy always persists.)

My first thought was that it was due to the 4xPLL being enabled. But as far as I understand, the watchdog timer is based upon the LFINTOSC clock, which is invariant under the 4xPLL.

Why is my watchdog timer running at four times the speed it should be?

Best Answer

According to the datasheet you provided, at page 105, the value you should program is: 01110. Thus the whole register should be 0b00011101 -> 0x1D.

It seems that you already did so. But are you sure that the definition of WDTCONbits.WDTPS doesn't contain a bug ? Try to assign to the whole register directly.

The watchdog is powered by the internal low frequency oscillator. It has nothing to do with the PLL.