2

在 IAR 编译器上使用 STM32L151xx。

我正在尝试获取 EXTI 中断但无处可去,这是我的代码,它基本上直接来自示例代码但无法正常工作,

  EXTI_InitTypeDef EXTI_InitStructure;
  NVIC_InitTypeDef NVIC_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
  SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource10);
  EXTI_InitStructure.EXTI_Line = EXTI_Line1;
  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling;  
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
  EXTI_Init(&EXTI_InitStructure);
  NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;//0x0F;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;//0x0F;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  EXTI_GenerateSWInterrupt(EXTI_Line1);

当我将 PA10 引脚设为高电平时,我没有收到软件中断,代码没有转到EXTI1_IRQHandler(),似乎缺少什么? 编辑EXTI_GetFlagStatus得到 0,EXTI_GETITStatus我得到 0

4

1 回答 1

2

PA9连接到Line9, 和PA10 Line 10中断服务通过EXTI9_5_IRQHandler (EXTI9_5_IRQn), 和EXTI15_10_IRQHandler (EXTI15_10_IRQn)

于 2013-10-06T15:46:16.007 回答