Not able to start time 7 as interrupt in bootloader
I am using STM32L562-DK for my development, I am using SBSFU.
In bootloader, I want to use timer 7 as an interrupt. I am configuring it as following
TIM_HandleTypeDef htim7;
void TIM7_IRQHandler(void)
{
/* USER CODE BEGIN TIM6_IRQn 0 */
/* USER CODE END TIM6_IRQn 0 */
HAL_TIM_IRQHandler(&htim7);
/* USER CODE BEGIN TIM7_IRQn 1 */
/* USER CODE END TIM7_IRQn 1 */
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
if (htim->Instance == TIM7) {
printf("\r\n TIM7 Callback");
}
/* USER CODE BEGIN Callback 1 */
/* USER CODE END Callback 1 */
}
HAL_StatusTypeDef Boot_StartWatchdgFeedTimer(void)
{
RCC_ClkInitTypeDef clkconfig;
uint32_t uwTimclock = 0;
uint32_t uwPrescalerValue = 0;
uint32_t pFLatency;
/*Configure the TIM7 IRQ priority */
HAL_NVIC_SetPriority(TIM7_IRQn, 0 ,0);
/* Enable the TIM7 global Interrupt */
HAL_NVIC_EnableIRQ(TIM7_IRQn);
/* Enable TIM7 clock */
__HAL_RCC_TIM7_CLK_ENABLE();
/* Get clock configuration */
HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
/* Compute TIM7 clock */
uwTimclock = HAL_RCC_GetPCLK1Freq();
/* Compute the prescaler value to have TIM7 counter clock equal to 1MHz */
uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
printf("\r\n uwTimclock = %d\r\n",uwTimclock);
printf("\r\n uwPrescalerValue = %d",uwPrescalerValue);
/* Initialize TIM7 */
htim7.Instance = TIM7;
/* Initialize TIMx peripheral as follow:
+ Period = [(TIM7CLK/1000) - 1]. to have a (1/1000) s time base.
+ Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
+ ClockDivision = 0
+ Counter direction = Up
*/
htim7.Init.Period = (1000000U / 1000U) - 1U;
htim7.Init.Prescaler = uwPrescalerValue;
htim7.Init.ClockDivision = 0;
htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
if(HAL_TIM_Base_Init(&htim7) == HAL_OK)
{
/* Start the TIM time Base generation in interrupt mode */
printf("\r\nTImer Start Ret valur\n");
int ret = HAL_TIM_Base_Start_IT(&htim7);
printf("\r\nTImer Start Ret value = %d\r\n",ret);
return ret;
}
/* Return function status */
return HAL_ERROR;
}
My code is hanging after executing HAL_TIM_Base_Start_IT() API, I have declared void TIM7_IRQHandler(void) in boot_hal.h, and all above APIs are written in boot_hal.c.
Is there any specific configuration required to use tim7 as an interrupt in the bootloader?
I have tried with timer 6, code is not hung HAL_TIM_Base_Start_IT() with timer 6 but the interrupt was not generated.
@Frantz LEFRERE , Can you please help me regarding it?
