{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Timers and counters - Timers and counters What is it A...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Timers and counters
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
What is it? A counter Some logic to perform comparisons Add 1 to count Trigger / Clock source Count value
Background image of page 2
Main system timer 16 bit (value) timer counter Uses registers to determine behaviour Several options for the clock source. Can be used to generate output waveforms Provides 4 selectable interrupts Can be used for input capture. Pages 106 – 134 in datasheet
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Input capture Captures the timer counter value when selected events occur. TCCR1B contains the flag to indicate rising or falling edge. Common usage is to measure the duration of a pulse. Example shows start of pulse at 0x0100 and end at 0x8000. The duration is 0x7F00 pulses. TCNT1 TCNT1= 0x0100 TCNT1= 0x8000 PD0
Background image of page 4
Tricky bits Timer can count 0x0000 to 0xFFFF then wraps. If pulse is guaranteed to be shorter there is the possibility of overlapping the overflow. The true duration is trailing edge +(0xFFFF- leading edge) If the duration is more than 0xFFFF then the timer overflow must be
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}