Use watch-dog timer
This example illustrates how the watch-dog timer should not be used. A command used to reset this timer is intentionally left out in the main program loop, thus enabling it to win the time battle and cause the microcontroller to be reset. As a result, the microcontroller will be reset every time, which is indicated by PORTB LEDs blinking.'Header****************************************************** program example_5 ' Program name main: ' Start of program OPTION_REG = 0x0E ' Prescaler is assigned to timer WDT (1:64) asm CLRWDT ' Assembly command to reset WDT timer end asm PORTB = 0x0F ' Initial value of the PORTB register TRISB = 0 ' All PORTB pins are configured as outputs Delay_ms(300) ' 30mS delay PORTB = 0xF0 ' Port PORTB value different from initial while 1 ' Endless loop. Program remains here until WDT wend ' timer resets the microcontroller end. ' End of programIn order to make this example work properly, it is necessary to enable the watchdog timer by selecting the Watchdog Timer - Enabledoption in mE programmer.