Unit-2
Unit-2
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.
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.
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.
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.
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
The table shows the list of special function registers for various operations in 8051
Memory Organization
External memory interface with 8051
Address/Data Multiplexing
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.