0% found this document useful (0 votes)
74 views3 pages

Timers and Counters in 8051

The 8051 microcontroller features two 16-bit timers/counters, Timer 0 and Timer 1, which can be configured using the TMOD and TCON special function registers. TMOD allows selection of timer/counter modes and operations, while TCON controls the timer operations and interrupt flags. The timers can operate in various modes, including 13-bit, 16-bit, 8-bit auto reload, and split-timer modes.

Uploaded by

charanksyadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views3 pages

Timers and Counters in 8051

The 8051 microcontroller features two 16-bit timers/counters, Timer 0 and Timer 1, which can be configured using the TMOD and TCON special function registers. TMOD allows selection of timer/counter modes and operations, while TCON controls the timer operations and interrupt flags. The timers can operate in various modes, including 13-bit, 16-bit, 8-bit auto reload, and split-timer modes.

Uploaded by

charanksyadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Timers and Counters in 8051

There are two 16-bit timers and counters in 8051 microcontroller: timer 0 and timer 1. Both
timers consist of 16-bit register in which the lower byte is stored in TL and the higher byte is
stored in TH. Timer can be used as a counter as well as for timing operation that depends on
the source of clock pulses to counters.

Timers and counters

Counters and Timers in 8051 microcontroller contain two special function registers: TMOD
(Timer Mode Register) and TCON (Timer Control Register), which are used for activating and
configuring timers and counters.
Timer Mode Control (TMOD): TMOD is an 8-bit register used for selecting timer or counter and
mode of timers. Lower 4-bits are used for control operation of timer 0 or counter0, and
remaining 4-bits are used for control operation of timer1 or counter1.This register is present in
SFR register, the address for SFR register is 89th.

Timer Mode Control (TMOD)


Gate: If the gate bit is set to ‘0’, then we can start and stop the “software” timer in the same
way. If the gate is set to ‘1’, then we can perform hardware timer.
C/T: If the C/T bit is ‘1’, then it is acting as a counter mode, and similarly when set C+
=/T bit is ‘0’; it is acting as a timer mode.
Mode select bits: The M1 and M0 are mode select bits, which are used to select the timer
operations. There are four modes to operate the timers.
Mode 0: This is a 13-bit mode that means the timer operation completes with “8192” pulses.
Mode 1: This is a16-bit mode, which means the timer operation completes with maximum clock
pulses that “65535”.
Mode 2: This mode is an 8-bit auto reload mode, which means the timer operation completes
with only “256” clock pulses.
Mode 3: This mode is a split-timer mode, which means the loading values in T0 and
automatically starts the T1.

Mode Selection Bits

Timer Control Register (TCON)

TCON is another register used to control operations of counter and timers in microcontrollers.
It is an 8-bit register wherein four upper bits are responsible for timers and counters and lower
bits are responsible for interrupts.

Timer Control Register (TCON)

TF1: The TF1 stands for ‘timer1’ flag bit. Whenever calculating the time-delay in timer1, the TH1
and TL1 reaches to the maximum value that is “FFFF” automatically.
EX: while (TF1==1) Whenever the TF1=1, then clear the flag bit and stop the timer.

TR1: The TR1 stands for timer1 start or stop bit. This timer starting can be through software
instruction or through hardware method.
EX: gate=0 (start timer 1 through software instruction)
TR1=1; (Start timer)

TF0: The TF0 stands for ‘timer0’ flag-bit. Whenever calculating the time delay in timer1, the TH0
and TL0 reaches to a maximum value that is ‘FFFF’, automatically.
EX: while (TF0==1)
Whenever the TF0=1, then clear the flag bit and stop the timer.

TR0: The TR0 stands for ‘timer0’ start or stop bit; this timer starting can be through software
instruction or through hardware method.
EX: gate=0 (start timer 1 through software instruction)
TR0=1; (Start timer)

You might also like