cancel
Showing results for 
Search instead for 
Did you mean: 

HardFault with freeRTOS. Variable changes while passed has argument.

JulienD
Senior

Hello

I'm building an app that sends pulses to stepper motors drivers L6474. I built it around

an STM32F429VE, the L6474 libs delivered as example with the x-nucleo board for L6474.

I'm using CubeMx 5.0.1 and cube F4 V1.23.

It's a C++ app.

How it works?

Basically the app send a pwm pulse to each of the 4 drivers using HAL_TIM_PWM_Start_IT() function. 

It catches the timers interrupts to introduce a new pwm pulse while managing acceleration / deceleration.

For testing purpose, the apps runs forever N pulses forward and N pulses backward.

I firstly built the app without OS and it seems to work.

Then I added FreeRTOS with a single task that does the same operation. Its stack memory is widely set to 2048.

Since this moment, I experiments Hard faults after some forward / backward movements. (not always the same amount).

I read this page https://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html#arm_cortex_imprecise_faults 

and its related. CubeMx is managing the freeRTOS initialization and regarding the freeRTOS web page, it seems to be

correctly done.

TIM7 is used as a systickTimer.

I managed to stop the app just before it crashes. Generally (but not always), it happens in HAL_TIM_IRQHandler(&htim7) called by TIM7_IRQHandler().

What I definitely don't understand is on the screenshot: htim7.Instance points to 0x40001400 which is correct but htim->Instance is null

(htim is the parameter of HAL_TIM_IRQHandler()). It should be the same because htim is htim7...

Do you have any explanation on what may happen and more generally about the crash.

I suspect a classic freeRTOS newbie configuration mistake...

Among things, I did try to raise priorityID of timers interrupt. In the map file htim7 is not far after from an array of struct used to manage motors. I instumented the code to check ids everywhere in case of memory overwrite. Everything is unsuccessfull.

Thanks

Julien

0 REPLIES 0