SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
Chapter 1 
The 8051 Microcontroller 
1.1 INTRODUCTION 
The microcontroller incorporates all the features that are found in microprocessor. 
The microcontroller has built in ROM, RAM, Input Output ports, Serial Port, 
timers, interrupts and clock circuit. A microcontroller is an entire computer 
manufactured on a single chip. Microcontrollers are usually dedicated devices 
embedded within an application. For example, microcontrollers are used as engine 
controllers in automobiles and as exposure and focus controllers in cameras. In 
order to serve these applications, they have a high concentration of on-chip facilities 
such as serial ports, parallel input output ports, timers, counters, interrupt control, 
analog-to-digital converters, random access memory, read only memory, etc. The 
I/O, memory, and on-chip peripherals of a microcontroller are selected depending 
on the specifics of the target application. Since microcontrollers are powerful 
digital processors, the degree of control and programmability they provide 
significantly enhances the effectiveness of the application. The 8051 is the first 
microcontroller of the MCS-51 family introduced by Intel Corporation at the end 
of the 1970s. The 8051 family with its many enhanced members enjoys the largest 
market share, estimated to be about 40%, among the various microcontroller 
architectures. 
The microcontroller has on chip peripheral devices. In this unit firstly we 
differentiate microcontroller from microprocessor then we will discuss about 
Hardware details of 8051 and then introduce the Assembly level language in brief. 
Microcontrollers 
• Microcontroller (MC) may be called computer on chip since it has basic 
features of microprocessor with internal ROM, RAM, Parallel and serial 
ports within single chip. Or we can say microprocessor with memory and 
ports is called as microcontroller. This is widely used in washing machines, 
vcd player, microwave oven, robotics or in industries.
2 Microcontroller and Embedded Systems 
• Microcontroller can be classified on the basis of their bits processed like 
8bit MC, 16bit MC. 
• 8 bit microcontroller, means it can read, write and process 8 bit data. Ex. 
8051 microcontroller. Basically 8 bit specifies the size of data bus. 8 bit 
microcontroller means 8 bit data can travel on the data bus or we can read, 
write process 8 bit data. 
1.2 DIFFERENCE BETWEEN MICROCONTROLLER AND 
MICROPROCESSOR 
Data bus 
CPU 
General 
Purpose 
Micro-processor 
RAM ROM I / O 
Port 
Timer 
Serial 
COM 
Port 
Address bus 
CPU RAM ROM 
I / O Timer 
Serial 
COM 
Port 
(a) General-purpose Microprocessor System (b) Microcontroller 
Fig. 1.1 Structure of microprocessor and microcontroller 
It is very clear from figure that in microprocessor we have to interface additional 
circuitry for providing the function of memory and ports, for example we have to 
interface external RAM for data storage, ROM for program storage, programmable 
peripheral interface (PPI) 8255 for the Input Output ports, 8253 for timers, USART 
for serial port. While in the microcontroller RAM, ROM, I/O ports, timers and 
serial communication ports are in built. Because of this it is called as “system on 
chip”. So in micro-controller there is no necessity of additional circuitry which is 
interfaced in the microprocessor because memory and input output ports are inbuilt 
in the microcontroller. Microcontroller gives the satisfactory performance for 
small applications. But for large applications the memory requirement is limited 
because only 64 KB memory is available for program storage. So for large 
applications we prefer microprocessor than microcontroller due to its high 
processing speed. 
1.3 CRITERIA FOR SELECTION OF A MICROCONTROLLER 
IN EMBEDDED SYSTEM 
Criteria for selection of microcontroller in any embedded system is as following: 
(a) Meeting the computing needs of task at hand efficiently and cost effectively 
• Speed of operation 
• Packing
The 8051 Microcontroller 3 
• Power consumption 
• Amount of RAM and ROM on chip 
• No. of I/O pins and timers on chip 
• Cost 
(b) Availability of software development tools such as compiler, assembler 
and debugger. 
1.4 MICROCONTROLLER 8051 ARCHITECTURE 
It is 8-bit microcontroller, means MC 8051 can Read, Write and Process 8 bit 
data. This is mostly used microcontroller in the robotics, home appliances like 
mp3 player, washing machines, electronic iron and industries. Mostly used blocks 
in the architecture of 8051 are as follows: 
EXTERNAL 
INTERRUPTS 
INTERRUPT 
CONTROL 
ON-CHIP 
ROM 
for 
program 
code 
ON-CHIP 
RAM 
ETC. 
TIMER 0 
TIMER 1 
T1 
T0 
COUNTER INPUTS 
CPU 
OSC 
30PF 30PF 
4 to 30 MHz 
BUS 
CONTROL 
4 I / O 
PORTS 
SERIAL 
PORT 
P0 P1 P2 P3 
normally 11.0592 MHz 
ADDRESS / DATA 
TXD RXD 
INT0 INT1 
Fig. 1.2 8051 architecture 
1.4.1 128 Byte RAM for Data Storage 
MC 8051 has 128 byte Random Access memory for data storage. Random access 
memory is non volatile memory. During execution for storing the data the RAM 
is used. RAM consists of the register banks, stack for temporary data storage. It 
also consists of some special function register (SFR) which are used for some 
specific purpose like timer, input output ports etc. Normally microcontroller has 
256 byte RAM in which 128 byte is used for user space which is normally Register
4 Microcontroller and Embedded Systems 
banks and stack. But other 128 byte RAM which consists of SFRs. We will 
discuss the RAM in detail in next section. 
Now what is the meaning of 128 byte RAM. What are address range which 
is provided for data storage. We will discuss here. 
We know that 128 byte = 27 byte 
7 6 5 4 3 2 1 0 
0 
if initial address is 
then final or last address is 0 
0 0 0 0 0 0 0 
1 1 1 1 1 1 1 
(00H) 
(7FH) 
7 F 
Since 27 bytes so last 7 bits can be changed so total locations are from 00H 
to 7F H. This procedure of calculating the memory address is called as “memory 
mapping”. We can save data on memory locations from 00H to 7FH. Means total 
128 byte space from 00H to 7FH is provided for data storage. 
1.4.2 4KB ROM 
• In 8051, 4KB read only memory (ROM) is available for program storage. 
This is used for permanent data storage. Or the data which is not changed 
during the processing like the program or algorithm for specific applications. 
• This is volatile memory; the data saved in this memory does not disappear 
after power failure. 
• We can interface up to 64KB ROM memory externally if the application is 
large. These sizes are specified different by their companies. 
• Address Range of PC: Address range of PC means program counter (which 
points the next instruction to be executing) can be moved between these 
locations or we can save the program from this location to this location. 
The address range can be calculated in the same way just like the RAM 
which is discussed in previous section. 
4KB = 22 ◊ 210 B(since 1KB = 210 B) 
= 212 Byte 
Address range of PC is 0000H to 0FFFH means total 4KB locations are available 
from 0000H to 0FFFH. At which we can save the program.
The 8051 Microcontroller 5 
Difference between RAM and ROM 
• RAM is used for data storage while ROM is used for program storage. 
• Data of RAM can be changed during processing while data of ROM can’t 
be changed during processing. 
• We can take an example of calculator. If we want to perform addition of 
two numbers then we type the two numbers in calculator, this is saved in 
the RAM, but the Algorithms by which the calculation is performed is saved 
in the ROM. Data which is given by us to calculator can be changed but the 
algorithm or program by which calculation is performed can’t be changed. 
1.4.3 Timers and Counters 
Timer means which can give the delay of particular time between some events. 
For example on or off the lights after every 2 sec. This delay can be provided 
through some assembly program but in microcontroller two hardware pins are 
available for delay generation. These hardware pins can be also used for counting 
some external events. How much times a number is repeated in the given table is 
calculated by the counter. 
• In MC8051, two timer pins are available T0 and T1, by these timers we can 
give the delay of particular time if we use these in timer mode. 
• We can count external pulses at these pins if we use these pins in counter 
mode. 
• 16 bits timers are available. Means we can generate delay between 0000H 
to FFFFH. 
• Two special function registers are available. 
• If we want to load T0 with 16 bit data then we can load separate lower 8 bit 
in TL0 and higher 8 bit in TH0. 
• In the same way for T1. 
• TMOD, TCON registers are used for controlling timer operation. 
1.4.4 Serial Port 
• There are two pins available for serial communication TXD and RXD. 
• Normally TXD is used for transmitting serial data which is in SBUF register, 
RXD is used for receiving the serial data. 
• SCON register is used for controlling the operation. 
• There are four modes of serial communication which has been discussed in 
next chapter.
6 Microcontroller and Embedded Systems 
1.4.5 Input Output Ports 
• There are four input output ports available P0, P1, P2, P3. 
• Each port is 8 bit wide and has special function register P0, P1, P2, P3 
which are bit addressable means each bit can be set or reset by the Bit 
instructions (SETB for high, CLR for low) independently. 
• The data at any port which is transmitting or receiving is in these registers. 
• The port 0 can perform dual works. It is also used as Lower order address 
bus (A0 to A7) multiplexed with 8 bit data bus P0.0 to P0.7 is AD0 to AD7 
respectively the address bus and data bus is demultiplex by the ALE signal 
and latch which is further discussed in details. 
• Port 2 can be used as I/O port as well as higher order address bus A8 to 
A15. 
• Port 3 also have dual functions it can be worked as I/O as well as each pin 
of P3 has specific function. 
P3.0 – RXD – {Serial I / P for Asynchronous communication 
Serial O / P for synchronous communication. 
P3.1 – TXD – Serial data transmit. 
P3.2 – INT0 – External Interrupt 0. 
P3.3 – INT1 – External Interrupt 1. 
P3.4 – T0 – Clock input for counter 0. 
P3.5 – T1 – Clock input for counter 1. 
P3.6 – WR – Signal for writing to external memory. 
P3.7 – RD – Signal for reading from external memory. 
When external memory is interfaced with 8051 then P0 and P2 can’t be 
worked as I/O port they works as address bus and data bus, otherwise they 
can be accessed as I/O ports. 
1.4.6 Oscillator 
• It is used for providing the clock to MC8051 which decides the speed or 
baud rate of MC. 
• We use crystal which frequency vary from 4MHz to 30 MHz, normally we 
use 11.0592 MHz frequency. 
1.4.7 Interrupts 
• Interrupts are defined as requests because they can be refused (masked) if 
they are not used, that is when an interrupt is acknowledged. A special set 
of events or routines are followed to handle the interrupts. These special 
routines are known as interrupt handler or interrupt service routines (ISR). 
These are located at a special location in memory. 
• INT0 and INT1 are the pins for external interrupts.
The 8051 Microcontroller 7 
1.5 PIN DIAGRAM OF 8051 
1 40 
2 39 
3 38 
4 37 
5 36 
8051 
6 35 
(8031) 
7 (89420) 
34 
8 33 
9 32 
10 31 
11 30 
12 29 
13 28 
14 27 
15 26 
16 25 
17 24 
18 23 
19 22 
20 21 
P1.0 
P1.1 
P1.2 
P1.3 
P1.4 
P1.5 
P1.6 
P1.7 
P1.18 
RST 
(RXD) P3.0 
(TXD) P3.1 
(INT0) P3.2 
(INT1) P3.3 
(T0) P3.4 
(T1) P3.5 
(WR) P3.6 
(RD) P3.7 
XTAL2 
XTAL1 
GND 
Vcc 
P0.0 (AD0) 
P0.1 (AD1) 
P0.2 (AD2) 
P0.3 (AD3) 
P0.4 (AD4) 
P0.5 (AD5) 
P0.6 (AD6) 
P0.7 (AD7) 
EA / VPP 
ALE / PROG 
PSEN 
P2.7 (A15) 
P2.6 (A14) 
P2.5 (A13) 
P2.4 (A12) 
P2.3 (A11) 
P2.2 (A10) 
P2.1 (A9) 
P2.0 (A8) 
Fig. 1.3 Pin diagram of MC 8051 
Description of each pin is discussed here: 
• VCC → 5V supply 
• VSS → GND 
• XTAL2/XTALI are for oscillator input 
• Port 0 – 32 to 39 – AD0/AD7 and P0.0 to P0.7 
• Port 1 – 1 to 8 – P1.0 to P1.7 
• Port 2 – 21 to 28 – P2.0 to P2.7 and A 8 to A15 
• Port 3 – 10 to 17 – P3.0 to P3.7 
• P 3.0 – RXD – Serial data input – SBUF 
• P 3.1 – TXD – Serial data output – SBUF 
• P 3.2 – INT0 – External interrupt 0 – TCON 0.1 
• P 3.3 – INT1 – External interrupt 1 – TCON 0.3 
• P 3.4 – T0 – External timer 0 input – TMOD
8 Microcontroller and Embedded Systems 
• P 3.5 – T1 – External timer 1 input – TMOD 
• P 3.6 –WR – External memory write cycle – Active LOW 
• P 3.7 – RD – External memory read cycle – Active LOW 
• RST – for Restarting 8051 
• ALE – Address latch enable 
1 – Address on AD 0 to AD 7 
0 – Data on AD 0 to AD 7 
• PSEN – Program store enable 
1.6 ARCHITECTURE OF 8051 
Figure 1.4 shows the architecture block diagram of 8051. 
Arithmetic 
and 
Logic Unit 
PSW 
Special 
Function 
Registers 
RAM 
Latch Latch Latch Latch 
Port0Port 1 Port 3 Port 2 
A B 
I / O 
AD –AD 7 0 
I / O 
I / O 
A –A 15 8 
I / O 
Interrupt (INT INT ) 0,9 1 
Counter (T T ) 0,9 1 
Serial Data 
(TXD, RXD) 
RD, WR 
8-Bit Data and 
Address Bus 
PC ROM 
16-Bit Address Bus 
DPTR 
DPH 
DPL 
EA 
ALE 
PSEN 
XTAL1 
XTAL2 
RESET 
Vcc 
GND 
System 
Timing 
System 
Interrupts 
Timers 
Data Buffers 
Memory Control 
Byte/Bit 
Addresses 
Register 
Bank 3 
Register 
Bank 2 
Register 
Bank 1 
Register 
Bank 0 
Special 
Function 
Register 
IE 
IP 
PCON 
SBUF 
SCON 
TCON 
TMOD 
TL0 
TH0 
TL1 
TH1 
Internal RAM Structure 
Fig. 1.4 Architectural block diagram of microcontroller 8051
The 8051 Microcontroller 9 
Each block will be discussed step by step: 
1.6.1 ALU — Arithmetic Logical Unit 
This unit is used for the arithmetic calculations. 
1.6.2 A-Accumulator 
This register is used for arithmetic operations. This is also bit addressable and 8 bit 
register. 
1.6.3 B-Register 
This register is used in only two instructions MUL AB and DIV AB. This is also 
bit addressable and 8 bit register. 
1.6.4 PC-Program Counter 
• Points to the address of next instruction to be executed from ROM 
• It is 16 bit register means the 8051 can access program address from 
0000H to FFFFH. A total of 64KB of code. 16 bit register means. 
Initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (0000H) 
Final value 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 (F F F FH) 
• Initially PC has 0000H 
• ORG instruction is used to initialize the PC ORG 0000H means PC 
initialize by 0000H 
• PC is incremented after each instruction. 
Example: 
Mnemonics Machine codes 
MOV R5, #25H 7D 25 
MOV A, #00H 74 00 
ADD A, R5 2D 
HERE: SJMP HERE; 80 FE 
• When 7D is accessed then PC locate the 
0001H (next instruction to be executed) 
• When 00 is accessed then PC locate the 
0004H (next instruction to be executed) 
1.6.5 ROM Memory Map in 8051 
→ 4KB, 8KB, 16KB, 32KB, 64KB on chip ROM is available. 
→ Max ROM space is 64 KB because 16 bit address line is available in 
8051. 
→ Starting address for ROM is 0000H (because PC which points the ROM 
is 16 bit wide). 
PC 
ROM 
7D 
25 
74 
00 
2D 
80 
FE 
0000H 
0001H 
0002H 
0003H 
0004H 
0005H 
0006H 
Fig. 1.5 ROM locations
10 Microcontroller and Embedded Systems 
Ex. For AT89C51 find the address range of ROM. 
Sol. 
4KB ROM = 22. 210 = 212B 
So 12 bits can be changed. 
(0000H) 000 0 00 0 0 0 0 0 0 0 0 00 (Starting Address) 
(0FFFH) 000 0 11 1 1 1 1 1 1 1 1 11 (Max Address) 
Memory address from 0000H to 0FFFH. 
1.6.6 8051 Flag Bits and PSW Register 
→ Used to indicate the Arithmetic condition of ACC. 
→ Flag register in 8051 is called as program status word (PSW). This special 
function register PSW is also bit addressable and 8 bit wide means each bit 
can be set or reset independently. 
PSW0.7 PSW0.6 PSW0.5 PSW0.4 PSW0.3 PSW0.2 PSW0.1 PSW0.0 
CY AC F0 RS1 RS0 OV — P 
FLAG Register 
There are four flags in 8051 
• P → Parity flag → PSW 0.0 
1 – odd number of 1 in ACC 
0 – even number of 1 in ACC 
• OV(PSW 0.2) → overflow flag → this is used to detect error in signed 
arithmetic operation. This is similar to carry flag but difference is only that 
carry flag is used for unsigned operation. 
• RS1(PSW0.4) RS0(PSW0.3) Register Bank Select 
0 0 Bank 0 
0 1 Bank 1 
1 0 Bank 2 
1 1 Bank 3 
for selecting Bank 1, we use following commands 
SETB PSW0.3 (means RS0=1) 
CLR PSW0.4 (means RS1=0) 
Initially by default always Bank 0 is selected. 
• F0 → user definable bit 
• AC → Auxiliary carry flag → when carry is generated from D3 to D4, it 
is set to 1, it is used in BCD arithmetic. 
1 1 
0 0 0 0 1 1 1 0 (0EH) 
0 1 0 1 1 0 1 0 (5AH) 
0 1 1 0 1 0 0 0 (38H) 
+
The 8051 Microcontroller 11 
Since carry is generated from D3 to D4, so AC is set. 
• CY → carry flag → Affected after 8 bit addition and subtraction. It is used 
to detect error in unsigned arithmetic opr. We can also use it as single bit 
storage. 
SETB C → for cy = 1 
CLR C → for cy = 0 
1.6.7 Structure of RAM or 8051 Register Bank and Stack 
→ 128 byte RAM is available in 8051 
→ 128 byte = 27B 
Address Range 
0 
0 0 0 0 0 0 0 
1 1 1 1 1 1 1 
(00H) 
(7FH) 
7 bits 
0 
Address range of RAM is 00H to 7FH. 
→ In MC8051, 128 byte visible or user accessible RAM is available which is 
shown in figure. Extra 128B RAM which is not user accessible. 80H to 
FFH used for storage of SFR (special function register) 
Scratch Pad RAM 
7FH 
30H 
2FH 1FH 
08 09 
00 01 02 03 04 05 06 07 
20H 
1FH 
18H 
17H 
10H 
0FH 
08H 
07H 
00H 
R7 
R0 
R7 
R0 
R7 
R0 
R7 
R0 
Bank 3 
Bank 2 
Bank 1 
Bank 0 
Bit addressable 
RAM 
Stack 
SP = 07 (initially) 
Fig. 1.6 Structure of RAM 
→ Four Register Banks 
→ There are four register banks, in each register bank there are eight 8 bit 
register available from R0 to R7 
→ By default Bank 0 is selected. 
For Bank 0, R0 has address 00H
12 Microcontroller and Embedded Systems 
R1 has address 01H 
. . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . 
R7 has address 07H 
For Bank 1, R0 has address 08H 
R1 has address 09H 
. . . . . . . . . . . . . . . . 
. . . . . . . . . . . . . . . . 
R7 has address 0FH 
For selecting banks we use RS0 and RS1 bit of PSW. 
→ R0 to R7 registers are byte addressable means. 
7 6 5 4 3 2 1 0 
0 0 0 0 0 0 0 0 R0 
If we want to set the bit 3 of R0 then we can’t use SETB R0.3 
We use MOV R0, #08H; 
For changing single bit we can modify all the other bits of R0. 
→ Locations 20H to 2FH is bit addressable RAM means each bit from 00H to 
FFH in this we can set or reset CF rather than changing whole byte. 
→ Locations 30H to 7FH is used as scratch pad means we can use this space 
for data reading and writing or for data storage. 
1.6.8 Stack in 8051 
→ RAM locations from 08H to 1FH can be used as stack. Stack is used to 
store the data temporarily. 
Stack is last in first out (LIFO) 
→ Stack pointer (SP) → 
• 8bit register 
• It indicate current RAM address available for stack or it points the top of 
stack. 
• Initially by default at 07H because first location of stack is 08H. 
• After each PUSH instruction the SP is incremented by one while in MC 
after PUSH instruction SP is decremented. 
• After each POP instruction the SP is decremented. 
Example: 
MOV R6,#25H; 
MOV R1,#12H; 
MOV R4,#OF3H; 
PUSH 06H; 
PUSH 01H; 
POP 04H;
The 8051 Microcontroller 13 
0B 
0A 
09 
08 
initially 
SP = 074 
PUSH 06 
PUSH 014 
POP 04 
R4 = 124 
25 
12(R1) 
25(R6) 
25(R6) 
SP = 084 SP = 09 
→ if we want to use more than 24byte (08H to 1FH) of stack. We can change 
SP to point RAM address 30H to 7FH by MOV SP, 
#XX 
Any value from 30 to 7FH 
1.6.8.1 Conflicting of Register Banks and Stack 
→ We know locations from 08H to 1FH is used as stack and it is also used as 
register bank. 
→ If in the program, we use the Register Bank 1 to 3 and also use the stack 
then conflicts exist and error can be possible. 
For removing this situation we use the stack from location 30H to 7FH by 
shifting SP to 2FH. 
MOV SP,#2FH; 
1.6.9 DPTR →→→→ Data Pointer in 8051 
→ 16 bit register, it is divided into two parts DPH and DPL. 
→ DPH for Higher order 8 bits, DPL for lower order 8 bits. 
→ DPTR, DPH, DPL these all are SFRs in 8051. 
1.6.10 Special Function Register 
→→→→ (See Fig.) RAM scratch pad, there is extra 128 byte RAM which is used to 
store the SFRs 
→→→→ Following figure shows special function bit address, all access to the four 
I/O ports CPU register, interrupt control register, timer/counter, UART, 
power control are performed through registers between 80H and FFH.
14 Microcontroller and Embedded Systems 
Byte Addressable SFR with byte address 
SP – Stack printer – 81H 
DPTR – Data pointer 2 bytes 
DPL – Low byte – 82H 
DPH – High byte – 83H 
TMOD – Timer mode control – 89H 
TH0 – Timer 0 Higher order bytes – 8CH 
TL0 – Timer 0 Low order bytes – 8AH 
TH1 – Timer 1 High bytes = 80H 
TL1 – Timer 1 Low order byte = 86H 
SBUF – Serial data buffer = 99H 
PCON – Power control – 87H. 
1.7 INTRODUCTION TO ASSEMBLY LEVEL LANGUAGE 
[Label:] mnemonic [operands] [;comment] 
Mnemonics → assembly level instructions are called mnemonic like MOV R5 
Operands → on which the operation is performed. 
Example: 
Loop: MOVR1, #25H; transfer 25H into R1 
↑ ↑ ↑ ↑ 
Label mnemonics operand comments
The 8051 Microcontroller 15 
→ two instructions which are used to start and terminate program. 
• ORG → this instruction indicate the origin of program ORG 3000H 
→ means program starts from 3000H locn. 
→ this instruction hasn’t take any memory space. It is used to show the 
starting address of program. 
• END → this instruction show the END of program or it is used to terminate 
the program. 
Example: 
ORG 0H; 
Again: MOV R5, # 25H; transistor 25H to R5 
ADD A, R5; Add the R5 with Acc 
SJMP Again; 
END; 
1.8 ASSEMBLY AND RUNNING 8051 PROGRAM 
EDITOR 
PROGRAM 
myfile.asm 
ASSEMBLER 
PROGRAM 
myfile.lst 
myfile.obj 
LINKER 
PROGRAM 
myfile.abs 
OH 
PROGRAM 
myfile.hex 
other obj files 
Fig. 1.7 Flow chart 
Steps: 
• Type your program in editor of software widely used editors are notepad. 
• Save this file with 
file name . asm } depending on assembler 
or file name . src 
notepad produce ASCII file.
16 Microcontroller and Embedded Systems 
• “ASM” source file contains program code assembler converts the instruction 
into machine code and produces “obj” file and “1st file” (object file and 
link file). 
→ Linker program takes one or more object files and produces an absolute 
object file with extension “abs”. 
→ “abs” file is used by 8051 trainer that have a monitor program. 
→ “abs” file is fed into a program code called “OH” (object to Hex con-verter). 
Which create a file with extension “Hex” that is ready to burn into ROM 
→ lst file contains all opcode and address as well as error that assembler 
detected. 
REVIEW QUESTIONS 
1. Differentiate between microprocessor and microcontroller. Draw and explain 
the block diagram of 8051. (RTU-EC-2010) 
2. What do you mean by memory map? How the address range of ROM is 
defined? Write the address range for following memory: 
(a) 8KB ROM (b) 64 KB ROM 
3. Differentiate between RAM and ROM. Draw the structure of RAM in 8051. 
If we want to use the stack from location 30H to 7FH then what is the 
procedure for it? 
4. What do you mean by bit addressability and byte addressability? Explain 
with the help of example. What is the procedure for eliminating the conflict 
of register bank and stack? 
5. Why is the coding done in assembly language instead of being written in 
machine codes directly by programmer? What are different components in 
instruction? (RTU-EC-2010) 
6. What are the different ways of classifying the types of microcontroller and 
list the alternate uses of each pin available in 8051 when used in expanded 
mode? (RTU-EC-2010) 
7. What are the pointers in 8051? Explain the use of each pointer. Explain the 
stack feature in 8051. (RTU-EC-2010) 
8. How the P0 and P2 are used for data bus and address bus and also used as 
Input Output Port? 
9. What is the difference of stack according to operation in 8051, 8085? 
10. Differentiate PSW in 8051 and 8085 also write difference between carry 
flag and OV flag. 
11. Explain the use of SFR available in 8051 also write different types of SFR. 
12. What are the registers available in 8051? What are the functions of 8051 
registers? 
13. What is a memory map? Why is it needed?

Weitere ähnliche Inhalte

Was ist angesagt?

8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
Prof. Swapnil V. Kaware
 
Microprocessor and Application (8085)
Microprocessor and Application (8085)Microprocessor and Application (8085)
Microprocessor and Application (8085)
ufaq kk
 
8051 microcontroller and embedded system
8051 microcontroller and embedded system8051 microcontroller and embedded system
8051 microcontroller and embedded system
sb108ec
 

Was ist angesagt? (20)

Over view of Microprocessor 8085 and its application
Over view of Microprocessor 8085 and its applicationOver view of Microprocessor 8085 and its application
Over view of Microprocessor 8085 and its application
 
Question Bank microcontroller 8051
Question Bank microcontroller 8051Question Bank microcontroller 8051
Question Bank microcontroller 8051
 
INTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLERINTRODUCTION TO MICROCONTROLLER
INTRODUCTION TO MICROCONTROLLER
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware8051 Microcontroller PPT's By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
 
microcontroller-8051-ppt(1)
microcontroller-8051-ppt(1)microcontroller-8051-ppt(1)
microcontroller-8051-ppt(1)
 
Microprocessor and Application (8085)
Microprocessor and Application (8085)Microprocessor and Application (8085)
Microprocessor and Application (8085)
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
8085 micro processor- notes
8085 micro  processor- notes8085 micro  processor- notes
8085 micro processor- notes
 
Introduction to-microprocessor
Introduction to-microprocessorIntroduction to-microprocessor
Introduction to-microprocessor
 
Microcontroller1
Microcontroller1Microcontroller1
Microcontroller1
 
Chapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly LanguageChapter 1-Microprocessors, Microcomputers, and Assembly Language
Chapter 1-Microprocessors, Microcomputers, and Assembly Language
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
8051 microcontroller and embedded system
8051 microcontroller and embedded system8051 microcontroller and embedded system
8051 microcontroller and embedded system
 
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer SystemsChapter 2-8085 Microprocessor Architecture and Microcomputer Systems
Chapter 2-8085 Microprocessor Architecture and Microcomputer Systems
 
Unit II Study of Onchip Peripherals
Unit II Study of Onchip PeripheralsUnit II Study of Onchip Peripherals
Unit II Study of Onchip Peripherals
 
EE8551 MPMC
EE8551  MPMCEE8551  MPMC
EE8551 MPMC
 
Question paper with solution the 8051 microcontroller based embedded systems...
Question paper with solution  the 8051 microcontroller based embedded systems...Question paper with solution  the 8051 microcontroller based embedded systems...
Question paper with solution the 8051 microcontroller based embedded systems...
 
Course material msp430-for_automatic_control
Course material msp430-for_automatic_controlCourse material msp430-for_automatic_control
Course material msp430-for_automatic_control
 
Block diagram of msp430x5xx
Block diagram of msp430x5xxBlock diagram of msp430x5xx
Block diagram of msp430x5xx
 

Andere mochten auch

Developing an aggressive and highly effective Sales and
Developing an aggressive and highly effective Sales andDeveloping an aggressive and highly effective Sales and
Developing an aggressive and highly effective Sales and
Tom Hayhurst
 
Tyutor u sistemi_tkachev6_fm (1)
Tyutor u sistemi_tkachev6_fm (1)Tyutor u sistemi_tkachev6_fm (1)
Tyutor u sistemi_tkachev6_fm (1)
dimka1994
 
Pengenalan i-pengenalan-internet
Pengenalan i-pengenalan-internetPengenalan i-pengenalan-internet
Pengenalan i-pengenalan-internet
Adam51000
 
Kowshikaa consultancy overseas
Kowshikaa consultancy overseas Kowshikaa consultancy overseas
Kowshikaa consultancy overseas
Rajaram Ravindharan
 
Asad adan cis_final_presentation1
Asad adan cis_final_presentation1Asad adan cis_final_presentation1
Asad adan cis_final_presentation1
asadadan
 
Printing_BrandonFrisco
Printing_BrandonFriscoPrinting_BrandonFrisco
Printing_BrandonFrisco
Brandon Frisco
 
Infographic-ConnectedConsumer-FINAL
Infographic-ConnectedConsumer-FINALInfographic-ConnectedConsumer-FINAL
Infographic-ConnectedConsumer-FINAL
Todd Lammie
 
Nov16_Updated Resume_BHOLAKUMAR SONAR
Nov16_Updated Resume_BHOLAKUMAR SONARNov16_Updated Resume_BHOLAKUMAR SONAR
Nov16_Updated Resume_BHOLAKUMAR SONAR
Bholakumar Sonar
 
Are personal relationships the cornerstone of business and
Are personal relationships the cornerstone of business andAre personal relationships the cornerstone of business and
Are personal relationships the cornerstone of business and
Arnaud Veere
 

Andere mochten auch (20)

Royhan kamal
Royhan kamalRoyhan kamal
Royhan kamal
 
Storyboard
StoryboardStoryboard
Storyboard
 
ΓΛΩΣΣΑ Γ΄ ΛΥΚΕΙΟΥ
ΓΛΩΣΣΑ Γ΄ ΛΥΚΕΙΟΥΓΛΩΣΣΑ Γ΄ ΛΥΚΕΙΟΥ
ΓΛΩΣΣΑ Γ΄ ΛΥΚΕΙΟΥ
 
Developing an aggressive and highly effective Sales and
Developing an aggressive and highly effective Sales andDeveloping an aggressive and highly effective Sales and
Developing an aggressive and highly effective Sales and
 
RENAVE Resolução CONTRAN 584 de 23 de Março de 2016
RENAVE Resolução CONTRAN 584 de 23 de Março de 2016RENAVE Resolução CONTRAN 584 de 23 de Março de 2016
RENAVE Resolução CONTRAN 584 de 23 de Março de 2016
 
Recovery Databse dengan SQL Server
Recovery Databse dengan SQL ServerRecovery Databse dengan SQL Server
Recovery Databse dengan SQL Server
 
Tyutor u sistemi_tkachev6_fm (1)
Tyutor u sistemi_tkachev6_fm (1)Tyutor u sistemi_tkachev6_fm (1)
Tyutor u sistemi_tkachev6_fm (1)
 
Islam Mokhtar 2
Islam Mokhtar 2Islam Mokhtar 2
Islam Mokhtar 2
 
Pengenalan i-pengenalan-internet
Pengenalan i-pengenalan-internetPengenalan i-pengenalan-internet
Pengenalan i-pengenalan-internet
 
Kowshikaa consultancy overseas
Kowshikaa consultancy overseas Kowshikaa consultancy overseas
Kowshikaa consultancy overseas
 
Basement Foundation Problem Signs
Basement Foundation Problem Signs Basement Foundation Problem Signs
Basement Foundation Problem Signs
 
Asad adan cis_final_presentation1
Asad adan cis_final_presentation1Asad adan cis_final_presentation1
Asad adan cis_final_presentation1
 
REFORME DU DROIT EUROPEEN DES MARQUES
REFORME DU DROIT EUROPEEN DES MARQUESREFORME DU DROIT EUROPEEN DES MARQUES
REFORME DU DROIT EUROPEEN DES MARQUES
 
ενέργεια
ενέργειαενέργεια
ενέργεια
 
Printing_BrandonFrisco
Printing_BrandonFriscoPrinting_BrandonFrisco
Printing_BrandonFrisco
 
Unit 120 powerpoint
Unit 120 powerpointUnit 120 powerpoint
Unit 120 powerpoint
 
Infographic-ConnectedConsumer-FINAL
Infographic-ConnectedConsumer-FINALInfographic-ConnectedConsumer-FINAL
Infographic-ConnectedConsumer-FINAL
 
результати анкетування
результати анкетуваннярезультати анкетування
результати анкетування
 
Nov16_Updated Resume_BHOLAKUMAR SONAR
Nov16_Updated Resume_BHOLAKUMAR SONARNov16_Updated Resume_BHOLAKUMAR SONAR
Nov16_Updated Resume_BHOLAKUMAR SONAR
 
Are personal relationships the cornerstone of business and
Are personal relationships the cornerstone of business andAre personal relationships the cornerstone of business and
Are personal relationships the cornerstone of business and
 

Ähnlich wie 002079

btech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptxbtech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptx
SKWriters
 
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering studentsEMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
eceprinter6
 
Study of 8051 microcontroller
Study of 8051 microcontrollerStudy of 8051 microcontroller
Study of 8051 microcontroller
918007165995
 
Embedded training report(mcs 51)
Embedded training report(mcs 51)Embedded training report(mcs 51)
Embedded training report(mcs 51)
Gurwinder Singh
 
Ashish microcontroller 8051
Ashish microcontroller 8051Ashish microcontroller 8051
Ashish microcontroller 8051
ASHISH RAJ
 

Ähnlich wie 002079 (20)

SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III  The 8051 MicrocontrollersSYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III  The 8051 Microcontrollers
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
 
AT89 S52
AT89 S52AT89 S52
AT89 S52
 
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxINDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
 
89s52 2
89s52 289s52 2
89s52 2
 
btech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptxbtech 8051 Microcontroller Programing.pptx
btech 8051 Microcontroller Programing.pptx
 
Project report
Project reportProject report
Project report
 
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering studentsEMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
 
Unit1 5-mpi-lecture-notes
Unit1 5-mpi-lecture-notesUnit1 5-mpi-lecture-notes
Unit1 5-mpi-lecture-notes
 
8051.pptx
8051.pptx8051.pptx
8051.pptx
 
8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf
 
Study of 8051 microcontroller
Study of 8051 microcontrollerStudy of 8051 microcontroller
Study of 8051 microcontroller
 
embedded system and microcontroller
 embedded system and microcontroller embedded system and microcontroller
embedded system and microcontroller
 
Embedded system classes in mumbai
Embedded system classes in mumbaiEmbedded system classes in mumbai
Embedded system classes in mumbai
 
Introduction to 8085 Microprocessors
Introduction to 8085 MicroprocessorsIntroduction to 8085 Microprocessors
Introduction to 8085 Microprocessors
 
Uc1(vii sem)
Uc1(vii sem)Uc1(vii sem)
Uc1(vii sem)
 
Embedded training report(mcs 51)
Embedded training report(mcs 51)Embedded training report(mcs 51)
Embedded training report(mcs 51)
 
8051 dev board guide
8051 dev board guide8051 dev board guide
8051 dev board guide
 
Ashish microcontroller 8051
Ashish microcontroller 8051Ashish microcontroller 8051
Ashish microcontroller 8051
 
8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
B sc e5.2 mp unit 4 mc-8051
B sc e5.2 mp unit 4 mc-8051B sc e5.2 mp unit 4 mc-8051
B sc e5.2 mp unit 4 mc-8051
 

Kürzlich hochgeladen

Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
ydyuyu
 

Kürzlich hochgeladen (20)

Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
APNIC Policy Roundup, presented by Sunny Chendi at the 5th ICANN APAC-TWNIC E...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
Wadgaon Sheri $ Call Girls Pune 10k @ I'm VIP Independent Escorts Girls 80057...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 

002079

  • 1. Chapter 1 The 8051 Microcontroller 1.1 INTRODUCTION The microcontroller incorporates all the features that are found in microprocessor. The microcontroller has built in ROM, RAM, Input Output ports, Serial Port, timers, interrupts and clock circuit. A microcontroller is an entire computer manufactured on a single chip. Microcontrollers are usually dedicated devices embedded within an application. For example, microcontrollers are used as engine controllers in automobiles and as exposure and focus controllers in cameras. In order to serve these applications, they have a high concentration of on-chip facilities such as serial ports, parallel input output ports, timers, counters, interrupt control, analog-to-digital converters, random access memory, read only memory, etc. The I/O, memory, and on-chip peripherals of a microcontroller are selected depending on the specifics of the target application. Since microcontrollers are powerful digital processors, the degree of control and programmability they provide significantly enhances the effectiveness of the application. The 8051 is the first microcontroller of the MCS-51 family introduced by Intel Corporation at the end of the 1970s. The 8051 family with its many enhanced members enjoys the largest market share, estimated to be about 40%, among the various microcontroller architectures. The microcontroller has on chip peripheral devices. In this unit firstly we differentiate microcontroller from microprocessor then we will discuss about Hardware details of 8051 and then introduce the Assembly level language in brief. Microcontrollers • Microcontroller (MC) may be called computer on chip since it has basic features of microprocessor with internal ROM, RAM, Parallel and serial ports within single chip. Or we can say microprocessor with memory and ports is called as microcontroller. This is widely used in washing machines, vcd player, microwave oven, robotics or in industries.
  • 2. 2 Microcontroller and Embedded Systems • Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC. • 8 bit microcontroller, means it can read, write and process 8 bit data. Ex. 8051 microcontroller. Basically 8 bit specifies the size of data bus. 8 bit microcontroller means 8 bit data can travel on the data bus or we can read, write process 8 bit data. 1.2 DIFFERENCE BETWEEN MICROCONTROLLER AND MICROPROCESSOR Data bus CPU General Purpose Micro-processor RAM ROM I / O Port Timer Serial COM Port Address bus CPU RAM ROM I / O Timer Serial COM Port (a) General-purpose Microprocessor System (b) Microcontroller Fig. 1.1 Structure of microprocessor and microcontroller It is very clear from figure that in microprocessor we have to interface additional circuitry for providing the function of memory and ports, for example we have to interface external RAM for data storage, ROM for program storage, programmable peripheral interface (PPI) 8255 for the Input Output ports, 8253 for timers, USART for serial port. While in the microcontroller RAM, ROM, I/O ports, timers and serial communication ports are in built. Because of this it is called as “system on chip”. So in micro-controller there is no necessity of additional circuitry which is interfaced in the microprocessor because memory and input output ports are inbuilt in the microcontroller. Microcontroller gives the satisfactory performance for small applications. But for large applications the memory requirement is limited because only 64 KB memory is available for program storage. So for large applications we prefer microprocessor than microcontroller due to its high processing speed. 1.3 CRITERIA FOR SELECTION OF A MICROCONTROLLER IN EMBEDDED SYSTEM Criteria for selection of microcontroller in any embedded system is as following: (a) Meeting the computing needs of task at hand efficiently and cost effectively • Speed of operation • Packing
  • 3. The 8051 Microcontroller 3 • Power consumption • Amount of RAM and ROM on chip • No. of I/O pins and timers on chip • Cost (b) Availability of software development tools such as compiler, assembler and debugger. 1.4 MICROCONTROLLER 8051 ARCHITECTURE It is 8-bit microcontroller, means MC 8051 can Read, Write and Process 8 bit data. This is mostly used microcontroller in the robotics, home appliances like mp3 player, washing machines, electronic iron and industries. Mostly used blocks in the architecture of 8051 are as follows: EXTERNAL INTERRUPTS INTERRUPT CONTROL ON-CHIP ROM for program code ON-CHIP RAM ETC. TIMER 0 TIMER 1 T1 T0 COUNTER INPUTS CPU OSC 30PF 30PF 4 to 30 MHz BUS CONTROL 4 I / O PORTS SERIAL PORT P0 P1 P2 P3 normally 11.0592 MHz ADDRESS / DATA TXD RXD INT0 INT1 Fig. 1.2 8051 architecture 1.4.1 128 Byte RAM for Data Storage MC 8051 has 128 byte Random Access memory for data storage. Random access memory is non volatile memory. During execution for storing the data the RAM is used. RAM consists of the register banks, stack for temporary data storage. It also consists of some special function register (SFR) which are used for some specific purpose like timer, input output ports etc. Normally microcontroller has 256 byte RAM in which 128 byte is used for user space which is normally Register
  • 4. 4 Microcontroller and Embedded Systems banks and stack. But other 128 byte RAM which consists of SFRs. We will discuss the RAM in detail in next section. Now what is the meaning of 128 byte RAM. What are address range which is provided for data storage. We will discuss here. We know that 128 byte = 27 byte 7 6 5 4 3 2 1 0 0 if initial address is then final or last address is 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 (00H) (7FH) 7 F Since 27 bytes so last 7 bits can be changed so total locations are from 00H to 7F H. This procedure of calculating the memory address is called as “memory mapping”. We can save data on memory locations from 00H to 7FH. Means total 128 byte space from 00H to 7FH is provided for data storage. 1.4.2 4KB ROM • In 8051, 4KB read only memory (ROM) is available for program storage. This is used for permanent data storage. Or the data which is not changed during the processing like the program or algorithm for specific applications. • This is volatile memory; the data saved in this memory does not disappear after power failure. • We can interface up to 64KB ROM memory externally if the application is large. These sizes are specified different by their companies. • Address Range of PC: Address range of PC means program counter (which points the next instruction to be executing) can be moved between these locations or we can save the program from this location to this location. The address range can be calculated in the same way just like the RAM which is discussed in previous section. 4KB = 22 ◊ 210 B(since 1KB = 210 B) = 212 Byte Address range of PC is 0000H to 0FFFH means total 4KB locations are available from 0000H to 0FFFH. At which we can save the program.
  • 5. The 8051 Microcontroller 5 Difference between RAM and ROM • RAM is used for data storage while ROM is used for program storage. • Data of RAM can be changed during processing while data of ROM can’t be changed during processing. • We can take an example of calculator. If we want to perform addition of two numbers then we type the two numbers in calculator, this is saved in the RAM, but the Algorithms by which the calculation is performed is saved in the ROM. Data which is given by us to calculator can be changed but the algorithm or program by which calculation is performed can’t be changed. 1.4.3 Timers and Counters Timer means which can give the delay of particular time between some events. For example on or off the lights after every 2 sec. This delay can be provided through some assembly program but in microcontroller two hardware pins are available for delay generation. These hardware pins can be also used for counting some external events. How much times a number is repeated in the given table is calculated by the counter. • In MC8051, two timer pins are available T0 and T1, by these timers we can give the delay of particular time if we use these in timer mode. • We can count external pulses at these pins if we use these pins in counter mode. • 16 bits timers are available. Means we can generate delay between 0000H to FFFFH. • Two special function registers are available. • If we want to load T0 with 16 bit data then we can load separate lower 8 bit in TL0 and higher 8 bit in TH0. • In the same way for T1. • TMOD, TCON registers are used for controlling timer operation. 1.4.4 Serial Port • There are two pins available for serial communication TXD and RXD. • Normally TXD is used for transmitting serial data which is in SBUF register, RXD is used for receiving the serial data. • SCON register is used for controlling the operation. • There are four modes of serial communication which has been discussed in next chapter.
  • 6. 6 Microcontroller and Embedded Systems 1.4.5 Input Output Ports • There are four input output ports available P0, P1, P2, P3. • Each port is 8 bit wide and has special function register P0, P1, P2, P3 which are bit addressable means each bit can be set or reset by the Bit instructions (SETB for high, CLR for low) independently. • The data at any port which is transmitting or receiving is in these registers. • The port 0 can perform dual works. It is also used as Lower order address bus (A0 to A7) multiplexed with 8 bit data bus P0.0 to P0.7 is AD0 to AD7 respectively the address bus and data bus is demultiplex by the ALE signal and latch which is further discussed in details. • Port 2 can be used as I/O port as well as higher order address bus A8 to A15. • Port 3 also have dual functions it can be worked as I/O as well as each pin of P3 has specific function. P3.0 – RXD – {Serial I / P for Asynchronous communication Serial O / P for synchronous communication. P3.1 – TXD – Serial data transmit. P3.2 – INT0 – External Interrupt 0. P3.3 – INT1 – External Interrupt 1. P3.4 – T0 – Clock input for counter 0. P3.5 – T1 – Clock input for counter 1. P3.6 – WR – Signal for writing to external memory. P3.7 – RD – Signal for reading from external memory. When external memory is interfaced with 8051 then P0 and P2 can’t be worked as I/O port they works as address bus and data bus, otherwise they can be accessed as I/O ports. 1.4.6 Oscillator • It is used for providing the clock to MC8051 which decides the speed or baud rate of MC. • We use crystal which frequency vary from 4MHz to 30 MHz, normally we use 11.0592 MHz frequency. 1.4.7 Interrupts • Interrupts are defined as requests because they can be refused (masked) if they are not used, that is when an interrupt is acknowledged. A special set of events or routines are followed to handle the interrupts. These special routines are known as interrupt handler or interrupt service routines (ISR). These are located at a special location in memory. • INT0 and INT1 are the pins for external interrupts.
  • 7. The 8051 Microcontroller 7 1.5 PIN DIAGRAM OF 8051 1 40 2 39 3 38 4 37 5 36 8051 6 35 (8031) 7 (89420) 34 8 33 9 32 10 31 11 30 12 29 13 28 14 27 15 26 16 25 17 24 18 23 19 22 20 21 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 P1.18 RST (RXD) P3.0 (TXD) P3.1 (INT0) P3.2 (INT1) P3.3 (T0) P3.4 (T1) P3.5 (WR) P3.6 (RD) P3.7 XTAL2 XTAL1 GND Vcc P0.0 (AD0) P0.1 (AD1) P0.2 (AD2) P0.3 (AD3) P0.4 (AD4) P0.5 (AD5) P0.6 (AD6) P0.7 (AD7) EA / VPP ALE / PROG PSEN P2.7 (A15) P2.6 (A14) P2.5 (A13) P2.4 (A12) P2.3 (A11) P2.2 (A10) P2.1 (A9) P2.0 (A8) Fig. 1.3 Pin diagram of MC 8051 Description of each pin is discussed here: • VCC → 5V supply • VSS → GND • XTAL2/XTALI are for oscillator input • Port 0 – 32 to 39 – AD0/AD7 and P0.0 to P0.7 • Port 1 – 1 to 8 – P1.0 to P1.7 • Port 2 – 21 to 28 – P2.0 to P2.7 and A 8 to A15 • Port 3 – 10 to 17 – P3.0 to P3.7 • P 3.0 – RXD – Serial data input – SBUF • P 3.1 – TXD – Serial data output – SBUF • P 3.2 – INT0 – External interrupt 0 – TCON 0.1 • P 3.3 – INT1 – External interrupt 1 – TCON 0.3 • P 3.4 – T0 – External timer 0 input – TMOD
  • 8. 8 Microcontroller and Embedded Systems • P 3.5 – T1 – External timer 1 input – TMOD • P 3.6 –WR – External memory write cycle – Active LOW • P 3.7 – RD – External memory read cycle – Active LOW • RST – for Restarting 8051 • ALE – Address latch enable 1 – Address on AD 0 to AD 7 0 – Data on AD 0 to AD 7 • PSEN – Program store enable 1.6 ARCHITECTURE OF 8051 Figure 1.4 shows the architecture block diagram of 8051. Arithmetic and Logic Unit PSW Special Function Registers RAM Latch Latch Latch Latch Port0Port 1 Port 3 Port 2 A B I / O AD –AD 7 0 I / O I / O A –A 15 8 I / O Interrupt (INT INT ) 0,9 1 Counter (T T ) 0,9 1 Serial Data (TXD, RXD) RD, WR 8-Bit Data and Address Bus PC ROM 16-Bit Address Bus DPTR DPH DPL EA ALE PSEN XTAL1 XTAL2 RESET Vcc GND System Timing System Interrupts Timers Data Buffers Memory Control Byte/Bit Addresses Register Bank 3 Register Bank 2 Register Bank 1 Register Bank 0 Special Function Register IE IP PCON SBUF SCON TCON TMOD TL0 TH0 TL1 TH1 Internal RAM Structure Fig. 1.4 Architectural block diagram of microcontroller 8051
  • 9. The 8051 Microcontroller 9 Each block will be discussed step by step: 1.6.1 ALU — Arithmetic Logical Unit This unit is used for the arithmetic calculations. 1.6.2 A-Accumulator This register is used for arithmetic operations. This is also bit addressable and 8 bit register. 1.6.3 B-Register This register is used in only two instructions MUL AB and DIV AB. This is also bit addressable and 8 bit register. 1.6.4 PC-Program Counter • Points to the address of next instruction to be executed from ROM • It is 16 bit register means the 8051 can access program address from 0000H to FFFFH. A total of 64KB of code. 16 bit register means. Initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 (0000H) Final value 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 (F F F FH) • Initially PC has 0000H • ORG instruction is used to initialize the PC ORG 0000H means PC initialize by 0000H • PC is incremented after each instruction. Example: Mnemonics Machine codes MOV R5, #25H 7D 25 MOV A, #00H 74 00 ADD A, R5 2D HERE: SJMP HERE; 80 FE • When 7D is accessed then PC locate the 0001H (next instruction to be executed) • When 00 is accessed then PC locate the 0004H (next instruction to be executed) 1.6.5 ROM Memory Map in 8051 → 4KB, 8KB, 16KB, 32KB, 64KB on chip ROM is available. → Max ROM space is 64 KB because 16 bit address line is available in 8051. → Starting address for ROM is 0000H (because PC which points the ROM is 16 bit wide). PC ROM 7D 25 74 00 2D 80 FE 0000H 0001H 0002H 0003H 0004H 0005H 0006H Fig. 1.5 ROM locations
  • 10. 10 Microcontroller and Embedded Systems Ex. For AT89C51 find the address range of ROM. Sol. 4KB ROM = 22. 210 = 212B So 12 bits can be changed. (0000H) 000 0 00 0 0 0 0 0 0 0 0 00 (Starting Address) (0FFFH) 000 0 11 1 1 1 1 1 1 1 1 11 (Max Address) Memory address from 0000H to 0FFFH. 1.6.6 8051 Flag Bits and PSW Register → Used to indicate the Arithmetic condition of ACC. → Flag register in 8051 is called as program status word (PSW). This special function register PSW is also bit addressable and 8 bit wide means each bit can be set or reset independently. PSW0.7 PSW0.6 PSW0.5 PSW0.4 PSW0.3 PSW0.2 PSW0.1 PSW0.0 CY AC F0 RS1 RS0 OV — P FLAG Register There are four flags in 8051 • P → Parity flag → PSW 0.0 1 – odd number of 1 in ACC 0 – even number of 1 in ACC • OV(PSW 0.2) → overflow flag → this is used to detect error in signed arithmetic operation. This is similar to carry flag but difference is only that carry flag is used for unsigned operation. • RS1(PSW0.4) RS0(PSW0.3) Register Bank Select 0 0 Bank 0 0 1 Bank 1 1 0 Bank 2 1 1 Bank 3 for selecting Bank 1, we use following commands SETB PSW0.3 (means RS0=1) CLR PSW0.4 (means RS1=0) Initially by default always Bank 0 is selected. • F0 → user definable bit • AC → Auxiliary carry flag → when carry is generated from D3 to D4, it is set to 1, it is used in BCD arithmetic. 1 1 0 0 0 0 1 1 1 0 (0EH) 0 1 0 1 1 0 1 0 (5AH) 0 1 1 0 1 0 0 0 (38H) +
  • 11. The 8051 Microcontroller 11 Since carry is generated from D3 to D4, so AC is set. • CY → carry flag → Affected after 8 bit addition and subtraction. It is used to detect error in unsigned arithmetic opr. We can also use it as single bit storage. SETB C → for cy = 1 CLR C → for cy = 0 1.6.7 Structure of RAM or 8051 Register Bank and Stack → 128 byte RAM is available in 8051 → 128 byte = 27B Address Range 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 (00H) (7FH) 7 bits 0 Address range of RAM is 00H to 7FH. → In MC8051, 128 byte visible or user accessible RAM is available which is shown in figure. Extra 128B RAM which is not user accessible. 80H to FFH used for storage of SFR (special function register) Scratch Pad RAM 7FH 30H 2FH 1FH 08 09 00 01 02 03 04 05 06 07 20H 1FH 18H 17H 10H 0FH 08H 07H 00H R7 R0 R7 R0 R7 R0 R7 R0 Bank 3 Bank 2 Bank 1 Bank 0 Bit addressable RAM Stack SP = 07 (initially) Fig. 1.6 Structure of RAM → Four Register Banks → There are four register banks, in each register bank there are eight 8 bit register available from R0 to R7 → By default Bank 0 is selected. For Bank 0, R0 has address 00H
  • 12. 12 Microcontroller and Embedded Systems R1 has address 01H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . R7 has address 07H For Bank 1, R0 has address 08H R1 has address 09H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . R7 has address 0FH For selecting banks we use RS0 and RS1 bit of PSW. → R0 to R7 registers are byte addressable means. 7 6 5 4 3 2 1 0 0 0 0 0 0 0 0 0 R0 If we want to set the bit 3 of R0 then we can’t use SETB R0.3 We use MOV R0, #08H; For changing single bit we can modify all the other bits of R0. → Locations 20H to 2FH is bit addressable RAM means each bit from 00H to FFH in this we can set or reset CF rather than changing whole byte. → Locations 30H to 7FH is used as scratch pad means we can use this space for data reading and writing or for data storage. 1.6.8 Stack in 8051 → RAM locations from 08H to 1FH can be used as stack. Stack is used to store the data temporarily. Stack is last in first out (LIFO) → Stack pointer (SP) → • 8bit register • It indicate current RAM address available for stack or it points the top of stack. • Initially by default at 07H because first location of stack is 08H. • After each PUSH instruction the SP is incremented by one while in MC after PUSH instruction SP is decremented. • After each POP instruction the SP is decremented. Example: MOV R6,#25H; MOV R1,#12H; MOV R4,#OF3H; PUSH 06H; PUSH 01H; POP 04H;
  • 13. The 8051 Microcontroller 13 0B 0A 09 08 initially SP = 074 PUSH 06 PUSH 014 POP 04 R4 = 124 25 12(R1) 25(R6) 25(R6) SP = 084 SP = 09 → if we want to use more than 24byte (08H to 1FH) of stack. We can change SP to point RAM address 30H to 7FH by MOV SP, #XX Any value from 30 to 7FH 1.6.8.1 Conflicting of Register Banks and Stack → We know locations from 08H to 1FH is used as stack and it is also used as register bank. → If in the program, we use the Register Bank 1 to 3 and also use the stack then conflicts exist and error can be possible. For removing this situation we use the stack from location 30H to 7FH by shifting SP to 2FH. MOV SP,#2FH; 1.6.9 DPTR →→→→ Data Pointer in 8051 → 16 bit register, it is divided into two parts DPH and DPL. → DPH for Higher order 8 bits, DPL for lower order 8 bits. → DPTR, DPH, DPL these all are SFRs in 8051. 1.6.10 Special Function Register →→→→ (See Fig.) RAM scratch pad, there is extra 128 byte RAM which is used to store the SFRs →→→→ Following figure shows special function bit address, all access to the four I/O ports CPU register, interrupt control register, timer/counter, UART, power control are performed through registers between 80H and FFH.
  • 14. 14 Microcontroller and Embedded Systems Byte Addressable SFR with byte address SP – Stack printer – 81H DPTR – Data pointer 2 bytes DPL – Low byte – 82H DPH – High byte – 83H TMOD – Timer mode control – 89H TH0 – Timer 0 Higher order bytes – 8CH TL0 – Timer 0 Low order bytes – 8AH TH1 – Timer 1 High bytes = 80H TL1 – Timer 1 Low order byte = 86H SBUF – Serial data buffer = 99H PCON – Power control – 87H. 1.7 INTRODUCTION TO ASSEMBLY LEVEL LANGUAGE [Label:] mnemonic [operands] [;comment] Mnemonics → assembly level instructions are called mnemonic like MOV R5 Operands → on which the operation is performed. Example: Loop: MOVR1, #25H; transfer 25H into R1 ↑ ↑ ↑ ↑ Label mnemonics operand comments
  • 15. The 8051 Microcontroller 15 → two instructions which are used to start and terminate program. • ORG → this instruction indicate the origin of program ORG 3000H → means program starts from 3000H locn. → this instruction hasn’t take any memory space. It is used to show the starting address of program. • END → this instruction show the END of program or it is used to terminate the program. Example: ORG 0H; Again: MOV R5, # 25H; transistor 25H to R5 ADD A, R5; Add the R5 with Acc SJMP Again; END; 1.8 ASSEMBLY AND RUNNING 8051 PROGRAM EDITOR PROGRAM myfile.asm ASSEMBLER PROGRAM myfile.lst myfile.obj LINKER PROGRAM myfile.abs OH PROGRAM myfile.hex other obj files Fig. 1.7 Flow chart Steps: • Type your program in editor of software widely used editors are notepad. • Save this file with file name . asm } depending on assembler or file name . src notepad produce ASCII file.
  • 16. 16 Microcontroller and Embedded Systems • “ASM” source file contains program code assembler converts the instruction into machine code and produces “obj” file and “1st file” (object file and link file). → Linker program takes one or more object files and produces an absolute object file with extension “abs”. → “abs” file is used by 8051 trainer that have a monitor program. → “abs” file is fed into a program code called “OH” (object to Hex con-verter). Which create a file with extension “Hex” that is ready to burn into ROM → lst file contains all opcode and address as well as error that assembler detected. REVIEW QUESTIONS 1. Differentiate between microprocessor and microcontroller. Draw and explain the block diagram of 8051. (RTU-EC-2010) 2. What do you mean by memory map? How the address range of ROM is defined? Write the address range for following memory: (a) 8KB ROM (b) 64 KB ROM 3. Differentiate between RAM and ROM. Draw the structure of RAM in 8051. If we want to use the stack from location 30H to 7FH then what is the procedure for it? 4. What do you mean by bit addressability and byte addressability? Explain with the help of example. What is the procedure for eliminating the conflict of register bank and stack? 5. Why is the coding done in assembly language instead of being written in machine codes directly by programmer? What are different components in instruction? (RTU-EC-2010) 6. What are the different ways of classifying the types of microcontroller and list the alternate uses of each pin available in 8051 when used in expanded mode? (RTU-EC-2010) 7. What are the pointers in 8051? Explain the use of each pointer. Explain the stack feature in 8051. (RTU-EC-2010) 8. How the P0 and P2 are used for data bus and address bus and also used as Input Output Port? 9. What is the difference of stack according to operation in 8051, 8085? 10. Differentiate PSW in 8051 and 8085 also write difference between carry flag and OV flag. 11. Explain the use of SFR available in 8051 also write different types of SFR. 12. What are the registers available in 8051? What are the functions of 8051 registers? 13. What is a memory map? Why is it needed?