完善资料让更多小伙伴认识你,还能领取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); } |
|
相关推荐
9个回答
|
|
单步调试下,看进入中断后能不能出来
|
|
|
|
昨晚试过单步调试,发现PB12,PB13上拉不正常,仅在初始化是上拉,一旦拉低,就不能再次拉高,一直保持低电平,所以只能相应一次中断,把NVIC_Configuration();注释掉,上拉就恢复正常了,求大神指点 |
|
|
|
会不会你pb口有连焊的现象,因为他们优先级都一样,不是很清楚
|
|
|
|
已解决,原来是
GPIOB->BSRR = (IO_B_L & 0xff)|(~IO_B_L & 0xff)<<16|(IO_B_H & 0xff)<<8|(~IO_B_H & 0xff)<<24; 改成 GPIOB->BSRR = (IO_B_L & 0xff)|(~IO_B_L & 0xff)<<16|(IO_B_H & 0x03)<<8|(~IO_B_H & 0x03)<<24; 就OK了 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LZ 可以问个关于STC_12的问题不
|
|
|
|
你好,我先在也是遇到这个问题,STM32外部中断是下降沿触发,但是只能进一次中断,用示波器看中断引脚电平是由高电平变为低电平不回去了,能加个好友交流一下吗QQ845879972
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1373 浏览 1 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
1303 浏览 3 评论
2616 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
1450 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
1882 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-2 03:21 , Processed in 0.699591 second(s), Total 61, Slave 53 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号