Timers and Counters



Timer means which can give the delay of particular time between some events. For example on or off the lights after every 2 sec. This delay can be provided through some assembly program but in microcontroller two hardware pins are available for delay generation. These hardware pins can be also used for counting some external events. How much times a number is repeated in the given table is calculated by the counter.

In MC8051, two timer pins are available T0 and T1, by these timers we cangive the delay of particular time if we use these in timer mode.

We can count external pulses at these pins if we use these pins in countermode.

16 bits timers are available. Means we can generate delay between 0000Hto FFFFH.

Two special function registers are available.


If we want to load T0 with 16 bit data then we can load separate lower 8 bitin TL0 and higher 8 bit in TH0.

In the same way for T1.

TMOD, TCON registers are used for controlling timer operation.

Serial Port

There are two pins available for serial communication TXD and RXD.

Normally TXD is used for transmitting serial data which is in SBUF register,RXD is used for receiving the serial data.

SCON register is used for controlling the operation.

There are four modes of serial communication which has been discussed innext chapter.

Input Output Ports

There are four input output ports available P0, P1, P2, P3.

Each port is 8 bit wide and has special function register P0, P1, P2, P3which are bit addressable means each bit can be set or reset by the Bit instructions (SETB for high, CLR for low) independently.

The data at any port which is transmitting or receiving is in these registers.

The port 0 can perform dual works. It is also used as Lower order addressbus (A0 to A7) multiplexed with 8 bit data bus P0.0 to P0.7 is AD0 to AD7 respectively the address bus and data bus is demultiplex by the ALE signal and latch which is further discussed in details.

Port 2 can be used as I/O port as well as higher order address bus A8 toA15.

Port 3 also have dual functions it can be worked as I/O as well as each pin of P3 has specific function.

Serial I / P for Asynchronous communication Serial O / P for synchronous communication.


Uploaded Mon, 18-Jan-2021
Related Articles

Lesson meta keywords and meta description:



Bootstrap Example