HardFault on TIM1 when using FreeRTOS

Hello!

I’m using a STM32407VET6 receiving data with UART+DMA+idleline using callbacks. Recently I added a software timer to check if UART communication it’s OK, if not, after 1[s] stops UART+DMA and resume it. But my code has a HardFault(FORCED+PRECISERR) executing HAL_TIM_IRQHandler() when it checks if (__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC1) != RESET).

I found that when the TIM1 is OK all its variables looks defined, but when it the code crashes, some variables/etc are unknow or change. Like the state in 48 or unknow lock state

htim_corrupted

I’m not using any other TIM nor making changes in TIM1. It looks like I’m trying to access to a wrong memory address or changing something in TIM1, but I’m not.

Any idea?

Have you been through FreeRTOS - Open Source RTOS Kernel for small embedded systems and in particular RTOS for ARM Cortex-M

0x2c343336 is NOT the address of TIM1, so something has corrupted that timer control block. My guess is something is overwriting that block. Adding a data breakpoint on htim1.Instance should catch whatever badness is getting you.

You may THINK that ou aren’t changing something in the control block, but you are.