AnsweredAssumed Answered

help: HAL_Delay and FreeRTOS cause HardFault_Handler

Question asked by yy.hh on Oct 15, 2015
Latest reply on Oct 15, 2015 by yy.hh
I'm using HAL libraries, its HAL_Delay with FreeRTOS will cause HardFault

my stack backtrace:
#0  HardFault_Handler ()
    at ./system/stm32f4xx_it.c:83
#1  <signal handler called>
#2  0x0800343a in xTaskIncrementTick () at freertos/tasks.c:2056
#3  0x0800064a in SysTick_Handler () at freertos/portable/GCC/ARM_CM4F/port.c:498
#4  <signal handler called>
#5  0x0800573a in HAL_GetTick () at ./st_hal/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:324
#6  0x08005764 in HAL_Delay (Delay=1)
    at ./st_hal/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c:342
#7  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.


Outcomes