I built a STemwin Project with Cubemx and run this project on STM32F429ii based PCB. Every time when it reached the GUI_INIT() which was related to the memory allocation, it ran into HardFault_Handler(). I debugged this issue and found it was caused by the Timer while the only timer in this project is TIM1 for Timebase source. I can't understand how can Timer cause the HardFault? Can someone give me a clue about this issue? Thank you.
Here is some debugging information:
->SP value when HardFault occur
->LR value in Stack
->Assembly code position
->C code position
Edit: Problem is solved. When the SDRAM clock frequency drops from 72Mhz to 36Mhz, the emwin runs well. The SDRAM controller needs to be check and reconfigured later but the emwin is ok.
HAL_TIM_PeriodElapsedCallback
function is trying to return, but the return address on the stack has been overwritten by something else. Have you made your stack(s) large enough? Have you added any additional code toHAL_IncTick
? \$\endgroup\$