2021-12-29 05:14 AM
Hi,
I´m reading the doc of my kits, stm32f767zi and stm32f429zi, but if anyone could help I´ll appreciate. I need start and stop a timer named htim3, as follow:
if (HAL_OK!=HAL_TIM_Base_Start_IT(&htim3))
Error_Handler();
But, if I execute the code twice, I get an error. How can I check if timer was started, before start and stop again? Are there an example code?
I know there´s a register with the information, but I don´t know how use it.
Thanks,
Geraldo.
2021-12-29 06:31 AM
The HAL way is to look at the value of htim3.State.
if (htim->State != HAL_TIM_STATE_READY) {
// timer is not initialized, or already started
}
2021-12-29 08:38 AM
Thanks TDK.
I´ve just tested and updated my project.
Best regards,
2021-12-29 10:47 AM
Actually the HAL way is to use HAL_TIM_Base_GetState() function or one of it's countless useless duplicates.
2021-12-29 12:22 PM
Ok thanks Piranha.