int Input_caputre3(void)
{
T3CON = 0x8030;
IC3CON = 0;
IC3CONbits.ICTMR = 0; //Select Timer3 as the IC3 Time base
IC3CONbits.ICSIDL = 0;
IC3CONbits.ICI = 0b0; //每个捕捉事件中断一次
IC3CONbits.ICM = 0b1; //Capture mode, every edge (rising and falling)
IPC9bits.IC3IP = 3; // Setup IC3 interrupt priority level
IFS2bits.IC3IF = 0; // Clear IC3 Interrupt Status Flag
IEC2bits.IC3IE = 1; // Enable IC3 interrupt
return 1;
}
int Input_caputre1(void)
{
T3CON = 0x8030; // 1:256 internal clock, start T3.
IPC0bits.IC1IP = 1; // Setup Input Capture 1 interrupt for desired priority
// level (this example assigns level 1 priority)
IFS0bits.IC1IF = 0; // Clear the IC1 interrupt status flag
IEC0bits.IC1IE = 1; // Enable IC1 interrupts
IC1CON = 0x0000; // Turn off Input Capture 1 Module
IC1CONbits.ICSIDL = 0; // Input capture module will continue to operate in CPU Idle mode
IC1CONbits.ICTMR = 0; // TMR3 contents are captured on capture event
IC1CONbits.ICI = 0; // Interrupt on every capture event
IC1CONbits.ICM = 1; // Capture mode, every edge (rising and falling)
}
void __attribute__((__interrupt__,no_auto_psv))_IC1Interrupt(void)
{
unsigned int t1;
IFS0bits.IC1IF = 0;
t1=IC1BUF;
LATF=(PORTF ^ 0xff);
//IC1flag = 1;
}
void __attribute__((__interrupt__,no_auto_psv))_IC3Interrupt(void)
{
unsigned int t1;
IFS2bits.IC3IF = 0;
t1=IC3BUF;
LATF=(PORTF ^ 0xff);
} |