Professional Documents
Culture Documents
8051 ARCHITECTURE
12 marks questions
Unit – I
1. Describe the architecture of 8051 with a neat diagram.
2. Explain the interrupt structure, SFR and timers of 8051.
3. i) Explain the different serial communication modes in 8051.
ii) Explain the memory structure of 8051.
4. Give the PIN details of an 8051 micro controller and explain.
5. i) Explain the internal RAM organization of 8051.
ii) Explain TCON, SCON and TMOD SFRs of 8051.
6. Explain memory organization of 8051
7. Explain timer/counter of 8051 in detail.
8. Give steps to program 8051 for serial data transfer.
9. Explain the ports and circuits of 8051 micro controller
NY
10. Briefly explain the external memory of 8051 microcontroller.
O
IMPORTANCES TWO MARK QUESTIONS & ANSWERS
1. Features of 8051microcontroller.
NT
· 8 bit controller operating on bit and byte.
· 256 bytes internal RAM and 4 kb internal RAM
· 64/60 kb external program memory address space
A
3. State the functions of RS1 and RS0 bit in the flag register
It is used to select the register banks
RS0 Bank selection
0 0 00 H – 07 H BANK 0
0 1 08H -0F H BANK 1
1 0 10H – 17 H BANK 2
1 1 18 H – 1F H BANK 3
NY
Rotate accumulator right Rotate accumulator right through carry flag
The 8 bits in the accumulator are rotated 1 The 8 bits in the accumulator and the carry
bit to the right.bit 0 is rotated in to the bit 7 flag together rotated 1 bit to the right.bit 0 is
position. No flags are affected. O moves in to the bit carry flag; the original
NT
value of the flag moves in to the bit 7
position. No flags are affected.
A
B7 B6 B5 B4 B3 B2 B1 B0
J.
CY AC F0 RS1 RS0 OF - P
S.
NY
· External interrupt-1
· Timer-1 interrupt
· Serial port interrupts.
O
12. What are the dedicated address pointers in 8051?
NT
· Program counter
· Data pointer.
· The PC is used as address pointer for program and DPTR is used as address pointer
A
for data.
S.
· The Reg banks are internal RAM locations of 8051 which can be used as general
purpose Reg or scratch pad reg.
S.
· The first 32 bytes of internal RAM of 8051 and organise as 4 Reg banks with each
bank consisting 8 locations.
· At any one time the processor can work with only one Reg bank depending on the
value of bits RS0 and RS1.
· The 8051 LIFO .Stack can reside anywhere in the internal RAM
· It has 8 bit stack pointer to indicate the top if stack. This can be accessed by PUSH and
POP instructions.
· During PUSH the SP is incremented by 1 and during POP the SP is decremented by 1.
• Serial Interrupt
The program counter keeps track of program execution. To execute a program the starting
NY
address of the program is loaded in program counter. The PC sends out an address to fetch a
byte of instruction from memory and increments its content automatically.
O
NT
************************************************
A
S.
J.
S.
1. What is microcontroller?
Microcontrollers are single-chip microcomputers, more suited for control and
automation of machines and processes. With the help of microcontroller it is possible to
carry out simple arithmetic and logical operations.
2. What are the constituents of microcontrolle r?
Microcontrollers consists of central processing unit(CPU), memory,
input/output(I/O) ports, timers and counters ,analog-to-digital converters(ADC),digital-to-
analog converters(DAC),serial ports, interrupt logic, oscillator circuitry and many more
functional blocks on chip.
3. Write about pin details of 8051.
8051 has four 8-bit I/O ports that are used either as four 8-bit ports or each of the
port pins could be addressed individually. There are pins for crystal connections, program
store enable, address latch enable and for external access.
4. Write about me mory organisation of 8051.
NY
It has 64k external data memory, 64k program memory and 256 bytes of internal data
memory. The 64k program memory space of 8051 is divided in to external and internal
memory.
5. Define interrupt. O
NT
Interrupt is an input to the processor that indicates the occurrence of an event.
· External interrupt 1
· Timer/counter 0 interrupt
J.
· Timer/counter 1 interrupt
· Serial port interrupts
S.
8. What are the timer modes of 8051 and how they are determined?
There are 4 timer modes in 8051. The pins M1, M0 determine these modes.
9. M1 10. M0 11. Modes
12. 0 13. 0 14. Mode 0
15. 0 16. 1 17. Mode 1
18. 1 19. 0 20. Mode 2
21. 1 22. 1 23. Mode 3
NY
functions done by 8051.some of the SFRs are
· Program status word
· Data pointer(DPTR)
· Timer registers O
NT
· Control registers
· Capture registers
A
v Calls
v Return
J.
NY
It has many instructions to It has one or two
2. move data between memory instructions to move data
and CPU. between memory and
CPU. O
NT
3. Access times for memory and Less access time
i/o devices are more. required.
A
functioned malfunctioned
20) State the functions of RS1 and RS0 bit in the flag register
It is used to select the register banks
RS1 RS0 Bank selection
0 0 00 H – 07 H BANK 0
0 1 08H -0F H BANK 1
1 0 10H – 17 H BANK 2
1 1 19 – 1F H BANK 3
B7 B6 B5 B4 B3 B2 B1 B0
CY AC F0 RS1 RS0 OF - P
NY
· Data transfer
· Arithmetic
· Logical
· Branching O
NT
· Boolean
· Register addressing
· Direct byte addressing
S.
· Register indirect
· Immediate
J.
· Register specific
S.
· Index
NY
The interrupts are:
Vector address
• Serial Interrupt
J.
NY
9. Write an 8051 ALP to find Fibonacci series of N given numbers.
10. Write an ALP to find the average of given N numbers.
O
IMPORTANCES TWO MARK QUESTIONS & ANSWERS
NT
1. How the baud rate is decided in mode1 and mode3 in the serial trans mission of 8051
· The baud rate depends on SMOD bit of PCON Reg and the yimer-1 overflow
A
2. How to estimate the time taken to execute the instruction in 8031/8051 controller
J.
The instruction that always clear carry flag are CLR C, DIV, MUL.
The Boolean variable instructions can carry or complement or move a particular bit
8. Write a program to perform multiplication of 2 no’s using 8051.
MOV A, #data 1
MOV B, #data 2
MUL AB
MOV DPTR, #5000
NY
9. Write a program to mask the 0th &7th bit using 8051.
MOV A, #data
ANL A,#81 O
NT
MOV DPTR, #4500
1. Direct addressing
J.
2. Register addressing
3. Register indirect addressing.
S.
4. Implicit addressing
5. Immediate addressing
6. Index addressing
7. Bit addressing
14. Write a program to find the 2’s comple ment using 8051.
MOV A,R0
CPL A
NY
INC A
O
15. Write a program to add 2 8-bit numbe rs using 8051.
NT
MOV A,#30H
ADD A,#50H
A
In this mode serial enters &exits through RXD, TXD outputs the shift clock.8 bits
J.
are transmitted/received: 8 data bits (LSB first).The baud rate is fixed at 1/12 the oscillator
frequency.
S.
In this mode 11 bits are transmitted(through TXD)or received (through RXD):a start
bit(0), 8 data bits(LSB first),a programmable 9th data bit ,& a stop bit(1).ON transmit the 9th data
bit (TB* in SCON)can be assigned the value of 0 or 1.Or for eg:, the parity bit(P, in the PSW)could
be moved into TB8.On receive the 9th data bit go in to the RB8 in Special
Function Register SCON, while the stop bit is ignored. The baud rate is programmable to either
1/32or1/64 the oscillator frequency.
MOV A, #data
SWAP A
20. Write a program to subtract two 8-bit numbe rs &exchange the digits using 8051.
MOV A,#9F
MOV R0,#40
SUBB A,R0
SWAP A
NY
21. Write a program to subtract the contents of R1 of Bank 0from the contents of R0 of
Bank 2 using 8051.
MOV PSW,#10 O
NT
MOV A,R0
MOV PSW,#00
A
SUBB A,R1
S.
************************************************
J.
S.
NY
4. Write about PSW ?
PSW – Program Status word
Program Status Word contains several status bits that reflect the current state
O
of the CPU. The PSW is one of the special function registers and contain the carry bit ,
NT
the auxiliary bit , two registers select bits , the overflow flag bit , the parity bit and two user
definable status flag bits .
5. What are the types of operand addressing?
A
OR
S.
* Direct addressing
* Register – indirect addressing
S.
* Immediate addressing
* Base register plus index register indirect addressing .
6. Define register addressing?
Register addressing permits access to eight registers (R0 –R7) of register
band . There are four banks of eight registers . One of the four banks is selected by a 2 – bit
field in PSW . other registers used are A,B,AB and DPTR.
7. What are the operand types of 8051?
* Bytes ,
* Short integers ,
* Bits .
8. Where does direct byte addressing provides operation ?
Direct byte addressing provides operation on one of the following .
1) Lower 128 bytes of internal data RAM ,
2) Special function registers .
9. Where does direct bit addressing provides operation ?
Direct bit addressing provides operation on one of the following .
NY
* Logical instructions ,
* Control transfer instructions.
14 . What are the four addition operations in 8051 ?
ADD O
NT
ADDC
DA
A
INC
15. What are the two subtraction operations ?
S.
* SUBB
* DEC
J.
* Two - operations .
17. List the single – operand logical operations ?
CLR, SETB , CPL , RL , RLC , RR , RRC , SWAP.
18. List the three classes of control transfer operations ?
1) Unconditional calls , returns and jumps ,
2) Conditional jumps ,
3) Interrupts .
19. How does the 8051 know whether a timer / counter is functioning as a time r
or as an event counter ?
There is a bit in the TMOD SFR that specifies whether it is a timer or a
counter .If this bit is set , the timer / counter will work as a counter and if this bit is reset ,
The timer/ counter will work as a timer .
22. How the baud rate is decided in mode1 and mode3 in the serial trans mission of 8051
· The baud rate depends on SMOD bit of PCON reg and the yimer-1 overflow rate
shown below.
· The baud rate in mode 1 or 3= 2 / 32 (timer – 1 overflow rate).
23. How to estimate the time taken to execute the instruction in 8031/8051 controller
• It is obtained by multiplying the time to execute machine cycle by the number of
machine cycles of the instruction. The time to execute a machine time is 12 clock periods.
NY
• Time to execute an instruction=C *12* T=C *12 *1/F.
·
O
External program memory fetch cycle.
NT
· External data memory read cycle.
· External data memory write cycle.
A
25. List the instruction of 8051 that all the flag of 8051
The 8051 instruction that affect all the flag are ADD, ADDC, and SUBB
J.
26. List the instruction of 8051 that affect overflow flag in 8051.
S.
The 8051 instruction that affect overflag are ADD, ADDC, DIV, MUL, and SUBB.
27. List the instruction of 8051 that always clear carry flag.
The instruction that always clear carry flag are CLR C, DIV, MUL.
28. What are the operations performe d by Boolean variable instruction of 8051?
The Boolean variable instructions can carry or complement or move a particular bit.
29. Write a program to perform multiplication of 2 no’s using 8051.
MOV A, #data 1
MOV B, #data 2
MUL AB
MOV DPTR, #5000
30. Write a program to mask the 0th &7th bit using 8051.
MOV A, #data
ANL A,#81
MOV DPTR,#4500
NY
9. Register addressing
10. Register indirect addressing.
O
11. Implicit addressing
NT
12. Immediate addressing
13. Index addressing
A
*LCALL(Long CALL)
*ACALL(Absolute CALL)
Each increments the PC to the 1 st byte of the instruction & pushes them in to the
stack.
35. Write a program to find the 2’s comple ment using 8051.
MOV A,R0
CPL A
INC A
36. Write a program to add 2 8-bit numbe rs using 8051.
MOV A, #30H
ADD A, #50H
In this mode serial enters &exits through RXD, TXD outputs the shift clock.8 bits
are transmitted/received: 8 data bits (LSB first).The baud rate is fixed at 1/12 the oscillator
frequency.
NY
38. Explain the operating mode2 of 8051 serial ports.
In this mode 11 bits are transmitted(through TXD)or received (through RXD):a start
O
bit(0), 8 data bits(LSB first),a programmable 9th data bit ,& a stop bit(1).ON transmit the 9th data
NT
bit (TB* in SCON)can be assigned the value of 0 or 1.Or for eg:, the parity bit(P, in the PSW)could
be moved into TB8.On receive the 9th data bit go in to the RB8 in Special
A
Function Register SCON, while the stop bit is ignored. The baud rate is programmable to either
1/32or1/64 the oscillator frequency.
S.
J.
bit(0), 8 data bits(LSB first),a programmable 9th data bit ,& a stop bit(1).In fact ,Mode3 is the same
as Mode2 in all respects except the baud rate. The baud rate in Mode3 is variable.
In all the four modes, transmission is initiated by any instruction that uses SBUF as a
destination register. Reception is initiated in Mode0 by the condition RI=0&REN=1.Reception is
initiated in other modes by the incoming start bit if REN=1.
40. Write a program to s wap two numbe rs using 8051.
MOV A, #data
SWAP A
**************************THE END**********************
O NY
NT
A
S.
J.
S.
12 marks questions
1. With neat sketch explain the function of A/D convertor.
2. With neat sketch explain the function of D/A convertor.
3. Explain stepper motor interfacing with 8051.
4. With near sketch explain the function of keyboard and display controller.
5. Explain the interface LCD module with 8051 microcontroller.
6. Draw the schematic for interfacing a stepper motor with 8051 microcontroller and
write the program to changing speed and direction of motor.
7. Explain the 8051 microcontroller interfacing to external memory.
8. Explain the 8051 interfacing to 8255.
NY
M/IO=1; microprocessor communicating with memory system.
M/IO=0; microprocessor communicating with IO system.
2. Give the two methods for interfacing IO device. (Nov 2007)
1. Input/output Mapped I/O. O
NT
2. Memory Mapped I/O.
The transfer of data is completely under the control of microprocessor program. The data
transfer takes place only when I/O transfer instruction executed.
S.
J.
NY
The internal devices of a DAC are R/2R resistive network, an internal latch and current to
voltage converting amplifier.
O
13. What do you meant by settling or conversion time in DAC?
NT
The time taken by the DAC to convert a given digital data to corresponding analog signal is
called conversion time.
A
and Generating key codes (Decoding the key). These task are performed software if the
keyboard is interfaced through ports and they are performed by hardware if the keyboard is
interfaced.
NY
4. Define ROM.
ROM-Read Only Memory
O
Rom is a type of memory that does not lose its contents when the power is turned off. For this
reason ROM is also called as non- volatile memory.
NT
5. What are the different types of ROM?
1. PROM
A
2. EPROM
3. EEPROM
S.
4. Flash EPROM
5. Mask ROM
J.
6. Define PROM.
S.
8. Define EPROM.
EPROM-Erasable Programmable Read Only Memory
EPROM in which one can program the memory chip & erase it thousands of times.
A widely used EPROM is called UV-EPROM.
NY
14. What are the factors to be considered while connecting a me mory chip to CPU.
1)Data bus of the CPU is connected directly to the data pins of the memory chip.
2)Control signals RD and WR from the CPU are connected to the OE and WE pins of the
memory chip.
O
NT
15. What is EA PIN?
For 8751/89c51/ds5000 based systems, we connect EA pin to VCC to indicate that
the program code is stored in the micro-controller ‘s on chip ROM.EA pin connected to GND to
A
PSEN is an output signal for the 8031/51 micro controller and must be connected
to OE pin of a ROM containing the program code.
S.
NY
• A fixed (32-bit) instruction size with few formats; CISC processors typically had
Variable length instruction sets with many formats.
• A load-store architecture where instructions that process data operate only on registers and are
O
separate from instructions that access memory; CISC processors typically allowed values in
memory to be used as operands in data processing instructions.
NT
• A large register bank of thirty-two 32-bit registers, all of which could be used for
any purpose, to allow the load-store architecture to operate efficiently; CISC
register sets were getting larger, but none was this large and most had different
A
registers for different purposes (for example, the data and address registers on the
Motorola MC68000)
S.
NY
• N: Negative; the last ALU operation which changed the flags produced a negative
result (the top bit of the 32-bit result was a one).
• Z: Zero; the last ALU operation which changed the flags produced a zero result
(every bit of the 32-bit result was zero). O
NT
• C: Carry; the last ALU operation which changed the flags generated a carry-out,
either as a result of an arithmetic operation in the ALU or from the shifter.
• V: overflow; the last arithmetic ALU operation which changed the flags generated
A
Data items may be 8-bit bytes, 16-bit half- words or 32-bit words. Words are always
aligned on 4-byte boundaries (that is, the two least significant address bits are zero)
S.
14. What are the ways to find the breaks in the pipeline?
The simplest way to view breaks in the ARM pipeline is to observe that:
S.J.S.ANTO NY. ITC, B.E, M.B.A., ECE/JKKNCET
25
• All instructions occupy the data path for one or more adjacent cycles.
• For each cycle that an instruction occupies the data path, it occupies the decode
logic in the immediately preceding cycle.
• During the first data path cycle each instruction issues a fetch for the next instruction but one.
• Branch instructions flush and refill the instruction pipeline.
15. What are the ways to improve the performance of 5 stage pipeline?
Increase the clock rate, fclk.
• Reduce the average number of clock cycles per instruction, CPI.
• Fetch; The instruction is fetched from memory and placed in the instruction pipeline.
• Decode; The instruction is decoded and register operands read from the register file. There are
three operand read ports in the register file, so most ARM instructions can source all their operands
in one cycle.
• Execute; An operand is shifted and the ALU result generated. If the instruction is a load or store
the memory address is computed in the ALU.
NY
• Buffer/data; Data memory is accessed if required. Otherwise the ALU result is simply buffered
for one clock cycle to give the same pipeline flow for all instructions.
• Write-back; The results generated by the instruction are written back to the register file,
including any data loaded from memory. O
NT
17. What are the factors determines the minimum cycle time?
The minimum data path cycle time is therefore the sum of:
A
*************************************************
NY
– System (SYS)
– Undefined (UND)
•
5. What is a load instruction?
S.
NY
• RSC
15. Mention three sets of instructions which interact with main me mory?
J.
***********************THE END************************
NY
1. What are the data types accepted by ARM processor?
ARM processors support six data types:
• 8-bit signed and unsigned bytes.
O
• 16-bit signed and unsigned half-words; these are aligned on 2-byte boundaries.
NT
• 32-bit signed and unsigned words; these are aligned on 4-byte boundaries.
Exceptions are usually used to handle unexpected events which arise during the execution of a
program, such as interrupts or memory faults
S.
9. Explain the processor ope rations for the execution of software interrupt
If the condition is passed the instruction enters supervisor mode using the standard ARM exception
NY
entry sequence. In detail, the processor actions are:
1. Save the address of the instruction after the SWI in r14 svc.
2. Save the CPSR in SPSR svc.
O
3. Enter supervisor mode and disable IRQs (but not FIQs) by setting CPSR [4:0] to
100112 and CPSR [7to l].
NT
4. Set the PC to 08 and begin executing the instructions there.
The ARM data processing instructions are used to modify data values in registers. The operations
that are supported include arithmetic and bit-wise logical combinations of 32-bit data types. One
S.
operand may be shifted or rotated en route to the ALU, allowing, for example, shift and add in a
single instruction
J.
11. Explain about single word and unsigned byte data transfer instruction.
S.
These instructions are the most flexible way to transfer single bytes or words of data between
ARM's registers and memory. Transferring large blocks of data is usually better done using the
multiple register transfer instructions, and recent ARM processors also support instructions for
transferring half-words and signed bytes.
12. Explain about half word and signed byte data transfer.
These instructions are not supported by some early ARM processors. As a result of their late
addition to the architecture they are somewhat 'shoe- horned' into the instruction space as indicated
by the split immediate field.
NY
• The Thumb code requires 70% of the space of the ARM code.
• The Thumb code uses 40% more instructions than the ARM code.
• With 32-bit memory, the ARM code is 40% faster than the Thumb code.
O
• With 16-bit memory, the Thumb code is 45% faster than the ARM code.
• Thumb code uses 30% less external memory power than ARM code.
NT
18. What is the application of thumb instruction.
• A high-end 32-bit ARM system may use Thumb code for certain non-critical routines to save
A
running ARM code, but use off-chip Thumb code for all non-critical routines.
J.
S.