本帖最后由 yhh808 于 2017-4-6 10:05 编辑
各位大虾,在st-link v2 硬件仿真时,无法进外部中断,但在下载到板子上,不在仿真模式下又可以进入中断!下面是我的配置,烦请各位看一下,到底是怎么回事。。。。。。。
#define NRF24L01_MB_IRQ GPIO_Pin_7
#define GPIO_NRF24L01_MB_IRQ GPIOC
#define RCC_NRF24L01_MB_IRQ RCC_APB2Periph_GPIOC
#define GPIO_PortSourceGPIO GPIO_PortSourceGPIOC
#define GPIO_PinSource GPIO_PinSource7
#define EXTI_Linex EXTI_Line7
void Set_24L01_IRQ(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_NRF24L01_MB_IRQ|RCC_APB2Periph_AFIO, ENABLE);//打开GPIO AFIO的时钟
GPIO_InitStructure.GPIO_Pin = NRF24L01_MB_IRQ;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIO_NRF24L01_MB_IRQ, &GPIO_InitStructure);
EXTI_ClearITPendingBit(EXTI_Linex);
GPIO_EXTILineConfig(GPIO_PortSourceGPIO,GPIO_PinSource);
EXTI_InitStructure.EXTI_Line= EXTI_Linex; //PC7,
EXTI_InitStructure.EXTI_Mode= EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger= EXTI_Trigger_Falling; //中断方式为下降沿
EXTI_InitStructure.EXTI_LineCmd=ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); //NVIC
NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority= 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority= 0;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
extern u8 RxInt ;
void EXTI9_5_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Linex) != RESET) //检查指定的EXTI线路触发请求发生与否
{
RxInt=1;
EXTI_ClearITPendingBit(EXTI_Linex); //清除EXTI线路挂起位
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>