P
P
The microcontroller like 8051 was designed in the year 1981 by Intel.
Its foundation was on Harvard Architecture and was developed principally for bringing into play Embedded
Systems.
An Embedded system product is used to do only one task, or we can say these are the application specific
processors with memory, I/O, Timers, buses etc. on one single chip.
At first, it was created using NMOS technology but as NMOS technology needs more power to function therefore
Intel re-intended Microcontroller 8051 employing CMOS technology and a new edition came into existence with a
letter ‘C’ in the title name, for illustration: 80C51.
The most common embedded systems that we use from day to day life are Air Conditioner, Touch Screen, Anti-
Break System, Biometric Attendance System, Face Sensors etc.
2
Microprocessor Microcontroller
Key Differences Heart/Brain of the Computer System. Heart/Brain of the embedded system.
Microcontroller
The circuit is very small.
usage.
Memories like RAM and ROM are absent. Carries RAM, ROM, etc.
Example: DEC Alpha 21164, IBM RS6000, Example: Intel 8051, PIC 16x, Zilog’s Z8,
etc. Freescale’s 6811 etc.
3
Some Embedded products using 4
Microcontroller
Security systems Laser printer Garage door openers
Intel www.intel.com/design/mcs51
Atmel www.atmel.com
Philips/Signetics www.semiconductors.philips.com
Infineon www.Infineon.com
5
How to choose a microcontroller ?
6
The 8051 Microcontroller
A harvard Single chip
architecture (separate microcontroller (µc)
instruction/data
memories)
• ROM - 4K Byte
• RAM – 128 Byte
• I/O Pins – 32
• Interrupt Sources – 6
Block Diagram of 8051 • Timers – 2
• Serial port - 1
7
8051 microcontroller is designed by Intel in 1981.
It is an 8-bit microcontroller.
8
Comparison of the 8051 Family Members
Feature 8051 8052 8031
Timers 2 3 2
I/O pins 32 32 32
Serial port 1 1 1
Interrupt sources 6 8 6
9
Pin Diagram of
8051
10
Explanation of the Pins
- Pin 1 to Pin 8 (Port – 1) – Pin 1 to Pin 8 is assigned to Port 1 for simple I/O
operations. It is a bidirectional port.
- Pin 9 (RST) – It is a reset input Pin, which is used to reset the 8051
- Pin 10 to Pin 17 (Port-3) – Pin 10 to Pin 17 are assigned to Port 3. This port is
also a bidirectional I/O port like port 1. This port performs some special functions
like interrupts, control signals, timer input, serial communication etc.
- Pin 18 and Pin 19 (XTAL2 And XTAL1) –Pins 18 and 19 i.e. XTAL 2 and
XTAL 1 are the pins for interfacing external oscillator. Mostly, a Quartz Crystal
Oscillator is connected here to get the system clock.
11
Explanation of the Pins
- Pin 21 to Pin28 (Port 2) – Pin 21 to pin 28 are port 2 pins. This port is also a bidirectional I/O port. But, this
is only possible when we are not using any external memory. If we use external memory, then these pins will
work as high order address bus (A8 to A15).
- Pin 29 (PSEN) – The Pin 29 is the Program Store Enable Pin (PSEN). It is used to enable external program
memory and read a signal from the external program memory.
- Pin 30 (ALE) – Pin 30 is the Address Latch Enable Pin. This pin is used to enable or disable the external
memory interfacing.
- Pin 31 (EA) – Pin 31 is the External Access Enable (EA) Pin. This pin allows external Program Memory. It is
an input pin and connected from VCC or GND. If we want to access the program from external program
memory, it must be connected with GND. If we want to use on-chip memory, it must be high (connected with
VCC).
- Pin 32 to Pin 39 (Port 0) – Pin 32 to Pin 39 are Port 0 pins. when we don’t use any external memory, these
pins are used as a bidirectional pin like port 2 and port 3. But, when ALE or Pin 30 is at 1, then this port is
used as data bus. And when the ALE pin is at 0, then this port is used as a lower order address bus (A0 to A7).
- Pin 40 (VCC) – This pin is used to provide (+5V ) power supply to the 8051 microcontroller circuit.
12
13
- Accumulator (A register) – The Accumulator, as its name suggests, is 14
used as a general register to accumulate the results of many instructions. It
can hold an 8-bit (1-byte) value and is the most versatile register the 8051.
This register is mostly used for arithmetic operations. The accumulator
register (A or ACC) act as an operand register, in case of some
instructions.
- B register – This is an 8-bit register that is bit addressable and is used for
two instructions only like MUL AB and DIV AB.
• MOV A,#55H
• MOV R0,A MOV A,#55H
• MOV R1,#34H
MOV R0,#46H
• MOV A,R1
• MOV R2,#20 ADD A,R0
• MOV A,R2
Module 3, Microprocessor & Microcontroller, SENSE VIT Dr. Shelja, Assistant Professor
- PSW register – Program Status Word (PSW) is the flag 15
● CY, the carry flag: This flag is set whenever there is a carry out from
the D7 bit. This flag bit is affected after an 8-bit addition or subtraction.
It can also be set to 1 or 0 directly by an instruction such as “SETB C”
and “CLR C” where “SETB C” stands for “set bit carry” and “CLR C”
for “clear arry”.
● P, the parity flag: The parity flag reflects the number of 1s in the A
(accumulator) register only. If the A register contains an odd number of
1s, then P = 1, Otherwise, P = 0 if A has an even number of 1s.
● 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. In general, The overflow flag is only used to detect
errors in signed arithmetic operations.
Note: X can be 0 or 1.
16
Example 1
Show the status of the CY, AC, and P flags after the addition of 38H and 2FH in the following
instructions.
MOV A,#38H
ADD A,#2FH ;after the addition A=67H, CY=0
Solution:
38 00111000
+ 2F 00101111
67 01100111
Show the status of the CY, AC, and P flags after the addition of 9CH and 64H in the following
instructions.
MOV A,#9CH
ADD A,#64H ;after addition A=00 and CY=1
Solution:
9C 10011100
+ 64 01100100
100 00000000
Memory Organization
ROM Memory
Map in the
8051 Family
Program Memory (ROM) is used
for permanent saving program
(CODE) being executed.
8051 memory organization
allows external program memory
to be added. memory type How
does the microcontroller handle
external memory depends on
the pin EA logical state.
Data Memory -
RAM