P
P
Pavel K2018-05-28 04:06:56
Microcontrollers
Pavel K, 2018-05-28 04:06:56

How to get the value of the CNT register of the timer if master/slave reset mode is used?

Greetings!
There is a task - counting the number of impulses per unit of time.
I did this:
the TIM3 timer counts the time, generates an interrupt when it overflows, in the interrupt I check how much TIM2 counted through the CNT register
, the TIM2 timer is set to external clocking from the foot (it counts these pulses), while it is a slave of TIM3 and when TIM3 overflows it is reset ( reset mode).
The problem is that when TIM3 overflows, the CNT counter of TIM2 is also reset and, of course, I always get 0 in the interrupt.
Question: how to set it up correctly so that I can read the CNT value in the interrupt?
PS Yes, you can not configure TIM2 as a slave and reset the counter manually, but I want all this to be done automatically.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Ocelot, 2018-05-28
@Ocelot

As an option, set TIM3 to coincidentally interrupt (somewhere at 90% of the maximum), in this interrupt, read the value of TIM2. And reset TIM2 on TIM3 overflow.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question