Answer the question
In order to leave comments, you need to log in
How to properly set up a 32-bit timer?
How to set a timer to fire N * 3 * 10^(-6) seconds? I did this: the clock frequency of my MK is 48 MHz, which means that 48,000,000 ticks occur in 1 second, then about 155 ticks should pass in 3 * 10 (-6). Multiply by the number of seconds that we go to wait and put this number in the match value and, in theory, everything is ok. In this case, I bypass the prescaler setting, leaving it equal to one.
Something didn't work. Is the error in the method or in something else? How about a prescaler?
Answer the question
In order to leave comments, you need to log in
MK was engaged in nuuu for a very long time ... do not scold)))
Purely for interest ...
Datashit to the studio. What MK are you on?
Is the timer supposed to be accurate to 1.5 microseconds? )))
I think that MK should be with an internal generator? Otherwise, there may be errors.
Check. I got 144 ticks, not 155. If I understood correctly what you mean. On what cycle will the counter count 3 * 10^(-6) seconds.
48MHz multiplied by 3 * 10^(-6).
or
3 * 10^(-6) divided by (1 divided by 48MHz).
But then there are different solutions:
1. I counted every 144th cycle from the first counter as another counter and when A*144=N. When the second counter counts N, then it's time. This is if you need to withstand more than 90 seconds.
2. But our counter will withstand 4294967296 cycles (I hope I didn’t lie), those 89 seconds. Immediately multiply N * 144 = you will get the value of the first counter.
3. There you can come up with a lot of things by examining the number 144. Some kind of binary transformation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question