0% found this document useful (0 votes)
9 views

microcontrol u 1B

The document provides an introduction to the 8051 microcontroller, detailing its history, architecture, and basic functionalities. It explains the components of the 8051, including its memory organization, I/O ports, and the significance of various pins. The 8051 microcontroller, developed by Intel in 1981, has become a foundational element in embedded systems due to its low power consumption and versatile applications.

Uploaded by

merir143
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)
9 views

microcontrol u 1B

The document provides an introduction to the 8051 microcontroller, detailing its history, architecture, and basic functionalities. It explains the components of the 8051, including its memory organization, I/O ports, and the significance of various pins. The 8051 microcontroller, developed by Intel in 1981, has become a foundational element in embedded systems due to its low power consumption and versatile applications.

Uploaded by

merir143
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/ 51

CHAPTER-1B

INTRODUCTION TO
MICROCONTROLLER

TECHNICAL AND VOCATIONAL TRAINING INSTITUTE


Department of Information technology
Fundamentals of microcontroller/microproccers
EETe 3032

By Tumay.T 1
Introduction to the 8051 Microcontroller
The 8051 microcontroller is a basic microcontroller, it is first introduced by the „Intel
Corporation‟ since 1970. It is developed by the 8086 processor architecture. The 8051 is a
family of the microcontroller, which has been developed by different manufactures such as
Philips, atmel, dalls, and so on. The 8051 microcontroller has
been used in lots of embedded products from small children‟s toys to large
automotive systems.

2
A brief history of the 8051

Originally, 8051 Microcontrollers were developed using N-MOS Technology but the use of
battery powered devices and their low power consumption lead to usage of CMOS Technology
(which is famous for its low power consumption).
Even though Intel developed 8051 Microcontrollers, more than 20 semiconductor manufacturers
are still producing 8051 compatible microcontrollers i.e. processors based on MSC-51
Architecture.
Some of the 8051 Microcontrollers produced by different manufacturers are: Atmel (AT89C51,
AT89S51), Phillips (S87C654), STC Micro (STC89C52), Infineon (SAB- C515, XC800),
Siemens (SAB-C501), Silicon Labs (C8051), NXP (NXP700, NXP900),
etc.
3
A brief history of the 8051 (Cont’d)
Majority of the modern 8051 Microcontrollers are Silicon IP Cores (Intellectual Property Cores) but
discrete 8051 Microcontroller IC‟s are also available. Because of their low power consumption,
smaller size and simple architecture, 8051 IP Cores are used in FPGAs (Field Programmable Gate
Array) and SoCs (System on Chip) instead of Advanced ARM Architecture based MCUs.
In 1981, Intel Corporation introduced an 8-bit microcontroller called the 8051. This
microcontroller had 128 bytes of RAM, 4K bytes of on-chip ROM, two timers, one serial port, and
four ports (each 8-bits wide) all on a single chip. At the time it was also referred to as a “system on a
chip.” The 8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a
time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU. The 8051
has a total of four I/O ports, each 8 bits wide. The 8051
can have a maximum of 64K bytes 4
8051 Microcontroller family
The microcontroller usually referred as 8051 has many variants from different
manufacturers

5
8051 Architecture

8051 is an 8 – bit Microcontroller i.e. the data bus of the 8051 Microcontroller (both internal
and external) is 8 – bit wide. It is a CISC based Microcontroller with Harvard Architecture
(separate program and data memory).
Since the basic layout of a microcontroller includes a CPU, ROM, RAM, etc. the 8051
microcontroller also has a similar layout. Irrespective of the manufacturer, the internal
hardware design i.e. the 8051 Microcontroller Architecture remains more or less the same.

6
8051 Architecture (Contd.)
The basic architecture of 8051 consists of:
• On-chip RAM: Random access memory of 128 byte is used for data storage in 8051. RAM is-
volatile memory consists of register banks, stacks for temporary data storage and some special
function registers.
• On-chip ROM: 8051 consists of 4KB ROM for program storage. ROM is a non-volatile
memory helps in permanent data storage.
• Timers and Counters: Timer helps in providing delay between the events. In 8051, there are
two timer pins T0, T1. If these pins are used in the counter mode, we can count the external
pulses. In T0, it is possible to store 16 bit data. This is done by storing the lower 8 bit in TL0
and the upper 8 bit in TH0. Similarly, we can store 16 bit
data in T1 also. TMOD and TCON helps in the timer operation. 9
8051 Architecture (Contd.)
• Serial Port: In order, to perform the serial communication, TXD and RXD pins are used. TXD pin is
used for transmitting the serial data and the RXD pin is used for the receiving of the data. SCON register
is used to control the operation of the serial communication.
• Input and Output Ports: P0, P1. P2. P3 form the four ports of 8051 microcontroller. Each of the port is
8 bit wide. Port P0 is used as a Lower Order Address bus. Port P2 can be used as I/O port and higher
order bus A8 to A15. Port P3 can be used as I/O pin and each pin of port 3 has special functions.
• Oscillator – This is used to provide clock to the 8051 microcontroller. The crystal frequency can vary
from 4MHz to 30MHz.
• Interrupts - Interrupts are requests which are used to handle special events or routines known
as Interrupt Service Routines. INT0 and INT1 are the basic interrupt pins used in 8051.

10
8051 Architecture (Contd.)
• Arithmetic Logic Unit - This unit is used for arithmetic calculations.
• Accumulator (A register) – This register is used for arithmetic operations.
• B register – This is an 8bit register that is bit addressable and is used for two instructions only
like MUL AB and DIV AB.
• Program Counter – is a 16 bit register that helps to access address from 0000H to FFFFH.
Program Counter is used to address the next instruction to be executed from the ROM.
• Flag Bits – The flag bits are used to indicate the arithmetic condition of the ACC. This register
consists of Six Flags like Carry Flag, Auxiliary Flag
Sign Flag, Parity Flag, Zero flag and Overflow flag.

11
Basics of 8051 Microcontroller
 The most famous type of microcontroller is 8051
 Architecture
– 3 system inputs
 Vcc power supply and ground
 Clock inputs (XTAL 1 and XTAL 2)
 Reset
– 3 control signals
 EA (External Access)
 PSEN (program store enable)
 ALE (Address latch enable)
– 4 ports
 Port 0, port 1, port 2 and port 3
 Each 8 bit is programmable for I/O

 Used to connect ADC, DAC, LED, 7 segment display etc 12


Basics of 8051 Microcontroller (cont’d)

13
Connection for standalone operation

14
8051 Microcontroller Basics

The microprocessor performs primarily four operations:


I. Memory Read: Reads data (or instruction) from memory.
II. Memory Write: Writes data (or instruction) into memory.
III. I/O Read: Accepts data from input device.
IV. I/O Write: Sends data to output device.
The 8051 processor performs these functions using address bus, data
bus and control bus as shown in Fig. (Slide 16).

15
8051 Bus structure

The block diagram of the 8051 Microcontroller Architecture shows that 8051
Microcontroller consists of a CPU, RAM (SFRs and Data Memory), Flash
(EEPROM), I/O Ports and control logic for communication between the
peripherals.
All these different peripherals inside the 8051 Microcontroller will
communicate with each other via the 8 – bit Data Bus, also known as the internal
data bus.

16
8051 Bus structure (Contd.)

Fig. The 8051 bus structure


8051 employs Harvard architecture. It has some peripherals such as 32 bit digital
I/O, Timers and Serial I/O.
17
Inside the 8051 Microcontroller Block Diagram
External interrupts
On-chip Timer/Counter

Interrupt ROM for


On-chip Timer 1 Counter
Control program
RAM Timer 0 Inputs
code

CPU

Bus Serial
4 I/O Ports
OSC Control Port

P0 P1 P2 P3 TxD RxD
Address/Data

The 8051 is the original member of the 8051 family. Intel refers to it as MCS-51.
8051 PIN DESCRIPTION
• Pin configuration
• 8051 MCU has 40 pins

• Is the functional assignment of pins of a microcontroller

• Some pins are dedicated pins, i.e. used for one purpose and others are
multiplexed (used for multiple functions)

• It can be used as a 4 i/o port standalone processor without external memory or can be
used with 16 bit address line for external memory and 8 bit data line for external data
access

19
8051 PIN DESCRIPTION (Contd.)

The logic pin layout and signal groups of the 8051 microcontroller is shown in Fig.
below. All the signals are classified into six groups:
Address bus
Data bus
Control & status signals
Power supply and frequency signals
Externally initiated signals
Serial I/O signals
The following image shows the 8051 Microcontroller Pin Diagram with respect to a
40 – pin Dual In-line Package (DIP).
20
40 – pin DIP

21
8051 PIN DESCRIPTION

22
8051 PIN DESCRIPTION (Contd.)

23
8051 Microcontroller Basic Circuit
We have seen the 8051 Microcontroller Pin Diagram and corresponding Pin Description, we
will proceed to the basic circuit or schematic of the 8051 Microcontroller. The following image
shows the basic circuit of the 8051 Microcontroller.

24
8051 Microcontroller Basic Circuit (Cont’d)
This basic circuit of 8051 microcontroller is the minimal interface required for it to work. The basic
circuit includes a Reset Circuit, the oscillator circuit and power supply.
First is the power supply. Pins 40 and 20 (VCC and GND) of the 8051 Microcontroller are
connected to +5V and GND respectively.
Next is the Reset Circuit. A logic HIGH (+5V) on Reset Pin for a minimum of two machine cycles (24
clock cycles) will reset the 8051 Microcontroller. The reset circuit of the 8051 Microcontroller
consists of a capacitor, a resistor and a push button and this type of reset circuit provides a Manual
Reset Option. If you remove the push button, then the reset circuit becomes a Power-On Reset Circuit.
The next part of the basic circuit of the 8051 Microcontroller is the Oscillator Circuit or the
Clock Circuit. A Quartz Crystal Oscillator is connected across XTAL1 and XTAL2 pins i.e.
Pins 19 and 18. The capacitors C1 and C2 can be selected in the range of 20pF to 2 45 0pF.
The basic setup of microcontroller
VCC and GND: - The pin 40 is Vcc i.e. it is given 5V and pin 20 is GND i.e. it is given 0V
(supplied from power source) for powering up the microcontroller.
CONNECTING THE CRYSTAL (XTAL1- XTAL2): The pin numbers 18 - 19 are used to
connect the crystal. The frequency of this crystal determines the machine cycle. With 8051
family we can use a crystal having frequency from 3 to 24 MHz.

26
Fig. Oscillator and Timing Circuitry
The basic setup of microcontroller (Contd.)

RESET PIN CONNECTION (RST): The reset pin i.e. pin number 9 is used to reset the
program just like we restart a computer, the program starts executing from the very beginning.
When reset is used the program counter is set back to zero and the values in all other registers
are lost.

Fig. RESET PIN CONNECTION (RST)


27
The basic setup of microcontroller (Contd.)
EA/VPP: The EA pin no. 31 is known as external access. The 8051 microcontrollers have on
chip ROM so the EA/VPP is set to one (or Vcc). In case there is no on- chip ROM, like in case
of 8031 we set this pin equal to zero. This pin cannot be left unconnected.
PSEN: This is an output pin. PSEN stands for “program store enable”. In 8051 we
leave this pin unconnected until otherwise mentioned.
ALE/PROG: ALE refers to address latch enable. In 8051 we leave this pin unconnected
until otherwise mentioned.

28
The basic setup of microcontroller

29
The basic setup of microcontroller (Contd.)

This is the basic setup of microcontroller that you need to have in order to perform
an 8051 activity. The pins ALE/ PROG, EA/ VPP and PSEN may have some
modifications.

30
The basic setup of microcontroller (Contd.)

31
The basic setup of microcontroller (Contd.)
This is a module that has been prepared by us. You can see that a 40 pin base has
been mounted on the PCB (printed circuit board) instead of directly soldering the
microcontroller to PCB which maybe damaged while soldering.

32
8051 Microcontroller Memory Organization
Hence, it is clear that the memory is an important part of the 8051 Microcontroller Architecture.
So, it is important for us to understand the 8051 Microcontroller Memory Organization i.e. how
memory is organized, how the processor accesses each memory and how to interface external
memory with 8051 Microcontroller. The 8051 Microcontroller Memory is separated in Program
Memory (ROM) and Data Memory (RAM). The Program Memory of the 8051
Microcontroller is used for storing the program to be executed i.e. instructions. The Data
Memory on the other hand, is used for storing temporary variable data and intermediate results.
8051 Microcontroller has both Internal ROM and Internal RAM. If the internal memory
is inadequate, you can add external memory using suitable circuits.

33
Program Memory (ROM) of 8051 Microcontroller
In 8051 Microcontroller, the code or instructions to be executed are stored in the Program Memory, which is also
called as the ROM of the Microcontroller. The original 8051 Microcontroller by Intel has 4KB of internal ROM.
Some variants of 8051 like the 8031 and 8032 series doesn‟t have any internal ROM (Program Memory) and must
be interfaced with external Program Memory with instructions loaded in it.
Almost all modern 8051 Microcontrollers, like 8052 Series, have 8KB of Internal Program Memory (ROM) in the
form of Flash Memory (ROM) and provide the option of reprogramming the memory.

34
Program Memory (ROM) of 8051 Microcontroller(Cont’d)
In case of 4KB of Internal ROM, the address space is 0000H to 0FFFH. If the address space i.e. the
program addresses exceed this value, then the CPU will automatically fetch the code from the
external Program Memory. For this, the External Access Pin (EA Pin) must be pulled HIGH i.e.
when the EA Pin is high, the CPU first fetches instructions from the Internal Program Memory in
the address range of 0000H to 0FFFFH and if the memory addresses exceed the limit, then the
instructions are fetched from the external ROM in the address range of 1000H to FFFFH.

35
Program Memory (ROM) of 8051 Microcontroller(Cont’d)

There is another way to fetch the instructions: ignore the Internal ROM and fetch all the
instructions only from the External Program Memory (External ROM). For this scenario, the
EA Pin must be connected to GND. In this case, the memory addresses of the external ROM
will be from 0000H to FFFFH.

36
Program Memory (ROM) of 8051 Microcontroller(Cont’d)

37
Data Memory (RAM) of 8051 Microcontroller

The Data Memory or RAM of the 8051 Microcontroller stores temporary data and intermediate
results that are generated and used during the normal operation of the microcontroller. Original
Intel‟s 8051 Microcontroller had 128B of internal RAM.
But almost all modern variants of 8051 Microcontroller have 256B of RAM. In this 256B, the
first 128B i.e. memory addresses from 00H to 7FH is divided in to Working Registers
(organized as Register Banks), Bit – Addressable Area and General Purpose RAM (also known
as Scratchpad area).
In the first 128B of RAM (from 00H to 7FH), the first 32B i.e. memory from addresses
00H to 1FH consists of 32 Working Registers that are organized as four banks with 8 Registers
in each Bank.
38
Data Memory (RAM) of 8051 Microcontroller
• Data memory

• This is the area used to store data to be used in a program

• Has 128byte internal memory and is capable of interfacing external memory

• The 128 byte internal memory is divided into three parts

• Register banks (bank #0,#1, #2, #3)

• Bit addressable area (used to store bit values such as status of motors, LEDS etc )

• General purpose storage area


• Special function registers (80-FF0) is used for
• Instruction register
• Data pointer
• Stack pointer
• 39
PSW, timers, IO ports, ACC and B registers
Data Memory (RAM) of 8051 Microcontroller(cont’d)

40
Data Memory (RAM) of 8051 Microcontroller(cont’d)

The lower 32 bytes are divided into 4 separate banks. Each register bank has 8
registers of one byte each. A register bank is selected depending upon two bank
select bits in the PSW (Program status word) register. Next 16 bytes are bit
addressable. In total, 128bits (16X8) are available in bit addressable area. Each bit
can be accessed and modified by suitable instructions. The bit addresses are from
00H (LSB of the first byte in 20H) to 7FH (MSB of the last byte in 2FH).
Remaining 80bytes of RAM are available for general purpose.

41
Data Memory (RAM) of 8051 Microcontroller(cont’d)

42
Data Memory (RAM) of 8051 Microcontroller(cont’d)

The 4 banks are named as Bank0, Bank1, Bank2 and Bank3. Each Bank consists of 8 registers
named as R0 – R7. Each Register can be addressed in two ways: either by name or by address.
To address the register by name, first the corresponding Bank must be selected. In order to
select the bank, we have to use the RS0 and RS1 bits of the Program Status Word (PSW)
Register (RS0 and RS1 are 3rd and 4th bits in the PSW Register). When addressing the Register
using its address i.e. 12H for example, the corresponding Bank may or may not be selected.
(12H corresponds to R2 in Bank2).

43
Data Memory (RAM) of 8051 Microcontroller(cont’d)

The next 16B of the RAM i.e. from 20H to 2FH are Bit – Addressable memory locations. There
are totally 128 bits that can be addressed individually using 00H to 7FH or the entire byte can be
addressed as 20H to 2FH. For example 32H is the bit 2 of the internal RAM location 26H.
The final 80B of the internal RAM i.e. addresses from 30H to 7FH, is the general
purpose RAM area which are byte addressable. These lower 128B of RAM can be addressed
directly or indirectly. The upper 128B of the RAM i.e. memory addresses from 80H to FFH is
allocated for Special Function Registers (SFRs). SFRs control specific functions of the 8051
Microcontroller. Some of the SFRs are I/O Port Registers (P0, P1, P2 and P3), PSW
(Program Status Word), A (Accumulator), IE (Interrupt
Enable), PCON (Power Control), etc. 44
SFRs Memory addresses are only direct addressable. Even though some of the addresses between
80H and FFH are not assigned to any SFR, they cannot be used as additional RAM area.
In some microcontrollers, there is an additional 128B of RAM, which share the memory address
with SFRs i.e. 80H to FFH. But, this additional RAM block is only accessed by
45
indirect addressing.
Interfacing External Memory with 8051 Microcontroller
We have seen that a typical 8051 Microcontroller has 4KB of ROM and 128B of RAM (most
modern 8051 Microcontroller variants have 8K ROM and 256B of RAM).
The designer of an 8051 Microcontroller based system is not limited to the internal RAM and ROM
present in the 8051 Microcontroller. There is a provision of connecting both external RAM and ROM i.e.
Data Memory and Program.
The reason for interfacing external Program Memory or ROM is that complex programs written
in high – level languages often tend to be larger and occupy more memory.
Another important reason is that chips like 8031 or 8032, which doesn‟t have any internal ROM, have to
be interfaced with external ROM.
A maximum of 64KB of Program Memory (ROM) and Data Memory (RAM) each can be
interface with the 8051 Microcontroller.
The following image shows the block diagram of interfacing 64KB of External RAM and 64KB of
46
External ROM with the 8051 Microcontroller.
Interfacing External Memory with 8051 Microcontroller

In this fig. we have seen the 8051 Microcontroller Memory Organization, Internal ROM and
RAM and how to interface external ROM and RAM with 8051 Microcontroller.
47
Clock connection
• Clock connection
• For 8051 microcontroller operation, one of the external inputs needed is the clock.
• There are three variations for this

48
Clock connection
• A machine cycle in 8051 contains six states or 12 clock cycles

49
Example

50
Reset operation

• Reset operation

• The other external input in 8051 is the reset input


• It is activated by making pin 9 high
• When reset occurs
• Program counter is cleared
• Register bank 0 is selected
• Stack pointer is initialized to 07H
• All ports are written with FFh
51
Reset operation (Contd.)

52
53

You might also like