Hello, I am trying to figure out how the watchdog timer works on a PIC12F1571 in Proteus with XC8 compiler and came across a weird issue.
I am setting WDTCONbits.WDTPS = 0b01110 which should change the WDT period to 16 seconds, but Proteus still says that the processor was reset after (the default) 2 seconds. I tried various values for WDTPS but I was still getting the default 2 second period, as if the WDTPS value is totally ignored.
I tried various things, but what finally worked for me was to call CLRWDT() once, outside the main loop, then the watchdog timer reset would kick in at a time period according to WDTPS and work as intended.
Is this documented somewhere?
My full code is here
#include <xc.h>
#pragma config FOSC = INTOSC
#define _XTAL_FREQ 2000000
#pragma config WDTE = SWDTEN
void main(void) {
OSCCONbits.IRCF = 0b1100;
WDTCONbits.SWDTEN = 0b1;
WDTCONbits.WDTPS = 0b01110;
CLRWDT();
TRISA = 0;
LATA = 0;
while(1){
LATA = ~LATA;
__delay_ms(1000);
LATA = ~LATA;
__delay_ms(1000);
}
return;
}