小编Fad*_*EID的帖子

为什么中断在 STM32 上没有按预期工作?

我正在尝试编写一个简单的程序,该程序利用外部中断来控制 2 个 LED 中的哪一个闪烁。在没有中断例程的情况下,两个 LED 都会闪烁,因此 LED 引脚(PB 和 PC13)的配置是正确的。每当我尝试使用 ISR 时就会出现该程序。我正在为 STM32F103C8 MCU 使用仅带有 CMSIS 内核的 Keil uVision 5。

在下面的代码中,两个 LED 都没有闪烁。我试图将引脚 PB5 设置为输入上拉,并在将 PB5 与 GND 连接时检测下降沿作为中断。

#include "stm32f10x.h"                  // Device header

void delay(int rep);
void EXTI9_5_IRQHandler();

// global variable
int signal = 0; // this will change upon each interrupt

int main(void)
{
    // set RCC for PortC to enable the clock BUS
    RCC->APB2ENR |= (1<<4);
    // set RCC for portB to enable the clock bus …
Run Code Online (Sandbox Code Playgroud)

c embedded microcontroller arm stm32

0
推荐指数
1
解决办法
665
查看次数

标签 统计

arm ×1

c ×1

embedded ×1

microcontroller ×1

stm32 ×1