cancel
Showing results for 
Search instead for 
Did you mean: 

help: HAL_Delay and FreeRTOS cause HardFault_Handler

sprhawk
Associate II
Posted on October 15, 2015 at 04:12

I'm using HAL libraries, its HAL_Delay with FreeRTOS will cause HardFault

my stack backtrace:

&sharp0  HardFault_Handler ()

    at ./system/stm32f4xx_it.c:83

&sharp1  <signal handler called>

&sharp2  0x0800343a in xTaskIncrementTick () at freertos/tasks.c:2056

&sharp3  0x0800064a in SysTick_Handler () at freertos/portable/GCC/ARM_CM4F/port.c:498

&sharp4  <signal handler called>

&sharp5  0x0800573a in HAL_GetTick () at ./st_hal/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:324

&sharp6  0x08005764 in HAL_Delay (Delay=1)

    at ./st_hal/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:342

&sharp7  0x08004704 in main () at main.c:95

Source code:

main()

{

    HAL_Init();

   HAL_Delay(1);

   while(1) {}

}

------------------------------

Update:

I found STM32Cube examples FatFs_uSD_FreeRTOS uses CMSIS_OS , it defines SysTick_Handler in stm32f4xxx_it.c, but when I define it in my _it.c, it complained multiple defined SysTick_Handler.

I found a maybe related discussion:    https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Java%2FFreeRTOS%20and%20HAL%20driver%20timeout%20issue&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&currentviews=1189

--------------

fixed:

comment xPortSystickHandler macro as comment says.

implement SysTick_Handler like what in freeRTOS/CMSIS_OS/cmsis_os.c.

#stm32-freertos-hardfault
2 REPLIES 2
Posted on October 15, 2015 at 06:34

Is dropping out of main() a good plan? Where does that go?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sprhawk
Associate II
Posted on October 15, 2015 at 07:03

I miss while(1) {} in the example. It is not the critical problem, I have updated, it is due to conflict with FreeRTOS.