各位大神。最近在折腾nucleo板子,型号为L152RE。网上的资料少的可怜。现在想用库开发。目前,想利用上面的按键来学习外部中断,可惜GPIO库中没有GPIO_EXTILineConfig。这就遇到了严重的问题了,折腾到现在都没办法用中断,真是郁闷!而且这款芯片的寄存器和F103的还不一样,太别扭了!求大神指点一二。 我把程序中要解决的位置标注出来了,求解决;我还想知道,这个中断线(EXTI_Line)是怎么设置的?是从EXTICR这个寄存器设置的吗? 下面是我的程序: #include"stm32l1xx.h" #include"stm32l1xx_it.h" volatile uint32_t msTicks; void GPIO_Configuration() { GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin=GPIO_Pin_5; GPIO_InitStructure.GPIO_Speed=GPIO_Speed_40MHz; GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT; GPIO_Init(GPIOA,&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin=GPIO_Pin_13; GPIO_InitStructure.GPIO_Speed=GPIO_Speed_40MHz; GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN; GPIO_Init(GPIOC,&GPIO_InitStructure); GPIO_SetBits(GPIOC,GPIO_Pin_13); } void EXTI_Configuration() { EXTI_InitTypeDef EXTI_InitStructure; SYSCFG->EXTICR[3]|=0X00000020;//我想用这个设置GPIO口与中断线的映射,但是这个根据寄存器设置的,居然没有任何用! EXTI_InitStructure.EXTI_Mode=EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger =EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_Line =EXTI_Line13;//按键在PC13上 EXTI_InitStructure.EXTI_LineCmd =ENABLE; EXTI_Init(&EXTI_InitStructure); } void NVIC_Configuration() { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); NVIC_InitStructure.NVIC_IRQChannel =EXTI15_10_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =1; NVIC_InitStructure.NVIC_IRQChannelSubPriority =1; NVIC_InitStructure.NVIC_IRQChannelCmd =ENABLE; NVIC_Init(&NVIC_InitStructure); } void Delay (uint32_t dlyTicks) { uint32_t curTicks; curTicks = msTicks; while ((msTicks - curTicks) < dlyTicks) { __NOP(); } } void EXTI15_10_IRQHandler() { GPIO_SetBits(GPIOA,GPIO_Pin_5); EXTI_ClearITPendingBit(EXTI_Line13); } int main() { SystemInit(); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC,ENABLE);//是否缺少需要的时钟? GPIO_Configuration(); SysTick_Config(SystemCoreClock / 1000); EXTI_Configuration(); NVIC_Configuration(); while(1) { // GPIO_ResetBits(GPIOA,GPIO_Pin_5); // Delay(500); // GPIO_SetBits(GPIOA,GPIO_Pin_5); // Delay(500); } } |
非常感谢谢谢回复!
没有看到 NVIC_EnableIRQ(EXTI15_10_IRQn) 呢?