0% found this document useful (0 votes)
12 views5 pages

6) B-1

The document discusses the timers and counters in the 8051 microcontroller, specifically Timer 0 and Timer 1, which are 16-bit timers divided into two 8-bit registers. It explains the functions of Timer Control Registers TCON and TMOD, which are essential for controlling the timers and counters' operations. The TCON register manages the start/stop of timers and overflow flags, while the TMOD register sets the modes of operation for the timers and counters.

Uploaded by

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

6) B-1

The document discusses the timers and counters in the 8051 microcontroller, specifically Timer 0 and Timer 1, which are 16-bit timers divided into two 8-bit registers. It explains the functions of Timer Control Registers TCON and TMOD, which are essential for controlling the timers and counters' operations. The TCON register manages the start/stop of timers and overflow flags, while the TMOD register sets the modes of operation for the timers and counters.

Uploaded by

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

Timers and counters are one of the best feature that is provided by microcontrollers.

Timers are
used to measure the time and for creating time delays . Counters are used to count the events
or tasks that are taking place outside the microcontrollers. We can setup these timers and
counters with the microcontrollers to make our tasks in different ways to fit in different
tasks.Types of 8051 Timers and Counters
The 8051 microcontroller mainly has two timers , Timer 0 and Timer 1. These are used as both
timers as well as counters. They are 16-bit long but the format of the microcontroller is 8-bit, due
to that the Timers or counters are divided into two 8-bit parts: a low byte and a high byte. Let’s
see one by one,

What is Timer 0 (T0) ?


Timer 0 is one of the main timers/counters in the 8051 microcontroller, used for doing timing
operations and counting events. It is divided into two 8-bit registers they are TL0 (Timer 0 Low
byte) and TH0 (Timer 0 High byte). By combining both, these form a 16-bit timer/counter.

TL0 (Timer 0 Low Byte)

●​ TL0 is the lower 8-bit register of Timer 0.It stores the lower byte of the count value.When
timer 0 functions as a 16-bit timer, TL0 increases first, and TH0 increases by one
following an overflow (when 255 is achieved).
TH0 (Timer 0 High Byte)

●​ TH0 is the upper 8-bit register of Timer 0.It stores the higher byte of the count
value.When TL0 overflows, Timer 0 can count up to 65,535 (FFFFH) before spilling
since TH0 is increased.

Structure of Timer 0:
Timer Control Registers-TCON and TMOD
TCON and TMOD are the special function registers in the 8051 microcontroller. These are used
to control the timers and counters.

TCON (Timer Control Register):


●​ The timers' start and stop are aided by this register. It additionally indicates whether the
timer is done counting.
TMOD (Timer Mode Register):
●​ The timers' mode is adjusted using this register. It selects whether the timers will record
events occurring outside of the microcontroller or record time.

●​ So, to make the timers and counters work, you need to set up TCON and TMOD
properly. In this way, you can use the timers to measure time or count events, depending
on what you need for your task.

TCON (Timer Control Register):


●​ The 8051 microcontroller has a unique function register called the TCON (Timer Control
Register). In order to provide precise output, timers and counters are controlled by it.
The data in the registers may overflow if these timers and counters are not under control.
Thus, the TCON is utilized to control the timers and counters. The structure in detail is
displayed below.

Structure of TCON:

The TCON register is an 8-bit register, where each bit has a specific function:

Here's what each bit represents:

7–TF1 (Timer 1 Overflow Flag)-Set to 1 when Timer 1 overflows else 0.

6–TR1 (Timer 1 Run Control Bit)-Set to 1 to start Timer 1, and set to 0 to stop Timer 1.

5–TF0 (Timer 0 Overflow Flag)-Set to 1 when Timer 0 overflows else 0.

4–TR0 (Timer 0 Run Control Bit)-Set to 1 to start Timer 0, and set to 0 to stop Timer 0.

3–IE1 (Interrupt 1 Edge Flag)-Set to 1 when an external interrupt 1 occurs else 0.


2–IT1 (Interrupt 1 Type Control Bit)-Set to 1 to configure external interrupt 1 as edge-triggered,
and set to 0 for level-triggered.

1–IE0 (Interrupt 0 Edge Flag)-Set to 1 when an external interrupt 0 occurs else 0.

0–IT0 (Interrupt 0 Type Control Bit)-Set to 1 to configure external interrupt 0 as edge-triggered,


and set to 0 for level-triggered.

TMOD (Timer Mode Register):

●​ The TMOD (Timer Mode Register) is a special function register in the 8051
microcontroller. Timer 0 and Timer 1 are the modes of operation that it is utilized to set.
Whether a timer or counter needs to be set, it is done so using this register. The
structure in detail is displayed below.

Structure of TMOD Register:


●​ The eight bits of the TMOD register are split into two sections: Timer 0 is controlled by
the lower four bits, and Timer 1 is controlled by the upper four bits. Similar bit fields in
each component set the timers' mode and behavior.
Here's what each bit represents:

7 or 3(Gate (0 or 1)-Gate Control Bit)

6 or 2(C/Tx-Counter/Timer Select Bit)

5 or 1(TxM1-Timer Select Bits for Mode1)

4 or 0(TxM0-Timer Select Bits for Mode0)

You might also like