请教各位大神;KBI中断设置为高电平触发,进入中断程序后,如果加上判断中断源引脚的程序,则读KBI1_SP寄存器的值为0x000000,如果不加上判断语句,则第一次读的值为0x000000,以后近中断读的值为0x00002000,与预期相符;中断引脚使能寄存器配置为0x000000;改引脚进入中断后使能为GPIO输入输出,做OWI通讯;
以下为我的中断初始化及服务程序:void KBI_PIR_Init_app(void)
{
uint32_t i;
KBI_ConfigType sKBIConfig;
MCU_drive_dis;
DOCI_R;
/* Disable all the KBI pins */
for (i = 0; i < KBI_MAX_PINS_PER_PORT; i++)
{
sKBIConfig.sPin[ i].bEn = 0;
}
sKBIConfig.sBits.bRstKbsp = 1;/*Writing a 1 to RSTKBSP is to clear the KBIxSP Register*/
sKBIConfig.sBits.bKbspEn = 1;/*The latched value in KBxSP register while interrupt flag occur to be read.*/
sKBIConfig.sBits.bMode = KBI_MODE_EDGE_LEVEL;
sKBIConfig.sBits.bIntEn = 1;
sKBIConfig.sPin[KBI1_PTF5_SHIFT].bEdge = KBI_RISING_EDGE_HIGH_LEVEL;
sKBIConfig.sPin[KBI1_PTF5_SHIFT].bEn = 1;
KBI_SetCallback(KBI1, &KBI1_PIR_Task);
KBI_Init(KBI1, &sKBIConfig);
}
void KBI1_PIR_Task(void)
{
KBI_mark=KBI_GetSP(KBI1);
//if(KBI_mark == KBI1_PTF5_MASK) 加上此判断,每次读取值为0x000000;
{
KBI_DisableInt(KBI1);
KBI_RstSP(KBI1);
MCU_drive_dis;
delay10us_PC(8);
GPIO_read=FGPIO_Read(FGPIOB);
if(GPIO_read&0x2000) //delete glitch
{
DOCI_read_data=DOCI_read();
global_uart_send[4]=DOCI_read_data>>8;
global_uart_send[5]=DOCI_read_data;
global_uart_send[0]=MCU_ADDR;
global_uart_send[1]=0x07;
global_uart_send[2]=0x06;
global_uart_send[3]=0x00;
global_uart_send[6]=Cal_CRC(global_uart_send,global_uart_send[1]-1);
UART_SendWait_app(UART1);
UART_clear();
UART_send_num++;
}
}
KBI1->PE |= 0x2000;
KBI_EnableInt(KBI1);
}
|