You are on page 1of 5

16-bit Timer/Counter1

Timer 1 is 16 bit, that is, it can count from 0 to 2^{16} = 65536. Two Independent Output Compare
Units, OCR1A,and OCR1B,One Input Capture Unit ICR1, i/p clock with prescaler, external event
counter, 16 operating modes include normal ctc and PWM, and Four Independent Interrupt Sources
(TOV1, OCF1A, OCF1B, and ICF1) in the TIFR register
TCCR1A – Timer/Counter1 Control Register A
TCCR1B – Timer/Counter1 Control Register B
TCNT1H and TCNT1L –Timer/Counter1 High and Low Register
OCR1AH and OCR1AL – Output Compare Register A
OCR1BH and OCR1BL – Output Compare Register B
ICR1H and ICR1L – Input Capture Register 1
TIMSK – Timer/Counter Interrupt Mask Register
TIFR – Timer/Counter Interrupt Flag Register
TCCR1A

Bit 7:6 – COM1A1:0: Compare Output Mode for Channel A


Bit 5:4 – COM1B1:0: Compare Output Mode for Channel B
Bit 3 – FOC1A: Force Output Compare for Channel A
Bit 2 – FOC1B: Force Output Compare for Channel B
Bit 1:0 – WGM11:0: Waveform Generation Mode
TCCR1B

Bit 7 – ICNC1: Input Capture Noise Canceller


Bit 6 – ICES1: Input Capture Edge Select
Bit 5 – Reserved Bit
Bit 4:3 – WGM13:2: Waveform Generation Mode
Bit 2:0 – CS12:0: Clock Select
TIMSK Register

Commonregister for all the timers. Enable or disable timer interrupts.


TIFR Register
Commonregister for all the timers. TOV1 sets when TCNT1 overflows from 0xFFFF to 0000. OCF1 is set
when TCNT1 matches with OCR1A, OCF1B,likewise. Upon detection of a defined event i.e. rising edge
or falling edge on ICP pin (PORTD.6), TCNT1(Timer / Counter register) value is loaded into the ICR1
(input capture) register and the ICF1 flag will get set.
All 16-bit registers have can only be accessed one byte at a time. To ensure precise timing, a 16-bit
temporary register is used when accessing the timer registers.
Write:
When writing the high byte (e.g. TCNT1H), the data is placed in the TEMP register. When the low byte is
written, the data is transferred to the actual registers simultaneously. So the high byte must be written
first to perform a true 16-bit write.
Read:
When reading the low byte, the high byte is read from TCNT1 simultaneously and can be read afterwards.
So when reading, access the low byte first for a true 16-bit read.
Example: Generate 1Hz onPC.4 system clock 8MHz

You might also like