Fixed broken TIM2 for STM32C0xx on stable_21.11.x. Caused by missing include, init and deinit of TIM2 IRQ in os/hal/ports/STM32/STM32C0xx/stm32_isr.c
I confirm TIM2 now works for STM32C071RB.
Code: Select all
From 12540053b7a96dc2640e640dbb3df0ae0321e78c Mon Sep 17 00:00:00 2001
From: engemil <[email protected]>
Date: Mon, 23 Feb 2026 22:02:05 +0000
Subject: [PATCH] fixed TIM2 for STM32C0xx port
---
demos/STM32/RT-STM32C071RB-NUCLEO64/cfg/mcuconf.h | 15 ++++++++-------
os/hal/ports/STM32/STM32C0xx/stm32_isr.c | 3 +++
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/demos/STM32/RT-STM32C071RB-NUCLEO64/cfg/mcuconf.h b/demos/STM32/RT-STM32C071RB-NUCLEO64/cfg/mcuconf.h
index 08f4445d4d..932de13a01 100644
--- a/demos/STM32/RT-STM32C071RB-NUCLEO64/cfg/mcuconf.h
+++ b/demos/STM32/RT-STM32C071RB-NUCLEO64/cfg/mcuconf.h
@@ -89,6 +89,7 @@
#define STM32_IRQ_TIM1_UP_PRIORITY 1
#define STM32_IRQ_TIM1_CC_PRIORITY 1
+#define STM32_IRQ_TIM2_PRIORITY 1
#define STM32_IRQ_TIM3_PRIORITY 1
#define STM32_IRQ_TIM14_PRIORITY 1
#define STM32_IRQ_TIM16_PRIORITY 1
@@ -185,13 +186,13 @@
#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure")
/*
- * USB driver system settings.
- */
-#define STM32_USB_USE_USB1 FALSE
-#define STM32_USB_USB1_LP_IRQ_PRIORITY 3
-#define STM32_USB_USE_ISOCHRONOUS FALSE
-#define STM32_USB_USE_FAST_COPY FALSE
-#define STM32_USB_HOST_WAKEUP_DURATION 2
+ * USB driver system settings.
+ */
+#define STM32_USB_USE_USB1 FALSE
+#define STM32_USB_USB1_LP_IRQ_PRIORITY 3
+#define STM32_USB_USE_ISOCHRONOUS FALSE
+#define STM32_USB_USE_FAST_COPY FALSE
+#define STM32_USB_HOST_WAKEUP_DURATION 2
#define STM32_USB_48MHZ_DELTA 0
/*
diff --git a/os/hal/ports/STM32/STM32C0xx/stm32_isr.c b/os/hal/ports/STM32/STM32C0xx/stm32_isr.c
index c4ca458158..a36f3ac5f8 100644
--- a/os/hal/ports/STM32/STM32C0xx/stm32_isr.c
+++ b/os/hal/ports/STM32/STM32C0xx/stm32_isr.c
@@ -61,6 +61,7 @@
#include "stm32_usart2.inc"
#include "stm32_tim1.inc"
+#include "stm32_tim2.inc"
#include "stm32_tim3.inc"
#include "stm32_tim14.inc"
#include "stm32_tim16.inc"
@@ -82,6 +83,7 @@ void irqInit(void) {
exti4_15_irq_init();
tim1_irq_init();
+ tim2_irq_init();
tim3_irq_init();
tim14_irq_init();
tim16_irq_init();
@@ -103,6 +105,7 @@ void irqDeinit(void) {
exti4_15_irq_deinit();
tim1_irq_deinit();
+ tim2_irq_deinit();
tim3_irq_deinit();
tim14_irq_deinit();
tim16_irq_deinit();