For this tutorial I have decided to add this Piconomic development board. You can purchase the board if you are from a South Africa.
Otherwise you can build this board by yourself. Piconomic allow to build a development board for non commercial personal use using their Protel 99 SE project files. Download Schematic to view it.
So I made one and now it is good chance to do some C programming by using it.
AVR 16 bit timer is more advanced timer than 8 bit timer.It has more features and this allows more accurate program execution timing. 16 bit timer is used when precise signal generation or signal timing measurement needed. As 8 bit timer counter can calculate up to 225 counts the 16 bit timer counter maximum value may reach 65535. In AVR microcontrollers 16 bit timer is Timer1. It contains a 16 bit input capture register (ICR1) and two 16 bit output compare registers (OCR1A and OCR1B). Of course the timer counters register (TCNT1) which is 16 bit long. When programming is ASM language there is special procedure for accessing it (refer to datasheet). While in C language it is done automatically we won’t get to deep into this. Timer1 is controlled by two timer counter control registers (TCCR1A/B). Signals are visible at timer interrupt flag register (TIFR) and interrupts can be individually masked in timer interrupt mask register (TIMSK).
Overflow and Compare Match Interrupt Sources (TOV2 and OCF2)
Allows Clocking from External 32 kHz Watch Crystal Independent of the I/O Clock
So we have there another register included OCR2, which is used to compare timer counter register TCNT2 register value and react on compare match. Wee see that there is Auto-reload ability what means that timer can be cleared automatically on compare match.