Start stop clear timer?
Hi, do HAL_TIM_Base_Stop will clear couter? When I next Start the timer will it count from 0 or will count from random number that it stopped? There is no Base_Clear as I know.
Thanks
Hi, do HAL_TIM_Base_Stop will clear couter? When I next Start the timer will it count from 0 or will count from random number that it stopped? There is no Base_Clear as I know.
Thanks
If you want to be in control, use the hardware registers as described in the reference manual.
The timer functional description chapters have some very helpful and detailed diagrams on the effects of setting various control bits.
Basically, issuing
TIMx->CR1 |= TIM_CR1_CEN;starts the counter from the actual value of the CNT register, and
TIMx->CR1 &= ~TIM_CR1_CEN;freezes the value in CNT.
The register description says that CNT is a read-write register, so you can set it to 0 or any other value when you want that.
Unfortunately the HAL documentation lacks that level of detail, so if you want to see exactly what they are doing, you have to reverse-engineer the HAL functions, which might be a lot more effort than following the step-by-step instructions in the reference manual.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.