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

Unit-2

mpmc
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)
17 views

Unit-2

mpmc
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/ 14

Unit-II

Intel 8051 Microcontroller Architecture

Features of the 8051 Microcontroller


 4 KB on-chip ROM (Program memory).
 128 bytes on-chip RAM (Data memory).
 The 8-bit data bus (bidirectional).
 16-bit address bus (unidirectional).
 Two 16-bit timers.
 Four 8-bit input/output ports.
 128 user-defined flags.
 Four register banks of 8 bit each.
 16-byte bit-addressable RAM.
 The general purpose registers are 32 each is 8-bit.
 8051 has two external and three internal interrupts.
 8051 microcontroller specifies some special function features like UARTs, ADC, Op-amp, etc.
 It has a 16-bit program counter and data pointer.
The pin diagram of 8051 microcontroller

Pin-40 : Named as Vcc is the main power source. Usually its +5V DC.
Pins 32-39: Known as Port 0 (P0.0 to P0.7) – In addition to serving as I/O port, lower order
address and data bus signals are multiplexed with this port (to serve the purpose of external
memory interfacing). This is a bi directional I/O port (the only one in 8051) and external pull up
resistors are required to function this port as I/O.

Pin-31:- ALE aka Address Latch Enable is used to demultiplex the address-data signal of port 0
(for external memory interfacing.) 2 ALE pulses are available for each machine cycle.

Pin-30:- EA/ External Access input is used to enable or disallow external memory interfacing. If
there is no external memory requirement, this pin is pulled high by connecting it to Vcc.

Pin- 29:- PSEN or Program Store Enable is used to read signal from external program memory.

Pins- 21-28:- Known as Port 2 (P 2.0 to P 2.7) – in addition to serving as I/O port, higher order
address bus signals are multiplexed with this quasi bi directional port.

Pin 20:- Named as Vss – it represents ground (0 V) connection.

Pins 18 and 19:- Used for interfacing an external crystal to provide system clock.

Pins 10 – 17:- Known as Port 3. This port also serves some other functions like interrupts, timer
input, control signals for external memory interfacing RD and WR , serial communication
signals RxD and TxD etc. This is a quasi bi directional port with internal pull up.

Pin 9:- As explained before RESET pin is used to set the 8051 microcontroller to its initial
values, while the microcontroller is working or at the initial start of application. The RESET pin
must be set high for 2 machine cycles.

Pins 1 – 8:- Known as Port 1. Unlike other ports, this port does not serve any other functions.
Port 1 is an internally pulled up, quasi bi directional I/O port.

8051 Block Diagram (Architecture)

The 8051 architecture consists of the following special features.


 8 bit CPU with registers A and B
 16 bit Program Counter(PC) and Data Pointer(DPTR)
 8 bit Program Status Word(PSW)
 8 bit Stack Pointer(SP)
 Internal ROM or EPROM of 4K bytes
 Internal RAM of 128 bytes.
o 4 Register banks , each containing 8 registers
o 16 bytes ,which may be addressed at the bit level
o 80 bytes of general purpose memory
 32 input / output pins are arranged as four 8 bit ports : P0-P3
 Two 16 bit timer / counters : T0 and T1
 Full duplex serial data receiver / transmitter : SBUF
 Control registers TCON,TMOD,SCON,PCON,IP and IE
 2 external and 3 internal interrupt sources
 Oscillator and Clock circuits.
8051 System Clock
An 8051 clock circuit is shown above. In general cases, a quartz crystal is used to make the clock
circuit. The connection is shown in figure and note the connections to XTAL 1 and XTAL 2. In
some cases external clock sources are used and you can see the various connections above. Clock
frequency limits (maximum and minimum) may change from device to device. Standard practice
is to use 12MHz frequency. If serial communications are involved then its best to use 11.0592
MHz frequency.

Okay, take a look at the above machine cycle waveform. One complete oscillation of the
clock source is called a pulse. Two pulses forms a state and six states forms one machine cycle.
Also note that, two pulses of ALE are available for 1 machine cycle.

ALU

All arithmetic and logical functions are carried out by the ALU.

Addition, subtraction with carry, and multiplication come under arithmetic operations.

Logical AND, OR and exclusive OR (XOR) come under logical operations.

Registers
Registers are usually known as data storage devices.
A & B Registers

8051 microcontroller has 2 registers, namely Register A and Register B. Register A serves as an
accumulator while Register B functions as a general purpose register. These registers are used to
store the output of mathematical and logical instructions.

The operations of addition, subtraction, multiplication and division are carried out by Register A.
Register B is usually unused and comes into picture only when multiplication and division
functions are carried out by Register A. Register A also involved in data transfers between the
microcontroller and external memory.
Program Counter (PC)
A program counter is a 16-bit register and it has no internal address. The basic function of
program counter is to fetch from memory the address of the next instruction to be executed. The
PC holds the address of the next instruction residing in memory and when a command is
encountered, it produces that instruction. This way the PC increments automatically, holding the
address of the next instruction.

Data Pointer (DPTR)


The data pointer or DPTR is a 16-bit register. It is made up of two 8-bit registers called DPH and
DPL. Separate addresses are assigned to each of DPH and DPL. These 8-bit registers are used for
the storing the memory addresses that can be used to access internal and external data/code.
Stack Pointer (SP)
The stack pointer (SP) in 8051 is an 8-bit register. The main purpose of SP is to access the stack.
As it has 8-bits it can take values in the range 00 H to FF H. Stack is a special area of data in
memory. The SP acts as a pointer for an address that points to the top of the stack.
PSW (Program Status Word)
Program Status Word or PSW is a hardware register which is a memory location which holds a
program's information and also monitors the status of the program this is currently being
executed. PSW also has a pointer which points towards the address of the next instruction to be
executed. PSW register has 3 fields namely are instruction address field, condition code field and
error status field. We can say that PSW is an internal register that keeps track of the computer at
every instant.

Generally, the instruction of the result of a program is stored in a single bit register called a 'flag'.
The are7 flags in the PSW of 8051. Among these 7 flags, 4 are math flags and 3 are general
purpose or user flags.
The 4 Math flags are: Carry flag(C), Auxiliary Carry (AC) ,Overflow (OV) and Parity
(P)

The 3 General purpose flags or User flags are: FO, GFO and GF 1

CY PSW.7 Carry flag (Carry out from the D7 bit)


AC PSW.6 Auxiliary carry flag (A carry from D3 to D4)
— PSW.5 Available to the 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 bit.
P PSW.0 Parity flag. Set/cleared by hardware each instruction cycle to indicate an
odd/even number of 1 bits in the accumulator
.
Special function registers

The table shows the list of special function registers for various operations in 8051
Memory Organization
External memory interface with 8051

Address/Data Multiplexing

From Figure, it is important to note that normally ALE = 0, and PO is used as a


data bus, sending data out or bringing data in. Whenever the 8031/51 wants to use
PO as an address bus, it puts the addresses AO – A7 on the PO pins and activates
ALE = 1 to indicate that PO has the addresses.

PSEN

Another important signal for the 8031/51 is the PSEN (program store enable)
signal. PSEN is an output signal for the 8031/51 microcontroller and must be
connected to the OE pin of a ROM containing the program code. In other words, to
access external ROM containing program code, the 8031/51 uses the PSEN signal.
It is important to emphasize the role of EA and PSEN when connecting the 8031/51
to external ROM. When the EA pin is connected to GND, the 8031/51 fetches
opcode from external ROM by using PSEN. The connection of the PSEN pin to the
OE pin of ROM. In systems based on the 8751/89C51/DS5000 where EA is
connected to VCC, these chips do not activate the PSEN pin. This indicates that the
on-chip ROM contains program code.
In systems where the external ROM contains the program code, burning the
program into ROM leaves the microcontroller chip untouched. This is preferable in
some applications due to flexibility. In such applications the software is updated via
the serial or parallel ports of the IBM PC. This is especially the case during
software development and this method is widely used in many 8051-based trainers
and emulators.

You might also like