[go: up one dir, main page]

0% found this document useful (0 votes)
34 views21 pages

Unit 3 Introduction To 8051 Microcontroller

The 8051 microcontroller, introduced by Intel in 1981, is a widely used 8-bit microcontroller known for its applications in embedded systems, automotive, medical devices, and consumer electronics. It features 4KB of on-chip program memory, 128 bytes of data memory, and various I/O ports, making it suitable for diverse applications. The microcontroller's architecture includes a CPU, RAM, ROM, and a 40-pin package for interfacing with external devices.

Uploaded by

shkzishan810
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)
34 views21 pages

Unit 3 Introduction To 8051 Microcontroller

The 8051 microcontroller, introduced by Intel in 1981, is a widely used 8-bit microcontroller known for its applications in embedded systems, automotive, medical devices, and consumer electronics. It features 4KB of on-chip program memory, 128 bytes of data memory, and various I/O ports, making it suitable for diverse applications. The microcontroller's architecture includes a CPU, RAM, ROM, and a 40-pin package for interfacing with external devices.

Uploaded by

shkzishan810
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/ 21

Introduction to 8051 Microcontroller

8051 is one of the first and most popular microcontrollers also known as MCS-51. Intel
introduced it in the year 1981. Initially, it came out as an N-type metal-oxide-semiconductor
(NMOS) based microcontroller, but later versions were based on complementary metal-
oxide-semiconductor(CMOS) technology. These microcontrollers were named 80C51, where
C in the name tells that it is based on CMOS technology. It is an 8-bit microcontroller which
means the data bus is 8-bit. Therefore, it can process 8 bits at a time. It is used in a wide
variety of embedded systems like robotics, remote controls, the automotive industry, telecom
applications, power tools, etc.

Features of 8051 Microcontroller

An 8051 microcontroller comes bundled with the following features −

 4KB bytes on-chip program memory (ROM)


 128 bytes on-chip data memory (RAM)
 Four register banks
 128 user defined software flags
 8-bit bidirectional data bus
 16-bit unidirectional address bus
 32 general purpose registers each of 8-bit
 16 bit Timers (usually 2, but may have more or less)
 Three internal and two external Interrupts
 Four 8-bit ports,(short model have two 8-bit ports)
 16-bit program counter and data pointer
 8051 may also have a number of special features such as UARTs, ADC, Op-amp, etc.

Application of 8051 Microcontroller


 Automation: The 8051 microcontroller is widely used in automotive applications.
They are widely used in hybrid vehicles to control engine options. In addition, functions
such as cruise control and anti-brake mechanism have been further enhanced thanks to
the integration of a microcontroller.
 Medical Devices: Convenient medical devices such as blood glucose and blood pressure
monitors contain microcontrollers that display measurements.
 Energy management: Competent measurement systems support energy consumption
calculations in home and industrial environments. These measuring systems are prepared
by integrating a microcontroller.
 Touch Screen: Many microcontroller vendors incorporate touch functionality into their
designs. Portable devices such as media players, and gaming devices.

Uses of 8051 Microcontroller:


Here are some of the most common uses of the 8051 microcontroller:
 Embedded Systems: The 8051 microcontroller is commonly used in embedded systems,
such as home automation systems, security systems, and industrial control systems. Its
low cost, small size, and ease of programming make it an ideal choice for these
applications.
 Automotive Systems: The 8051 microcontroller is used in automotive systems, such as
engine control units, anti-lock braking systems, and airbag systems, to control various
functions and ensure safe and efficient operation.
 Robotics: The 8051 microcontroller is used in robotics applications to control the
movement and operation of robots. It is commonly used to control the motors, sensors,
and other peripherals of the robot.
 Consumer Electronics: The 8051 microcontroller is used in a variety of consumer
electronics products, such as digital cameras, gaming systems, and audio players. It is
commonly used to control the user interface, display, and other peripherals of these
devices.
 Communication Systems: The 8051 microcontroller is used in communication systems,
such as modems, routers, and switches, to control the data transfer and communication
protocols.
 Medical Devices: The 8051 microcontroller is used in medical devices, such as insulin
pumps, heart monitors, and blood glucose meters, to control various functions and
provide accurate and reliable results.
 Industrial Control Systems: The 8051 microcontroller is used in industrial control
systems, such as process control systems and manufacturing equipment, to control and
monitor various processes and operations.
Block Diagram of 8051 Microcontroller

The following illustration shows the block diagram of an 8051 microcontroller −

Pin diagram of 8051 Microcontroller


The 8051 microcontroller is a popular 8-bit microcontroller widely used in embedded
systems. It is a single-chip microcontroller with a Harvard architecture that includes a CPU,
RAM, ROM, and several peripherals. The 8051 microcontroller has a 40-pin dual in-line
package (DIP) that provides various inputs and outputs for communication with external
devices.

8051 microcontroller is a 40 pin Dual Inline Package (DIP). These 40 pins serve different
functions like read, write, I/O operations, interrupts etc. 8051 has four I/O ports wherein each
port has 8 pins which can be configured as input or output depending upon the logic state of
the pins. Therefore, 32 out of these 40 pins are dedicated to I/O ports. The rest of the pins are
dedicated to VCC, GND, XTAL1, XTAL2, RST, ALE, EA’ and PSEN’.
Description of the Pins :
 Pin 1 to Pin 8 (Port 1) – Pin 1 to Pin 8 are assigned to Port 1 for simple I/O operations.
They can be configured as input or output pins depending on the logic control i.e. if logic
zero (0) is applied to the I/O port it will act as an output pin and if logic one (1) is applied
the pin will act as an input pin. These pins are also referred to as P1.0 to P1.7 (where P1
indicates that it is a pin in port 1 and the number after ‘.’ tells the pin number i.e. 0
indicates first pin of the port. So, P1.0 means first pin of port 1, P1.1 means second pin
of the port 1 and so on). These pins are bidirectional pins.
 Pin 9 (RST) – Reset pin. It is an active-high, input pin. Therefore if the RST pin is high
for a minimum of 2 machine cycles, the microcontroller will reset i.e. it will close and
terminate all activities. It is often referred as “power-on-reset” pin because it is used to
reset the microcontroller to it’s initial values when power is on (high).
 Pin 10 to Pin 17 (Port 3) – Pin 10 to pin 17 are port 3 pins which are also referred to as
P3.0 to P3.7. These pins are similar to port 1 and can be used as universal input or output
pins. These pins are bidirectional pins. These pins also have some additional functions
which are as follows:
o P3.0 (RXD) : 10th pin is RXD (serial data receive pin) which is for serial
input. Through this input signal microcontroller receives data for serial
communication.
o P3.1 (TXD) : 11th pin is TXD (serial data transmit pin) which is serial output
pin. Through this output signal microcontroller transmits data for serial
communication.
o P3.2 and P3.3 (INT0′, INT1′ ) : 12th and 13th pins are for External Hardware
Interrupt 0 and Interrupt 1 respectively. When this interrupt is activated(i.e.
when it is low), 8051 gets interrupted in whatever it is doing and jumps to the
vector value of the interrupt (0003H for INT0 and 0013H for INT1) and starts
performing Interrupt Service Routine (ISR) from that vector location.
o P3.4 and P3.5 (T0 and T1) : 14th and 15th pin are for Timer 0 and Timer 1
external input. They can be connected with 16 bit timer/counter.
o P3.6 (WR’) : 16th pin is for external memory write i.e. writing data to the
external memory.
o P3.7 (RD’) : 17th pin is for external memory read i.e. reading data from
external memory.
 Pin 18 and Pin 19 (XTAL2 And XTAL1) – These pins are connected to an external
oscillator which is generally a quartz crystal oscillator. They are used to provide an
external clock frequency of 4MHz to 30MHz.
 Pin 20 (GND) – This pin is connected to the ground. It has to be provided with 0V power
supply. Hence it is connected to the negative terminal of the power supply.
 Pin 21 to Pin 28 (Port 2) – Pin 21 to pin 28 are port 2 pins also referred to as P2.0 to
P2.7. When additional external memory is interfaced with the 8051 microcontroller, pins
of port 2 act as higher-order address bytes. These pins are bidirectional.
 Pin 29 (PSEN) – PSEN stands for Program Store Enable. It is output, active-low pin.
This is used to read external memory. In 8031 based system where external ROM holds
the program code, this pin is connected to the OE pin of the ROM.
 Pin 30 (ALE/ PROG) – ALE stands for Address Latch Enable. It is input, active-high
pin. This pin is used to distinguish between memory chips when multiple memory chips
are used. It is also used to de-multiplex the multiplexed address and data signals available
at port 0. During flash programming i.e. Programming of EPROM, this pin acts as
program pulse input (PROG).
 Pin 31 (EA/ VPP) – EA stands for External Access input. It is used to enable/disable
external memory interfacing. In 8051, EA is connected to Vcc as it comes with on-chip
ROM to store programs. For other family members such as 8031 and 8032 in which there
is no on-chip ROM, the EA pin is connected to the GND.
 Pin 32 to Pin 39 (Port 0) – Pin 32 to pin 39 are port 0 pins also referred to as P0.0 to
P0.7. They are bidirectional input/output pins. They don’t have any internal pull-ups.
Hence, 10 K? pull-up registers are used as external pull-ups. Port 0 is also designated as
AD0-AD7 because 8051 multiplexes address and data through port 0 to save pins.

 Pin 40 (VCC) – This pin provides power supply voltage i.e. +5 Volts to the circuit.
The pin diagram of the 8051 microcontroller is as follows:
1. VCC: This pin is connected to the power supply and provides a voltage of +5V to the
microcontroller.
2. GND: This pin is connected to the ground and serves as the reference voltage for the
microcontroller.
3. XTAL1 and XTAL2: These pins are used for connecting an external crystal oscillator
that provides the clock signal for the microcontroller.
4. Reset: This pin is used for resetting the microcontroller. A high pulse on this pin resets
the microcontroller to its initial state.
5. Port 1: This is an 8-bit bidirectional input/output port that can be used for interfacing
with external devices.
6. Port 2: This is an 8-bit bidirectional input/output port that can be used for interfacing
with external devices.
7. Port 3: This is an 8-bit bidirectional input/output port that can be used for interfacing
with external devices.
8. Port 4: This is an 8-bit bidirectional input/output port that can be used for interfacing
with external devices.
9. INT0: This is an external interrupt 0 input pin.
10. INT1: This is an external interrupt 1 input pin.
11. T0: This is an external timer 0 input pin.
12. T1: This is an external timer 1 input pin.
13. WR: This is the write signal for external memory.
14. RD: This is the read signal for external memory.
15. ALE: This is the address latch enable signal that is used to latch the address for external
memory.
16. PSEN: This is the program store enable signal that is used for accessing the program
memory.
17. 17-24. Address bus: These pins are used for transmitting the address information to the
external memory.
18. 25-32. Data bus: These pins are used for transmitting the data between the
microcontroller and external memory.
19. RST: This is the output signal that indicates the microcontroller is being reset.
20. EA: This is the external access enable signal that is used for selecting the program
memory.
21. VPP: This pin is used for programming the microcontroller.
22. 36-39. XTAL: These pins are used for connecting an external crystal oscillator.
23. P1.0 (AD0) – P1.7 (AD7): These pins are used for interfacing with external analog
devices.
Storage Registers in 8051

Following types of storage registers here −

 Accumulator
 R register
 B register
 Data Pointer (DPTR)
 Program Counter (PC)
 Stack Pointer (SP)

Accumulator

The accumulator, register A, is used for all arithmetic and logic operations. If the accumulator
is not present, then every result of each calculation (addition, multiplication, shift, etc.) is to be
stored into the main memory. Access to main memory is slower than access to a register like
the accumulator because the technology used for the large main memory is slower (but cheaper)
than that used for a register.

The "R" Registers

The "R" registers are a set of eight registers, namely, R0, R1 to R7. These registers function as
auxiliary or temporary storage registers in many operations. Consider an example of the sum
of 10 and 20. Store a variable 10 in an accumulator and another variable 20 in, say, register R4.
To process the addition operation, execute the following command −

ADD A,R4

After executing this instruction, the accumulator will contain the value 30. Thus "R" registers
are very important auxiliary or helper registers. The Accumulator alone would not be very
useful if it were not for these "R" registers. The "R" registers are meant for temporarily storage
of values.

Let us take another example. We will add the values in R1 and R2 together and then subtract
the values of R3 and R4 from the result.

MOV A,R3 ;Move the value of R3 into the accumulator


ADD A,R4 ;Add the value of R4
MOV R5,A ;Store the resulting value temporarily in R5
MOV A,R1 ;Move the value of R1 into the accumulator
ADD A,R2 ;Add the value of R2
SUBB A,R5 ;Subtract the value of R5 (which now contains R3 + R4)

As you can see, we used R5 to temporarily hold the sum of R3 and R4. Of course, this is not
the most efficient way to calculate (R1 + R2) – (R3 + R4), but it does illustrate the use of the
"R" registers as a way to store values temporarily.

The "B" Register

The "B" register is very similar to the Accumulator in the sense that it may hold an 8-bit (1-
byte) value. The "B" register is used only by two 8051 instructions: MUL AB and DIV AB.
To quickly and easily multiply or divide A by another number, you may store the other number
in "B" and make use of these two instructions. Apart from using MUL and DIV instructions,
the "B" register is often used as yet another temporary storage register, much like a ninth R
register.
The Data Pointer

The Data Pointer (DPTR) is the 8051’s only user-accessible 16-bit (2-byte) register. The
Accumulator, R0–R7 registers and B register are 1-byte value registers. DPTR is meant for
pointing to data. It is used by the 8051 to access external memory using the address indicated
by DPTR. DPTR is the only 16-bit register available and is often used to store 2-byte values.

The Program Counter

The Program Counter (PC) is a 2-byte address which tells the 8051 where the next instruction
to execute can be found in the memory. PC starts at 0000h when the 8051 initializes and is
incremented every time after an instruction is executed. PC is not always incremented by 1.
Some instructions may require 2 or 3 bytes; in such cases, the PC will be incremented by 2 or
3.

Branch, jump, and interrupt operations load the Program Counter with an address other than
the next sequential location. Activating a power-on reset will cause all values in the register to
be lost. It means the value of the PC is 0 upon reset, forcing the CPU to fetch the first opcode
from the ROM location 0000. It means we must place the first byte of upcode in ROM location
0000 because that is where the CPU expects to find the first instruction.

The Stack Pointer (SP)

The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit (1-byte) value.
The Stack Pointer tells the location from where the next value is to be removed from the stack.
When a value is pushed onto the stack, the value of SP is incremented and then the value is
stored at the resulting memory location. When a value is popped off the stack, the value is
returned from the memory location indicated by SP, and then the value of SP is decremented.

This order of operation is important. SP will be initialized to 07h when the 8051 is initialized.
If a value is pushed onto the stack at the same time, the value will be stored in the internal
RAM address 08h because the 8051 will first increment the value of SP (from 07h to 08h) and
then will store the pushed value at that memory address (08h). SP is modified directly by the
8051 by six instructions: PUSH, POP, ACALL, LCALL, RET, and RETI.
8051 Flag Bits and PSW Register

The program status word (PSW) register is an 8-bit register, also known as flag register. It is
of 8-bit wide but only 6-bit of it is used. The two unused bits are user-defined flags. Four of
the flags are called conditional flags, which means that they indicate a condition which results
after an instruction is executed. These four are CY (Carry), AC (auxiliary carry), P (parity),
and OV (overflow). The bits RS0 and RS1 are used to change the bank registers. The following
figure shows the program status word register.

The PSW Register contains that status bits that reflect the current status of the CPU.

CY CA F0 RS1 RS0 OV - P

CY PSW.7 Carry Flag

AC PSW.6 Auxiliary Carry Flag

F0 PSW.5 Flag 0 available to user for general purpose.

RS1 PSW.4 Register Bank selector bit 1

RS0 PSW.3 Register Bank selector bit 0

OV PSW.2 Overflow Flag

- PSW.1 User definable FLAG

Parity FLAG. Set/ cleared by hardware during instruction cycle to indicate


P PSW.0
even/odd number of 1 bit in accumulator.
We can select the corresponding Register Bank bit using RS0 and RS1 bits.

RS1 RS2 Register Bank Address

0 0 0 00H-07H

0 1 1 08H-0FH

1 0 2 10H-17H

1 1 3 18H-1FH

 CY, the carry flag − This carry flag is set (1) whenever there is a carry out from the D7 bit. It
is affected after an 8-bit addition or subtraction operation. It can also be reset to 1 or 0 directly
by an instruction such as "SETB C" and "CLR C" where "SETB" stands for set bit carry and
"CLR" stands for clear carry.
 AC, auxiliary carry flag − If there is a carry from D3 and D4 during an ADD or SUB
operation, the AC bit is set; otherwise, it is cleared. It is used for the instruction to perform
binary coded decimal arithmetic.
 P, the parity flag − The parity flag represents the number of 1's in the accumulator register
only. If the A register contains odd number of 1's, then P = 1; and for even number of 1's, P =
0.
 OV, the overflow flag − This flag is set whenever the result of a signed number operation is
too large causing the high-order bit to overflow into the sign bit. It is used only to detect errors
in signed arithmetic operations.

8051 Timers and Counters


8051 microcontrollers are mainly used to speed up our tasks because they are very
easy to use and they are also fast to complete tasks easily. These microcontrollers
have one main feature which is Timers and counters. This feature is widely used
in microcontrollers to measure the time and as well as to count the events or tasks.
By learning about these timers and counters, we can make good embedded
systems. In this article let us see how these counters and timers work in
microcontrollers.

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 they are 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
Given below is the Structure of Timer 0.

What is Timer 1 (T1) ?


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

TL1 (Timer 1 Low Byte)


 Timer 1's bottom 8-bit register is designated as TL1.
 It contains the count value's bottom byte.
 When using a 16-bit timer, TL1 increases first and then TH1 by 1 once TL1
reaches its maximum value of 255.
TH1 (Timer 1 High Byte)
 Timer 1's upper 8-bit register is designated as TH1.
 It contains the count value's higher byte.
 When TL1 overflows, TH1 increments, allowing Timer 1 to count up to 65,535
(FFFFH) before overflowing.

Structure of Timer 1
Given below is the Structure of Timer 1.

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.
1. TCON (Timer Control Register): The timers' start and stop are aided by this
register. It additionally indicates whether the timer is done counting.
2. 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. Let's we see one by one,

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:
Bit Bit Name Description

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

TR1 (Timer 1 Run


6 Set to 1 to start Timer 1, and set to 0 to stop Timer 1.
Control Bit)

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

TR0 (Timer 0 Run


4 Set to 1 to start Timer 0, and set to 0 to stop Timer 0.
Control Bit)

IE1 (Interrupt 1 Edge


3 Set to 1 when an external interrupt 1 occurs else 0.
Flag)

IT1 (Interrupt 1 Type Set to 1 to configure external interrupt 1 as edge-triggered,


2
Control Bit) and set to 0 for level-triggered.

IE0 (Interrupt 0 Edge


1 Set to 1 when an external interrupt 0 occurs else 0.
Flag)

IT0 (Interrupt 0 Type Set to 1 to configure external interrupt 0 as edge-


0
Control Bit) 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:

Bit Bit Name Description

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

Let's see each bit's one by one,


1. GATE (Gate Control Bit): When set to 1, the timer/counter is enabled only
while the INT pin is high and TR control bit is set. When cleared to 0, the timer
is enabled whenever the TR control bit is set.
2. C/T (Counter/Timer Select Bit): When set to 1, the timer operates as a counter
(counts external events). When cleared to 0, it operates as a timer (measuring
time).
3. M1 and M0 (Mode Select Bits):

M0 M1 Mode Description

0 0 Mode 0 13-bit Timer mode (8 Bit of THx and 5 Bit of TLx).

0 1 Mode 1 16-bit Timer mode.

8-bit Auto-reload mode (TLx reload with the THx


1 0 Mode 2
value each time when TLx overflows).

Split Timer mode - Split 16 bit timer into two 8 bit


1 1 Mode 3
timers(THx and TLx).

Timer Modes
Mode 0: 13-bit Timer Mode
 Description: In Mode 0, 0 or 1 timer functions as a 13-bit timer. It counts from 0 to 8191
counts, or from 0000H to 1FFFH. It makes use of all eight bits of TH0 or TH1, and five
bits of TL0 or TL1.
 Working Principle: TLx counts in steps of 0 to 31, resets to 0, and then increases THx.
Out of the two timer bytes, only 13 bits are used.
 Usage: Because of the narrow count range of 8192 values, it is rarely utilized.
 Example: It is used for Generating Short Delays
The Block Diagram for Mode 0 is shown below.
Mode 1: 16-bit Timer Mode
 Description: Timer 0 and Timer 1 are set up as 16-bit timers in Mode 1. They use the
0000H to FFFFH count range (0 to 65535).
 Working Principle: TLx uses all 16 bits to count from 0 to 255, resets to 0, and then
increases THx.
 Usage: Because of its larger range of values, it is frequently utilized for a variety of timing
jobs.
 Example: It is used for Timing Events or Generating PWM Signals.
The Block Diagram for Mode 1 is shown below.

Counter Modes
Mode 2: 8-bit Auto-Reload Mode
 Description: The configuration of Timer 0 in Mode 2 is an 8-bit auto-reload timer. It
counts from 00H to FFH (0 to 255) and then loads the starting value automatically.
 Working Principle: TLx starts at 0 and increases to 255, but instead of returning to 0, it
reloads with the value from THx.
 Usage: Good for jobs like setting baud rates, when the timer needs to continuously reload
with a set value.
 Example: Used for Frequency Measurement.
The Block Diagram for Mode 2 is shown below.
Mode 3: Split Timer Mode
 Description: Timer 0 is divided into two 8-bit timers in Mode 3, which enables Timer 0
to function as two independent timers while Timer 1 continues to function as a 16-bit
timer as usual.
 Working Principle: Both timers separately count from 0 to 255, then overflow back to
0. The control bits of Timer 1 are connected to TH0.
 Usage: helpful when two independent timers are required.
 Example: Used in Real-time Clock with Alarm Functionality.
The Block Diagram for Mode 3 is shown below.

You might also like