Skip to main content
Wleon.1
Associate III
March 4, 2020
Question

reset TIMx_CNT

  • March 4, 2020
  • 3 replies
  • 852 views

Hi, does

htim4.Instance->CNT = 0 

resets the counter value in TIM4_CNT ?

Does it guarantee atomicity ?

Thanks in advance!

This topic has been closed for replies.

3 replies

dbgarasiya
Senior
March 4, 2020

yes sure

dbgarasiya
Senior
March 4, 2020

but will start again timer automatically

if you have to reset timer then use

TIMx->CR1 = !(TIM_CR1_CEN); will stop timer permanently

Piranha
Principal III
March 7, 2020

That code is wrong. Effectively it will translate to:

TIMx->CR1 = 0;

What was meant, is:

TIMx->CR1 &= ~TIM_CR1_CEN;

dbgarasiya
Senior
March 4, 2020

Best of luck

Wleon.1
Wleon.1Author
Associate III
March 4, 2020

Thanks!