Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

1. Explain the architecture of 8051 microcontroller.

Program counter:
Draw the block diagram of 8051 microcontroller and explain. • It is a 16 bit address register.
• It is used to hold the address of the instruction executed next.
The 8051 microcontroller has internal blocks of ALU, memory, timing & control Data Pointer:
unit etc. • It is a 16 bit address register.
• It is used as pointer to access external memory.
• It can be accessed as separate 8 bit registers as DPL and DPH.
PSW register:
• IT is a bit addressable 8 bit status register.
• It is used to select register bank and to store the status of the last
output result
• It has CY, AC, OV, P flag bit registers.
Stack pointer:
• It is a 8 bit address register
• It is used as pointer to access internal RAM memoruy.
• Stack operations are performed through SP register.
Memory:
RAM:
• 8051 microcontroller has 128 bytes of internal RAM to store data
• It is accessed by addresses from 00 H to FF H.
ROM:
• It has 4 kilo Bytes of internal ROM to store program.
• It is accessed through 16 bit addresses from 0000 H to 0FFF H
Timer/counter
• It has two timer (T0 & T1)
• It is used to generate time delay and used to count external pulses.
ALU (Arithmetic and logic unit)
Timing and control unit
• It is the CPU of microcontroller.
• This unit control and synchronises all the operations in microcontroller
• It performs arithmetic operation (addition, subtraction, multiplication, in proper sequence.
division) and logic operation (AND,OR,EX-OR,NOT) on 8 bit data. Instruction register:
A register (Accumulator)
• It is a 8 bit register.
• It is a bit addressable 8 bit data register.
• The instruction fetched from ROM is kept in this register and
• It is used to store input and output data when addition, subtraction, processed.
multiplication and division operation. Control registers.
B register:
• IE, IP registers – control interrupt operations.
• It is a bit addressable 8 bit register.
• SCON, PCON – control serial communication.
• It is used to store input and output data when multiplication and division
• TCON, TMOD – control timer/counter operation.
operation.
2. Explain the Pin details of 8051 microcontroller. • This port is also used for other functions like interrupts, timer input,
control signal for external memory interfacing RD, WR and serial
communication signal RxD & TxD.
Pin 18 – 19 : XTAL1, XTAL2
• These pins are used to connect external crystal to generate system
clock signal.
Pin 20 : Vss
• Ground connection pin.
Pin 21 – 28 : ( P2.0 to P2.7)
• Multifunction I/O port.
• These 8 pins are used as input and output port.
• This port is also used for sending higher order byte addresses to
external memory unit.
Pin 29 : PSEN (Program store enable)
• It is a read control signal to fetch instruction from external program
memory.
Pin 30 : ALE (Address Latch Enable)
• This signal is used to indicate the address transfer over address/data
multiplexed bus (port 0)
Pin 1 – 8 : (P1.0 to P1.7) • If ALE = 0 , data is transferred through port 0 lines.
• Single function I/O port. • If ALE =1 , address is transferred through port 0 lines.
• It is a bidirectional input and output port. Pin 31 : EA (External access enable input)
• It has internal pull-up resistors.
• It is used to anable or disable external program memory interfacing.
Pin 9 : RST. • If EA = 0 , External ROM can be accessed.
• Reset input. • If EA =1 , external ROM cannot be accessed.
• Applying high value for 2 machines cycle at this pin, resets Pin 32 – 39 : (P0.0 to P0.7)
microcontroller.
• All the registers are cleared. • Multifunction I/o port.
• These 8 pin are used as input and output port.
Pin 10 – 17 : ( P3.0 to P3.7)
• This port is also used to transfer data to external memory and to send
• Multifunction I/O port. lower order address byte to external memory.
• These 8 pins used as input and output port. Pin 40 : +Vcc
• +5 V DC supply is given to microcontroller through this pin.
• 8051 microcontroller has 128 bytes of on chip RAM for data storage.
• MOV instructions are used to access internal RAM.
3. Explain the Memory Organisation of 8051 microcontroller. • The addresses 00 H to 7F h are used to access internal RAM.
• The 8051 microcontroller has two types of memory. • They are divided into three portions
• They are program memory and data memory. i. Register bank
• Program memory (ROM) is used to save program permanently. ii. Bit addressable locations
• Data memory ( RAM) is used to store data temporarily.’ iii. General purpose RAM.
• 8051 microcontroller has 128 bytes of internal RAM and 4 kilo Bytes of
internal ROM. Register Bank
• And 8051 microcontroller has 16-bit addressing bus and are capable of • There are four register bank from 00 H to 1F h.
addressing 64 KB memory. • Register bank 0 , Register bank 1 , Register bank 2 and Register bank 3
• RS1 and RS0 bits in PSW register decides \register bank being accessed.
Program memory: • Each register bank have eight registers named R0, R1, R2 FR7.
• 8051 microcontroller has 4 KB of internal On-chip Rom for program Bit addressable locations:
storage. • 8051 microcontroller has 216 bit addressable locations.
• If the inbuilt memory is not sufficient, additional memory can be added • 128 locations are from RAM addresses 20 H to 2F H.
externally up to 64 KB. • Each 128 locations have individual bit address from 002 H 7F h.
• To access external ROM, the pin EA must be connected to GND. • In this location, any single bit can be set or reset by program.
• If EA is connected to Vcc ( +5 V) , the program addresses ( 0000 H to • Remaining 88 bit locations are from special function registers.
0FFF H) are directed to internal ROM and addresses ( 1000 H to FFFF H )
are directed to external ROM. General purpose RAM:
• If EA is connected to ground, the addresses 0000 H to FFFF H are • The address from 30 H to 7F H are general purpose byte addressable
directed to external ROM alone. locations.
• These 80 bytes of memory used for general purpose data storage.
DATA memory :
Special Function registers:
Internal RAM: • More than 128 bytes of Ram, 21 special function registers (SFR) are
available inside microcontroller.
• They are arranged from addresses 80 h to FF h.
• They are used for particular function they have been assigned.
• Among 21 registers, 11 are bit and byte addressable.
• Other 10 registers are only byte addressable.
External RAM:
• When internal RAM of 128 Bytes are not sufficient for data storage, up
to 64 KB of external RAM can be added.
• RD and WR control signal are used to access external RAM.
• MOVX instruction is used to access external RAM.
• When accessing external RAM, data pointer DPTR is used to hold
memory addresses.
4. Classify the instruction set of 8051 microcontroller and Logic instructions
explain with example. • The instructions that perform logic operations ( AND, OR, EX-OR,
• The 8051 microcontroller has 111 instructions. NOT) are known as logic instructions.
• They are classified into 5 categories based on their functions. • It also shifts the data in the A register.
• They are
Mnemonics: ANL,ORL,XRL,CPL,RLA, RLCA, RRA, RRC A.
i. Data transfer instructions
ii. Arithmetic instructions Example:
iii. Logic instructions
iv. Program branching instructions ANL A,R0 : Bitwise AND operation is performed between 8 bit data in A
v. Bit manipulation instruction register and R0 register and the result is stored in A register.

Data transfer instruction: ORL A,R0 : Bitwise OR operation is performed between 8 bit data in A register
and R0 register and the result is stored in A register.
• The instructions that performs data transfer between registers, memory
are known as data transfer instructions. Program branching instructions :
• The copy data from one register to another register, one memory location • The instructions that control the sequence of program execution are
to another memory location, I/O ports. known as program branching instructions.
• This instruction also used to exchange data between registers. • The se instructions change the address in the program counter (PC)
Mnemonics : MOV, MOVX,MOVC,XCH,XCHD,PUSH,POP. register.

Example: Mnemonic: SJMP, LJMP, ACALL, LCALL,DJNZ,CJNE..etc

MOV A,R0 : copies 8 bit data from R0 register to A register. Example :

MOVX @DPTR, A : Copies 8 bit data in A register to external memory pointed LJMP 8200 H : program execution is jumped to the instruction located at 8200
H address.
by DPTR register.
SJMP FA H : program execution is jumped to instruction located by relative
Arithmetic instructions: address FA h.
• The instructions that perform arithmetic operations ( addition , Bit manipulation instruction:
subtraction, multiplication and division) are known as arithmetic
instructions. • The instructions that are capable of processing single bit of data are
known as bit manipulation instructions.
Mnemonic :ADD,ADDC,SUBB,MUL,DIV,INC,DEC,DAA. • These instructions accesses single bit data by their bit addresses.
Example: Mnemonic: SETB, CLR, CPL..etc
ADD A, R0 : the 8 bit data in R0 register is added with 8 bit data in A register and Example :
the result is stored in A register.
SETB C : it sets the carry flag value to ‘1’
SUBB A, R0 : the 8 bit data in R0 register is subtracted from 8 bit data in A
register and the result is stored in A register. CLR C : It clears the carry flag value to ‘0’ .
5. Explain the different Addressing modes of 8051 in detail. Indirect addressing mode :
• The different methods of accessing data is known as addressing modes. • In indirect addressing mode, the data are accessed through addresses
• There are 6 addressing modes. stored in R0 and R1 registers indirectly.
i. Immediate addressing mode • Internal and external RAM both can be accessed through indirect
ii. Register addressing mode addressing mode.
iii. Direct addressing mode • @R0 and @R1 terms in a instruction defines indirect addressing mode.
iv. Indirect addressing mode
v. Indexed addressing mode Example:
vi. Register specific addressing mode
ADD A, @R0 : the data in RAM location stored in R0 register, is added with A
Immediate addressing mode register and the result is stored in A register.

• In immediate addressing mode the data is defined with the instruction MOV A, @R0 : the data in RAM location stored in R0 register , is copied to A
itself. register.
• The pound sign ‘#’ in the instruction notifies immediate addressing mode. Indexed Addressing mode:
Example:
• Indexed addressing mode is used to access look up table data stored
ADD A, #22 h : The 8 bit data in A r3egister and immediate data 22 h are added in program memory.
and the result is stored in A register. • PC or DPTR has starting address of lookup table and A register has
table entry number.
MOV R0, # 5E h : The immediate data 5E is copied to R0 register.
Example :
Register addressing mode: MOVC A, @A+PC : the data at address given from adding PC register value
• In register addressing mode, the data are accessed from internal and A register value , is copied to A register.
registers R0,R1,R2,F.R7,DPL,DPH. MOVC A, @A+DPTR : the data at address given from adding DPTR register
Example : value and A register value , is copied to A register.
ADD A ,R0 :the 8 bit data in R0 register are added into data in A register and the Register specific addressing mode:
result is stored in A register.
• Microcontroller perform some operations only on the specified
MOV A, R0 : the data ain R0 register is copied to A register. registers.
Direct addressing mode : • In these operations, the operand is identified just from opcode field
itself. This is known as register specific addressing mode.
• In direct addressing mode, data are accessed through their RAM
addresses directly Example:
• By direct addressing mode, internal Ram and SFR can only be accessed. RL A : the 8 bit data in A register is shifted left by 1 position. This operation
Example : can only be done in A register.
ADD A, 22 h : The 8 bit data in A register and data in RAM location ‘22’ h are DA A : After adding two BCD numbers, the result is in HEX . By using this
added and the result is stored in A register. instruction it is converted to BCD value. This operation is only done on A
MOV R0, 5E h : The data in RAM location ‘5E’ h is copied to R0 register. register.

You might also like