完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
使用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); } |
|
相关推荐
7个回答
|
|
在EXTI_ClearITPendingBit(EXTI_Line12);之前加一句EXTI_ClearFlag(EXTI_Line12);试试
|
|
|
|
vuywsdfwf 发表于 2018-9-17 18:19 试了,没能解决问题,这两个函数是一样的吧 |
|
|
|
如果12,13可以进入一次的话,可能配置没啥问题,将你的IO_OutputData贴出来看看,是不是在里面修改了12,13管脚的属性了
|
|
|
|
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; } 求大神指点 |
|
|
|
是不是不能在中断中有延时?为什么在中断中延时delay_us(10)?
|
|
|
|
已解决,果然是 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; } |
|
|
|
兄弟,如果解决了问题,把我的回复设为最佳答案啊,这样咱俩都有金币得了 |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
STM32配合可编程加密芯片SMEC88ST的防抄板加密方案设计
1063 浏览 0 评论
2395 浏览 1 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
2190 浏览 3 评论
4824 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
2333 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-31 05:40 , Processed in 0.597759 second(s), Total 54, Slave 48 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号