2026-03-11 11:33 AM
I have an STM32H7 project (created by TouchGFX) that uses FreeRTOS.
FreeRTOS uses the systick, so the HAL uses TIM2 for it's timebase.
However, HAL_IncTick is never called, so calls to HAL_Delay never return.
HAL_InitTick() is being called during startup and this results in TIM2 counting and its update interrupt flag being set. However, the interrupt handler never gets called.
2026-03-11 11:40 AM
i have problem a little bit similar to yours but iam using AZURE RTOS i just start with blink an LED task it blink at the first time so the problem hapen in tx_thread_sleep it didnt work still SUSPENDED by system timer
2026-03-11 11:41 AM
TIM2 needs to be running and configured, TIM2 interrupt needs to exist, be enabled, and be higher (numerically lower) than the thread you're calling HAL_GetTick from. One of those isn't happening.
2026-03-11 1:18 PM - edited 2026-03-11 1:19 PM
Add a HAL_Delay(2) call in your main() before creating any RTOS thingy and starting the scheduler.
If this call won't return as expected - the TIM interrupt does not work. Check why. Especially check that the vectors table pointer is set correctly and the TIM interrupt priority is very high (numerically small or equal to 0).
If this little test passed, but the interrupt fails to tick later after the scheduler started: again check the TIM interrupt priority vs the RTOS synchronization priority. The TIM handler does not touch any RTOS service so the prio should be very high. Or (much worse) suspect memory or stack corruption.
2026-03-11 4:43 PM
Thanks All,
The timer is running - I can see it counting if I set a breakpoint in HAL_Delay().
The call to HAL_Delay() that 'gets stuck' takes place before the RTOS is started:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* USER CODE BEGIN Boot_Mode_Sequence_0 */
/* USER CODE END Boot_Mode_Sequence_0 */
/* Enable the CPU Cache */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* USER CODE BEGIN Boot_Mode_Sequence_1 */
//SCB_EnableDCache();
/* USER CODE END Boot_Mode_Sequence_1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init(); // This calls HAL_InitTick(), which configures and starts TIM2
/* USER CODE BEGIN Init */
//uwTickPrio = 4;
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* Configure the peripherals common clocks */
PeriphCommonClock_Config();
/* USER CODE BEGIN Boot_Mode_Sequence_2 */
/* USER CODE END Boot_Mode_Sequence_2 */
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_MDMA_Init();
MX_LTDC_Init();
MX_USART1_UART_Init();
MX_I2C4_Init();
MX_DAC1_Init();
MX_DMA2D_Init();
MX_SPI1_Init();
MX_TIM1_Init();
MX_TIM5_Init();
MX_UART4_Init();
MX_UART8_Init();
MX_CRC_Init();
MX_I2C2_Init();
MX_LPTIM2_Init();
MX_SPI2_Init();
MX_TIM15_Init();
MX_DSIHOST_DSI_Init(); // First call to HAL_Delay() is in here
// More init calls, followed by calls to start FreeRTOS.If I set a breakpoint in HAL_Delay() and force it to return then the code executes as expected (so the only issue is HAL_IncTick() not being called.
The template configures the TIM2 interrupt to run at priority 15 (which is ok, as it's only really used to generate some non-critical delays within the HAL). I have tried rebuilding with it set to 0, but that made no difference.
2026-03-11 4:45 PM
Strange. I've made no changes, but the delays have now started working.
I'm wondering if this is related.
2026-03-12 2:52 AM
How do I get the "Accepted solution" removed from this thread?
The problem still exists - my "Thanks All" message was simply reporting that the timer was running, not that the interrupt was being called.
2026-03-12 3:16 AM
2026-03-12 4:21 AM
For important stuff: don't use HAL :D
And a simple "SysTick simulation" / basic system timer is set up quite easily without HAL, even in H7.
I also recommend not using the HAL IRQ handler for such simple timer use, so much overhead to reset one register / bit.
2026-03-12 4:49 AM
This is a TouchGFX project created from a template, so I have to live with what it uses ;)