#include<p32xxxx.h>
#include<stdio.h>
#include <plib.h>
#pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_1, FWDTEN = OFF
#pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_2
#define SYS_FREQ (80000000L)
#define CORE_TIMER_PERIOD SYS_FREQ
int Toggle_count;
int main()
{
TRISD =0x00000000;
PORTDbits.RD0 = 1;
while(1)
{
};
};
void __ISR(INT_EXTERNAL_0_VECTOR, 3) CoreTimerHandler(void)
{
// .. things to do
if (Toggle_count == 1) mPORTDToggleBits(BIT_0);
if (Toggle_count == 2) mPORTDToggleBits(BIT_1);
if (Toggle_count == 3) mPORTDToggleBits(BIT_2);
Toggle_count ++;
if (Toggle_count == 4) Toggle_count = 1;
// .. Toggle the LED
mPORTDToggleBits(BIT_0);
// update the period
UpdateCoreTimer(CORE_TICK_RATE);
// clear the interrupt flag
mCTClearIntFlag();
}