2021-08-10 06:22 AM
I have one project built in SW4STM32. I download 1.7 stm32ide and want to start this project in stm32ide. I complete comply. It looks pretty good, the whole project use FREERTOS and tick time use timer6, when I start my program. my program trigger hardfault event and this issue is triggered in HAL_Init(); I believe the issue comes from timer 6 start up, anybody know how to fix this issue?
2021-08-10 07:08 AM
Hello,
Which MCU is it ?
If you go step by step, at what line in HAL_Init() does it fail ?
2021-08-10 07:39 AM
I am using FREERTOS, so I need HAL_InitTick to startup timer 6, when program start HAL_TIM_Base_Start_IT, it causes hardfault.
The same program is working in OPENOCD.
2021-08-10 07:47 AM
Do you have implemented the interrupt code for the TIM6 (named TIM6_IRQHandler ) in stm32xxx_it.c or stm32xxxx_hal_timebase_tim.c file ?
2021-08-10 08:25 AM
2021-08-10 08:29 AM
2021-08-10 08:32 AM
Try to append that code in your file stm32h7xx_hal_timebase_tim.c :
/**
* @brief This function handles TIM interrupt request.
* @param None
* @retval None
*/
void TIM6_DAC_IRQHandler(void)
{
HAL_TIM_IRQHandler(&htim6);
}
2021-08-10 08:37 AM
I have narrow the code trigger hardfault event.
tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS; in HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim)
2021-08-10 08:58 AM
If you are using TIM6 as Systick base, it shouldn't execute the code you just mentionned.
You're calling HAL_TIM_Base_Start_IT with a wrong/invalid timer.
2021-08-10 09:08 AM
Hello,
stm32h7xx_hal_timebase_TIM.c is generated by stm32cube, HAL_TIM_Base_Start_IT is added by stm32cube when I use FREERTOS.
I found the issue on HAL_TIM_PeriodElapsedCallback. rtc_millisecond=999-(temp * 1000/hrtc.Init.SynchPrediv) cause the issue on hrtc.Init.SynchPrediv because hrtc initialization after hal_Init(), so hrtc.Init.SynchPrediv=0, and also the default selection "exception on divide by zero is checked in debug configuration. So a hardfault is triggered, I have modified the program. now I am able to ST-LINK GDB NOW. THANK YOU FOR YOUR SUGGESTION.
I have one more question, I am using NUCLEO-H743ZI2, Is it possible to use J-LINK ? if yes, how to set up?
I want to get some printf message when I debug my program, I used printf function suing j-link, so I want to try j-link, but NUCLEO-H743ZI2, use st-link v3, and j-link can't load j-link to NUCLEO-H743ZI2, Do you have any idea?
Thank you again