Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include "HardwareProfile.h"
  2.  
  3. _FOSCSEL(FNOSC_FRCPLL)              //set clock for internal OSC with PLL
  4. _FOSC(OSCIOFNC_OFF & POSCMD_NONE)   //no clock output, external OSC disabled
  5. _FWDT(FWDTEN_OFF)                   //disable the watchdog timer
  6. _FICD(JTAGEN_OFF & ICS_PGD1);       //disable JTAG, enable debugging on PGx1 pins
  7.  
  8. int main() {
  9.     // setup internal clock for 80MHz/40MIPS
  10.     // 7.37/2=3.685*43=158.455/2=79.2275
  11.     CLKDIVbits.PLLPRE=0;        // PLLPRE (N2) 0=/2
  12.     PLLFBD=41;                  // pll multiplier (M) = +2
  13.     CLKDIVbits.PLLPOST=0;       // PLLPOST (N1) 0=/2
  14.     while(!OSCCONbits.LOCK);    // wait for PLL ready
  15.     ...