Department of Collegiate and Technical Education
8051 Microcontroller(Module 1)
Session 2
MICROCONTORLLER AND ITS APPLICATIONS(IV Semester)
Electronics and Communication Engineering
Electronics and Communication Engineering – 18EC46
Table of Content
• Computer software
• Salient features of 8051 microcontroller
• The 8051 architecture
• 8051 programming model
• Multiple choice questions
• References
Electronics and Communication Engineering – 18EC46
COMPUTER SOFTWARE
A set of instructions written in a specific sequence for the
computer to solve a specific task is called a program and software
is a collection of such programs.
The program stored in the computer memory in the form of binary
numbers is called machine instructions. The machine language
program is called object code.
An assembly language is a mnemonic representation of machine
language. Machine language and assembly language are low level
languages and are processor specific.
Electronics and Communication Engineering – 18EC46
The assembly language program, the programmer enters is
called source code. The source code (assembly language) is
translated to object code (machine language) using assembler.
Programs can be written in high level languages such as C, C+
+ etc. High level language will be converted to machine language
using compiler or interpreter.
Compiler reads the entire program and translate into the object
code and then it is executed by the processor.
Interpreter takes one statement of the high level language as
input and translate it into object code and then executes.
Electronics and Communication Engineering –
18EC46
SALIENT FEATURES
Eight bit CPU
On chip clock oscillator
4Kbytes of internal program memory (code memory) [ROM]
128 bytes of internal data memory [RAM]
64 Kbytes of external program memory address space.
64 Kbytes of external data memory address space.
32 bi directional I/O lines (can be used as four 8 bit ports or 32
individually addressable I/O lines)
Two 16 Bit Timer/Counter :T0, T1
Full Duplex serial data receiver/transmitter
Electronics and Communication Engineering – 18EC46
8 Bit Stack Pointer
Five vector interrupt structure (RESET not considered as an
interrupt.)
8051 CPU consists of 8 bit ALU with associated registers like
accumulator ‘A’, B register, PSW, SP, 16 bit program counter,
stack pointer.
ALU can perform arithmetic and logic functions on 8 bit
variables.
8051 has 128 bytes of internal RAM which is divided into
Working registers [00 – 1F]
Bit addressable memory area [20 – 2F]
General purpose memory area (Scratch pad memory) [30-7F]
Four Register banks with 8 registers in each bank.
Sixteen bit Program counter (PC) and a data pointer (DPTR)
8 Bit Program Status Word (PSW)
Electronics and Communication Engineering – 18EC46
8051 ARCHITECTURE
Electronics and Communication Engineering – 18EC46
The programming model of 8051 shows the 8051 as the
collection of 8 and 16 bit registers and 8 bit memory locations.
These registers and memory locations can be made to
operate using software instructions that are incorporated as part of
the program instructions.
8051 has 4 K Bytes of internal ROM. The address space is from
0000 to 0FFFh. If the program size is more than 4 K Bytes 8051
will fetch the code automatically from external memory.
Accumulator is an 8 bit register widely used for all arithmetic and
logical operations. Accumulator is also used to transfer data
between external memory. B register is used along with
Accumulator for multiplication and division. A and B registers
together is also called MATH registers.
Electronics and Communication Engineering –
PSW (Program Status Word). This is an 8 bit register which
contains the arithmetic status of ALU and the bank select bits of
register banks.
CY AC F0 RS1 RS0 OV - P
•CY - carry flag
•AC - auxiliary carry flag
•F0 - available to the user for general purpose RS1, RS0 - register
bank select bits
•RS1, RS0 - register bank select bits
•OV - overflow
•P - parity
Electronics and Communication Engineering –
Stack Pointer (SP) – it contains the address of the data item on
the top of the stack. Stack may reside anywhere on the internal
RAM. On reset, SP is initialized to 07 so that the default stack will
start from address 08 onwards.
Data Pointer (DPTR) – DPH (Data pointer higher byte), DPL
(Data pointer lower byte). This is a 16 bit register which is used to
furnish address information for internal and external program
memory and for external data memory.
Program Counter (PC) – 16 bit PC contains the address of next
instruction to be executed. On reset PC will set to 0000. After
fetching every instruction PC will increment by one.
Electronics and Communication Engineering –
8051 Programming model
Electronics and Communication Engineering –
The programming model of the 8051 in above figure shows
the 8051 as a collection of 8 and 16 bit registers and 8 bit
memory locations.
These registers and memory locations can be made to operate
using the software instructions that are incorporated as part of
the design.
The program instructions have to do with the control of the
registers and digital data paths that are physically contained by
the number of SFR s that must be present to make a
microcomputer a microcontroller.
Electronics and Communication Engineering –
Most of the registers have a specific function those that do
occupy an individual block with a symbolic name such as A or
TH0 or PC others, which are indistinguishable from each other are
grouped in a larger block such as internal ROM or RAM memory.
Each register except PC has an 1 byte address some marked with
(*) are both bit and byte addressable.
Electronics and Communication Engineering –
Multiple Choice Question
1. 8051 microcontrollers are manufactured by which of the following
companies?
a) Atmel
b) Philips
c) Intel
d) All of the mentioned
Answer: d
Explanation: 8051 microcontrollers are manufactured by Intel, Atmel,
Philips/Signetics, Infineon, Dallas Semi/Maxim.
2. AT89C2051 has RAM of:
a) 128 bytes
b) 256 bytes
c) 64 bytes
d) 512 bytes
Answer: a
Explanation: It has 128 bytes of RAM in it.
Electronics and Communication Engineering – 18EC46
3. 8051 series has how many 16 bit registers?
a) 2
b) 3
c) 1
d) 0
Answer: a
Explanation: It has two 16 bit registers DPTR and PC.
4. When 8051 wakes up then 0x00 is loaded to which register?
a) PSW
b) SP
c) PC
d) None of the mentioned
Answer: c
Explanation: When 8051 wakes up, Program Counter (PC) loaded with 0000H.
Because of this in 8051 first opcode is stored in ROM address at 0000H.
Electronics and Communication Engineering – 18EC46
5. When the microcontroller executes some arithmetic operations, then the flag
bits of which register are affected?
a) PSW
b) SP
c) DPTR
d) PC
Answer: a
Explanation: It stands for program status word. It consists of carry, auxiliary carry,
and overflow, parity, and register bank select bits etc which are affected during such
operations.
6. How are the status of the carry, auxiliary carry and parity flag affected if the
write instruction
MOV A,#9C
ADD A,#64H
a) CY=0,AC=0,P=0
b) CY=1,AC=1,P=0
c) CY=0,AC=1,P=0
d) CY=1,AC=1,P=1
Answer: b
Explanation: On adding 9C and 64, a carry is generated from D3 and from the D7
bit so CY and AC are set to 1. In the result, the number of 1’s present are even so
parity flag is set to zero.
Electronics and Communication Engineering – 18EC46
7. If we push data onto the stack then the stack pointer
a) increases with every push
b) decreases with every push
c) increases & decreases with every push
d) none of the mentioned
Answer: a
Explanation: If we push elements onto the stack then the stack pointer increases
with every push of element.
8. How are the bits of the register PSW affected if we select Bank2 of 8051?
a) PSW.5=0 and PSW.4=1
b) PSW.2=0 and PSW.3=1
c) PSW.3=1 and PSW.4=1
d) PSW.3=0 and PSW.4=1
Answer: d
Explanation: Bits of PSW register are CY, AC, F0, RS1, RS0, OV, -, P so for
selecting bank2 RS1=1 and RS0=0 which are fourth and third bit of the register
respectively.
Electronics and Communication Engineering – 18EC46
9. On power up, the 8051 uses which RAM locations for register R0- R7
a) 00-2F
b) 00-07
c) 00-7F
d) 00-0F
Answer: b
Explanation: On power up register bank 0 is selected which has memory address
from 00H-07H.
10. How many bytes of bit addressable memory is present in 8051 based
microcontrollers?
a) 8 bytes
b) 32 bytes
c) 16 bytes
d) 128 bytes
Answer: c
Explanation: 8051 microcontrollers have 16 bytes of bit addressable memory.
Electronics and Communication Engineering – 18EC46
REFERENCES
[1]. “The 8051 Microcontroller and Embedded Systems – using
assembly and C”, Muhammad Ali Mazidiand Janice Gillespie Mazidi
and Rollin D. McKinlay; PHI, 2006 / Pearson, 2006.
[2]. “The 8051 Microcontroller”, Kenneth J. Ayala, 3rd Edition,
Thomson/Cengage Learning.
[3]. “The 8051 Microcontroller Based Embedded Systems”, Manish
K Patel, McGraw Hill, 2014, ISBN:978-93-329-0125-4.
[4]. “Microcontrollers: Architecture, Programming, Interfacing and
System Design”, Raj Kamal, PearsonEducation, 2005.
[5]https://www.sanfoundry.com/microcontroller-mcqs-von-
newmann-harward-architecture/
Electronics and Communication Engineering – 18EC46
Thank you
Dr. Rangaraju H G GSKSJTI, Bangalore
Dr. Revanna C R GEC,Ramanagara
Dr. Neelappa GEC, Kushalnagar
Dr. Imran Khan GEC, Ramanagara
Prof. Prathibha S GEC, Ramanagara
Prof. Karibasappa GEC, Kushalnagara
Prof. Nandeesha R GEC, KR.Pete
Prof. Fazaludden DM GEC,Karwar
Electronics and Communication Engineering – 17EC72