我正在尝试编写一个简单的程序,该程序利用外部中断来控制 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)