Unable achieve delay with timer14 in stm32g030kt6 MCU
Hi all,
I tried to configure timer 14 to generate interrupt every 500 ms . i am toggling an GPIO to measure delay .
when put a breakpoint interrupt gets triggered but unable to see waveform in logic analyser of GPIO toggling with delay .
My clock frequency is 4 MHZ , desired interval period is 500 ms so PSC is 2000 , ARR is 1000.
Kindly give suggestions
void main()
{
timer_init();
HAL_TIM_Base_Start_IT(&htim1);
while(1)
{
}
}
void timer_init()
{
htim1.Instance = TIM14;
htim1.Init.Prescaler = 2000 - 1;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 1000 - 1;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
}
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef *htim)
{
if(htim->Instance == TIM14)
{
/* Peripheral clock enable */
__HAL_RCC_TIM14_CLK_ENABLE();
/* TIM14 interrupt Init */
HAL_NVIC_SetPriority(TIM14_IRQn, 3, 0);
HAL_NVIC_EnableIRQ(TIM14_IRQn);
}
}
void TIM14_IRQHandler()
{
GPIOB->ODR ^= 1 << 9;
}
Thanks
Narendra C