For 16Mhz clock source, the following configuration is used to create 0.5us tick:
I know that CS11 is an 8x prescale.
TCCR1A = 0;
TCCR1B = _BV(CS11);
TCCR1C = 0;
How can I keep 0.5us tick for an 8Mhz clock source?
Thanks!
For 16Mhz clock source, the following configuration is used to create 0.5us tick:
I know that CS11 is an 8x prescale.
TCCR1A = 0;
TCCR1B = _BV(CS11);
TCCR1C = 0;
How can I keep 0.5us tick for an 8Mhz clock source?
Thanks!
Everything you ever wanted to know about Arduino Timers
There is no prescale of 4 so you have to use a prescale of 1 (Set only CS10) and divide the elapsed time by 4 after you capture the value. If the 8 MHz clock rate is too fast and your timer overflows, use the timer overflow interrupt to increment a byte. That will extend your 16-bit timer to 24 bits.
In the input capture interrupt handler, if the timer count value is small and the Overflow flag is set there is a pending overflow interrupt so add 1 to the overflow count when you use it.
The direct answer is, you can't. Prescalers only come in a few flavours and after 1 there's 8. The real question is, what do you want to do with a 0.5us tick? There are other ways.
Thanks for your information!
Your answers are helpful!