原子哥你好:下面是我编写的外部中断程序 程序无法进入中断 请帮忙找找原因
void main ()
{
RCC->AHB1ENR |= 0x00000008; //使能GPIOD时钟
RCC->APB2ENR |= (1<<14); //使能syscfg时钟
SCB->AIRCR = 0x05FA0000 | 0x400; //中断优先级分组 抢占:响应=3:1
Led_Init();
GPIOD->MODER &= 0xFFFFFCFF; //浮空输入模式
GPIOD->
UPDR &= 0xFFFFFCFF;
EXTI->IMR |= ( 1 << 8 ); //不屏蔽外中断线0
EXTI->FTSR |= ( 1 << 8 ); //下降沿触发
SYSCFG->EXTICR[2] &= 0xFFFFFFF0; //配置外中断线8到PD口
SYSCFG->EXTICR[2] |= 0X00000003;
NVIC->IP[23] = 0x70; //最低抢占优先级,最高响应优先级0111
NVIC->ISER[0] |= (1<<23); //使能中断线6,也就是外中断0
while(1)
{
};
}
void EXTI9_5_IRQHandler(void)
{
uint32_t tmp;
if(EXTI->
R & 0x00000100 != 0) //检查是不是外中断0挂起
{
GPIOD->BSRRH = 0xf000;
Delay(500);
// tmp = (~GPIOD->ODR) & 0x0000f000; //PD15 14 13 12翻转,板子上四个LED的亮灭
// GPIOD->ODR &= 0xffff0fff;
// GPIOD->ODR |= tmp;
EXTI->
R =(1<<8); //外中断0解除挂起
}
}
一周热门 更多>