Professional Documents
Culture Documents
Timer
• It is a specialized type of clock which is used to measure time
intervals.
• A timer that counts from zero upwards for measuring time
elapsed is often called a stopwatch.
• It is a device that counts down from a specified time interval and
used to generate a time delay timer.
Counter
• A counter is a device that stores (and sometimes displays) the
number of times a particular event or process occurred, with
respect to a clock signal.
• It is used to count the events happening outside the
microcontroller..
• The 8051 has two counters/timers which can be used
either as timer to generate a time delay or as counter to
count events happening outside the microcontroller.
Timer Counter
The register incremented for every The register is incremented considering 1
machine cycle. to 0 transition at its corresponding to an
external input
Maximum count rate is 1/12 of the Maximum count rate is 1/24 of the
oscillator frequency. oscillator frequency.
A timer uses the frequency of the A counter uses an external signal to
internal clock and generates delay. count pulses.
TMOD (timer mode) Register: This is an 8-bit register which is used by both Timer 0 and 1
to set the various timer modes.
GATE:
1 = Enable Timer/Counter only when the INT0/INT1 pin is high and TR0/TR1 is set.
0 = Enable Timer/Counter when TR0/TR1 is set.
M1 M0 Mode Operation
0 0 • 0 (13-bit timer mode) ✓ 13-bit timer/counter, 8-bit of THx & 5-bit of TLx
0 1 • 1 (16-bit timer mode) ✓ 16-bit timer/counter, THx cascaded with TLx
✓ 8-bit timer/counter (auto reload mode),
• 2 (8-bit auto reload
1 0 ✓ TLx reload with value held by THx
mode)
✓ each time TLx overflow
✓ Split 16-bit timer into two 8-bit timer i.e.
1 1 • 3 (split timer mode)
✓ THx and TLx like two 8-bit timer
TCON Register : TCON is 8-bit control register and contains timer and interrupt flags.