跪求大神帮忙看看,是不是配置的代码错误了。仿真时外部给低电平不进中断服务函数。 以下是我写的代码 void EXTIX_Init(void) { EXTI_InitTypeDef EXTI_InitStruct; NVIC_InitTypeDef NVIC_InitStruct; GPIO_InitTypeDef GPIO_InitStructure; // OC_Init(); //¹âñî³õʼ»¯ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);//ʹÄÜSYSCFGʱÖÓ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_2; GPIO_Init(GPIOA, &GPIO_InitStructure); SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);//PA0 Á¬½Óµ½ÖжÏÏß0 EXTI_InitStruct.EXTI_Line = EXTI_Line0; EXTI_InitStruct.EXTI_Mode = EXTI_Mode_Interrupt;//ÖжÏʼþ EXTI_InitStruct.EXTI_Trigger = EXTI_Trigger_Falling; //ÉÏÉýÑØ´¥·¢ EXTI_InitStruct.EXTI_LineCmd = ENABLE;//ÖжÏÏßʹÄÜ EXTI_Init(&EXTI_InitStruct); NVIC_InitStruct.NVIC_IRQChannel = EXTI0_1_IRQn;//ÍⲿÖжÏ0 NVIC_InitStruct.NVIC_IRQChannelPriority = 0x04;//ÇÀÕ¼ÓÅÏȼ¶2 NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStruct); EXTI_ClearITPendingBit(EXTI_Line0); } void EXTI0_1_IRQHandler(void) { if(EXTI_GetITStatus(EXTI_Line0)!= RESET ) { EXTI_ClearITPendingBit(EXTI_Line0); } // if((EXTI->R & EXTI_Line0) !=(uint32_t)RESET) // { // EXTI_ClearITPendingBit(EXTI_Line0); // // } } |
评分
查看全部评分
评分
查看全部评分
谢谢,我已经找到原因了.
已解决了,硬件问题,单片机坏掉了.非常感谢