cancel
Showing results for 
Search instead for 
Did you mean: 

st-link gdb debug

yang hong
Associate II

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?

10 REPLIES 10
Mike_ST
ST Employee

Hello,

Which MCU is it ?

If you go step by step, at what line in HAL_Init() does it fail ?

yang hong
Associate II

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.

Mike_ST
ST Employee

Do you have implemented the interrupt code for the TIM6 (named TIM6_IRQHandler ) in stm32xxx_it.c or stm32xxxx_hal_timebase_tim.c file ?

yang hong
Associate II

hello:

TIM6_DAC_IRQHandler is default function, I didn't add anything inside, but I have timer6 callback function to update my rtc time.

yang hong
Associate II

hal_tim_periodElapsedcallback

Mike_ST
ST Employee

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);

}

yang hong
Associate II

I have narrow the code trigger hardfault event.

tmpsmcr = htim->Instance->SMCR & TIM_SMCR_SMS; in HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim)

Mike_ST
ST Employee

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.

yang hong
Associate II

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