IAR Embedded Workbench for ARM - 如何定义中断服务例程?

IAR Embedded Workbench for ARM - How to define Interrupt Service Routine?

我尝试为 Timer2 溢出中断创建一个中断服务例程,如下所示:

#include "stm32f10x.h"

/* IRQ definitions in CMSIS startup_stm32f10x */


void TIM2_IRQHandler (void) {
  TIM2->SR &=~TIM_SR_UIF;
  GPIOC->ODR |= GPIO_ODR_ODR13;
}

void timer2_setup() {
  RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;

  TIM2->PSC = 0;
  TIM2->ARR = 900;
  TIM2->DIER |= TIM_DIER_UIE;

  NVIC_EnableIRQ(TIM2_IRQn);

  TIM2->CR1 = TIM_CR1_CEN;
}

int main()
{
  /* Set System-Clock as high as possible */
  RCC->CFGR = RCC_CFGR_SW_1 | RCC_CFGR_PLLMULL_3 | RCC_CFGR_PLLMULL_2 | RCC_CFGR_PLLMULL_0;
  RCC->CR = RCC_CR_HSION | RCC_CR_PLLON;

  /* Set GPIO C13 as High-Speed PushPull output */
  RCC->APB2ENR = RCC_APB2ENR_IOPCEN;
  GPIOC->CRH |= GPIO_CRH_MODE13_1 | GPIO_CRH_MODE13_0;

  __enable_irq();  
  timer2_setup();
  GPIOC->ODR &=~GPIO_ODR_ODR13;
  while(1){
    asm volatile ("nop");
  }
}

我正在为 ARM v8.22.2(最新版本)使用 IAR Embedded Workbench。但是 TIM2_IRQHandler 永远不会被调用——它甚至从 C 编译器中得到优化(所以在反汇编中不再有 TIM2_IRQHandler)。

那么如何在 IAR 中正确定义 ISR Workbench?

请检查 startup_stm32f10XXX.s 文件。此文件必须包含 MCU 的所有中断向量定义。