title: Program exits endless loop (PIC microcontroller)?
body: <p>I wrote a program for the PIC 16f690 microcontroller after noticing my programs seemed to be exiting an endless loop.</p>
  
  <p>There are LEDs on pins 3,4,5 of PORTC.</p>
  
  <pre><code>#include &lt;xc.h&gt;
  #define _XTAL_FREQ 4000000
  
  void main(void) {
  
      TRISC = 0x00;
      PORTC = 0b00111000;
  
      while (1)
      {
          __delay_ms(1000);
          PORTC = 0x00;
      }
  }
  </code></pre>
  
  <p>As far as I understand, the LEDS should be on for ~1sec, and then be off forever. Instead they keep blinking every second.</p>
  
  <p>I wrote this in MPLABX and programmed using PICkit3 and C8 compiler.</p>