#include "HardwareProfile.h"
_FOSCSEL(FNOSC_FRCPLL) //set clock for internal OSC with PLL
_FOSC(OSCIOFNC_OFF & POSCMD_NONE) //no clock output, external OSC disabled
_FWDT(FWDTEN_OFF) //disable the watchdog timer
_FICD(JTAGEN_OFF & ICS_PGD1); //disable JTAG, enable debugging on PGx1 pins
int main() {
// setup internal clock for 80MHz/40MIPS
// 7.37/2=3.685*43=158.455/2=79.2275
CLKDIVbits.PLLPRE=0; // PLLPRE (N2) 0=/2
PLLFBD=41; // pll multiplier (M) = +2
CLKDIVbits.PLLPOST=0; // PLLPOST (N1) 0=/2
while(!OSCCONbits.LOCK); // wait for PLL ready
...