使用PB12,PB13,PE14,PE15作为外部中断,PE14,PE15响应正常,但PB12,PB13无法正常进入中断,代码如下,求指点。。 void EXTI15_10_IRQHandler(void) { //KEY_OK if(EXTI_GetITStatus(EXTI_Line14)==SET) { IO_OutputData(0x00); delay_us(10); EXTI_ClearITPendingBit(EXTI_Line14); } //KEY_UP if(EXTI_GetITStatus(EXTI_Line15)==SET) { IO_OutputData(0xff); delay_us(10); EXTI_ClearITPendingBit(EXTI_Line15); } //KEY_DOWN if(EXTI_GetITStatus(EXTI_Line12)==SET) { IO_OutputData(0xff); delay_us(10); EXTI_ClearITPendingBit(EXTI_Line12); } //KEY_CANCEL if(EXTI_GetITStatus(EXTI_Line13)==SET) { IO_OutputData(0x00); delay_us(10); EXTI_ClearITPendingBit(EXTI_Line13); } } ---------------------------------------------------------------------- void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } -------------------------------------------------------------------------------------- void KEY_config(void) { GPIO_InitTypeDef GPIO_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = KEY_OK | KEY_UP; GPIO_Init(GPIOE, &GPIO_InitStructure); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = KEY_DOWN | KEY_CANCEL; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource14); EXTI_InitStructure.EXTI_Line = EXTI_Line14 ; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource15); EXTI_InitStructure.EXTI_Line = EXTI_Line15 ; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource12); EXTI_InitStructure.EXTI_Line = EXTI_Line12 ; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource13); EXTI_InitStructure.EXTI_Line = EXTI_Line13; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); EXTI_ClearITPendingBit(EXTI_Line12); EXTI_ClearITPendingBit(EXTI_Line13); EXTI_ClearITPendingBit(EXTI_Line14); EXTI_ClearITPendingBit(EXTI_Line15); } |
试了,没能解决问题,这两个函数是一样的吧
void IO_OutputData(u8 DATA)
{
u8 IO_E,IO_B_L,IO_B_H;
IO_E = ((DATA&0x01)<<1)|((DATA&0x02)>>1);
IO_B_H = ((DATA&0x04)>>1)|((DATA&0x08)>>3);
IO_B_L = ((DATA&0x10)<<2)|((DATA&0x40)>>2)|(DATA&0x20)|((DATA&0x80)>>4);
GPIOE->BSRR = (IO_E & 0xff) | (~IO_E & 0xff)<<16;
GPIOB->BSRR = (IO_B_L & 0xff) | (IO_B_H & 0xff)<<8 | (~IO_B_L & 0xff)<<16 | (~IO_B_H & 0xff)<<24;
}
求大神指点
已解决,果然是 IO_OutputData的问题
void IO_OutputData(u8 DATA)
{
u8 IO_E,IO_B_L,IO_B_H;
IO_E = ((DATA&0x01)<<1)|((DATA&0x02)>>1);
IO_B_H = ((DATA&0x04)>>1)|((DATA&0x08)>>3);
IO_B_L = ((DATA&0x10)<<2)|((DATA&0x40)>>2)|(DATA&0x20)|((DATA&0x80)>>4);
GPIOE->BSRR = (IO_E & 0xff) | (~IO_E & 0xff)<<16;
GPIOB->BSRR = (IO_B_L & 0xff) | (~IO_B_L & 0xff)<<16 | (IO_B_H & 0x03)<<8 | (~IO_B_H & 0x03)<<24;
}
兄弟,如果解决了问题,把我的回复设为最佳答案啊,这样咱俩都有金币得了