本帖最后由 fancychg1 于 2019-12-26 13:04 编辑
PIC24FV16KM202 需要使用引脚边沿捕捉触发中断功能如何操作?
先配置好定时器,再配置CCPxBUFH/CCPxBUFL?
能举个例子?设置过输入引脚方向。初始化了CCP1控制寄存器,设置了中断服务程序,为何引脚有脉冲却未进入中断服务程序?
//Set RA7 as Input of Start Negtive pulse
//Set RB9 as Input of Start Negtive pulse
TRISA = 0xFFF7; // 1 as inputs and 0 as outputs
TRISB = 0xE20F; //
void initCCP1()
{
CCP1TMRH=0;
CCP1TMRL=0;
CCP1CON1Lbits.CCPON=1;
CCP1CON1Lbits.CLKSEL=0;
CCP1CON1Lbits.TMRPS=0;
CCP1CON1Lbits.T32=0;
CCP1CON1Lbits.CCSEL=1;
CCP1CON1Lbits.MOD=0b0010;
CCP1CON1Hbits.TRIGEN=0;
CCP1CON1Hbits.OPS3=0;
CCP1CON1Hbits.TRIGEN=1;
CCP1CON1Hbits.ONESHOT=1;
CCP1CON2Lbits.ASDG=0;
CCP1CON2Hbits.ICS=0;
CCP1STATLbits.TRCLR=1;
IPC0bits.CCP1IP=0b001; /////////////
IPC0bits.T1IP=0b010;///////////////
IFS0bits.CCP1IF = 0;
IEC0bits.CCP1IE = 1; //Enable CCP1 interrupt.
}
void __attribute__((__interrupt__ , auto_psv)) _CCP1Interrupt(void)
{
IFS0bits.CCP1IF = 0;
}
|