Cmsis, Interrupt on blackpill

Hello,
I’m trying to setup an interrupt routine.
There is an led and scope on gpiob pin 11 to monitor the outcome.
The SysTick_Handler() is working correctly but not the TIM1_UP_IRQHandler().
What could be the reason for that ?

platformio.ini

[env:blackpill_f103c8]
platform = ststm32
board = blackpill_f103c8
framework = cmsis
; change microcontroller
board_build.mcu = stm32f103c8t6
; change MCU frequency
board_build.f_cpu = 72000000L

The main code

#include <stm32f1xx.h>
int main(void) {
  SysTick_Config(SystemCoreClock / 1000);
  // pin b11 output push pull
  RCC->APB2ENR |= RCC_APB2ENR_IOPBEN;
  GPIOB->CRH |= GPIO_CRH_MODE11_0; 
  GPIOB->CRH &= ~GPIO_CRH_CNF11_0;
  GPIOB->CRH &= ~GPIO_CRH_CNF11_1;
  GPIOB->ODR |= GPIO_ODR_ODR11;
  // timer
  RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
  TIM2->PSC = 10;
  TIM2->ARR = 1000;
  TIM2->CR1 |= TIM_CR1_URS;
  TIM2->DIER |= TIM_DIER_UIE;
  TIM2->EGR |= TIM_EGR_UG;
  NVIC_EnableIRQ(TIM1_UP_IRQn);
  
  while(1) {
   //
  }
  return 0;
}

extern "C" {
  void SysTick_Handler(void) {
    count++;
  }
  void TIM2_IRQHandler(void) {
    GPIOB->ODR ^= GPIO_ODR_ODR11; // not excecuting
  }
}

Does the code work when compiled with a different toolchain/IDE or has the code never worked before? Also define “not working”. No outupt, wrong frequency output, …? More info needed.

@maxgerhardt
I haven’t tested another toolchain/IDE yet.
By not working i mean the code inside TIM1_UP_IRQHandler() is not excecuting while the code inside SysTick_Handler() is. The output on pb11 stays high while i get a square wave output when i uncomment GPIOB->ODR ^= GPIO_ODR_ODR11; inside the SysTick_Handler().

Also don’t you have to clear the the interrupt pending bit for your timer? From which sources did you construct this code? Like in Controlling STM32 Hardware Timers with Interrupts – VisualGDB Tutorials where they

extern "C" void TIM2_IRQHandler()
{
    if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
    {
        TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
        GPIO_ToggleBits(GPIOD, GPIO_Pin_12);
    }
}

@maxgerhardt
Thank you, clearing the interrupt pending bit fixed it.
I got the code from a tutorial on Youtube which you can see here.
Now that i watch it again, he also is clearing the interrupt pending bit. I must have looked over it.
I also needed to add this line.

TIM2->CR1 |= TIM_CR1_CEN;
1 Like