2022-04-28 07:50 PM
htim5 has been running and I need to zero the count (CNT?).
Do I need to stop, de init, init, then start?
Also it seems HAL_TIM_OC_Init() is being used with HAL_TIM_Base_Start_IT(() on the same timer, TIM5. It is used to to generate interrupts with a period of 0xFFFF FFFF. Is this correct?
htim5.Instance = TIM5;
htim5.Init.Prescaler = 83;
htim5.Init.CounterMode = TIM_COUNTERMODE_UP;
htim5.Init.Period = 0xffffffff;
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
// htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_OC_Init(&htim5) != HAL_OK)
{
Error_Handler();
}
HAL_TIM_Base_Start_IT(&htim5);
Thanks
2022-04-28 09:09 PM
CNT can be modified with the timer still running.
TIM5->CNT = 0;
You need a call to HAL_TIM_Base_Init to initialize, not HAL_TIM_OC_Init, if you want interrupts from the update signal, which is the typical method.
2022-04-28 10:45 PM
Next time I try to read CNT the watchdog IRQ fires off. Probably a side effect tho.
2022-04-29 07:20 AM
Reading CNT will not cause a watchdog event to occur. Must be another reason.