gpt4 book ai didi

c - STM32L-Discovery EXTI中断失败

转载 作者:太空宇宙 更新时间:2023-11-03 23:29:29 27 4
gpt4 key购买 nike

在 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

最佳答案

PA9 连接到Line9PA10 Line 10 中断服务通过EXTI9_5_IRQHandler ( EXTI9_5_IRQn)EXTI15_10_IRQHandler (EXTI15_10_IRQn)

关于c - STM32L-Discovery EXTI中断失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19157681/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com