I have a PIC16LF1709 20-pin 8-bit microchip MCU. I am programming it using a PICkit 3. I am able to successfully burn a program to the chip and run it, but it always seems to reset part-way through execution.

While programming the PIC, I'm letting the programmer supply the power, but I can also unplug the programmer and run the chip on its own 5V supply. As recommended, I've run a 50kOhm pull-up resistor from MCLR to Vdd to prevent that from resetting the device.

I have five LEDs connected to RC0-RC4, and I've written the test program below to demonstrate the problems I'm experiencing:

#include <xc.h>             /* XC8 General Include File */
#include <pic16lf1709.h>    /* Definitions of I/O pins */

void main(void) {

    TRISC = 0x0;    // port C (all are LEDs or NC) is output
    PORTC = 0x0;    // turn on all LEDs
    for(int i=0; i<500; i++) _delay(250); // delay for about a second
    PORTC = 0xFF;   // turn off all LEDs

    while(1) {
        // do nothing, forever
        // lights should remain OFF.


I expect the lights to turn on briefly, then turn off and stay off until I power-cycle the device. Instead, the lights are blinking. This makes me think that the PIC is being reset about every 1 - 2 seconds.

I've tried including the following configuration line (other than this, I didn't specify any configuration) in an attempt to disable some of the features that might automatically reset the device. The behaviour was unchanged.

#pragma config MCLRE = OFF, STVREN = OFF, LPBOR = OFF

I've also tried letting the execution run while powered by the 3.25v supplied by the PICkit (as opposed to the 5v supplied by my main power supply), but that made no apparent difference either.

What could be causing this behaviour?

  • 9
    \$\begingroup\$ A Watchdog Timer? Try adding WDT = OFF. Or WDTE... \$\endgroup\$
    – Eugene Sh.
    Commented May 20, 2015 at 21:21
  • 1
    \$\begingroup\$ Do you have any bypass capacitors? 0.1uF and 1uF directly (or as close as you can) across the power supply pins. I recently had something similar because my only bypass capacitor (space constrained system) wasn't soldered down. \$\endgroup\$
    – akohlsmith
    Commented May 20, 2015 at 21:36
  • \$\begingroup\$ Also try a 100n cap on mclr to gnd \$\endgroup\$
    – Andy aka
    Commented May 20, 2015 at 21:48
  • \$\begingroup\$ @akohlsmith we do have a 100nF decoupling cap across the powersupply. thank you for the suggestion, though. \$\endgroup\$ Commented May 21, 2015 at 12:44

1 Answer 1


As Eugene Sh. correctly pointed out. The most likely culprit is the watchdog timer. If you look at the specification sheet (http://ww1.microchip.com/downloads/en/DeviceDoc/40001729A.pdf) page 99, you can see that the default timeout for the watchdog timer reset is 2s. Also, on page 48, you can see that the default configuration bits enable the watchdog timer regardless of runtime software setting.

Your issue may be solved with the addition of the line:

#pragma config WDTE = OFF 

If that does not solve your issue, you can get the source of the last reset by checking the value of the PCON and STATUS registers ( see section 5.12 Determining the Cause of a Reset in the specification sheet at page 58 ).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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