[syntax=c]#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
//void ConfigInt0(EXT_INT_ENABLE |FALLING_EDGE_INT |EXT_INT_PRI_5 );
int Toggle_count;
int main()
{
void ConfigInt0(EXT_INT_ENABLE |FALLING_EDGE_INT | EXT_INT_PRI_5 );
TRISD =0x00000000;
PORTDbits.RD0 = 1;
while(1)
{
};
};
void __ISR(3, IPL5) CoreTimerHandler(void) //INT_EXTERNAL_0_VECTOR
{
// .. 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_TIMER_PERIOD);
// clear the interrupt flag
mINT0ClearIntFlag();
while(1);
}[/syntax]