Ee6502 MM QB2
Ee6502 MM QB2
Ee6502 MM QB2
com
TEXT BOOKS:
1. Krishna Kant, “Microprocessor and Microcontrollers”, Eastern Company Edition,
Prentice Hall of India, New Delhi , 2007.
2. R.S. Gaonkar, „Microprocessor Architecture Programming and Application‟, with
8085, Wiley Eastern Ltd., New Delhi, 2013.
3. Soumitra Kumar Mandal, Microprocessor & Microcontroller Architecture,
Programming & Interfacing using 8085,8086,8051,McGraw Hill Edu,2013.
REFERENCES:
1. Muhammad Ali Mazidi & Janice Gilli Mazidi, R.D.Kinely „The 8051 Micro
Controller and Embedded Systems‟, PHI Pearson Education, 5th Indian reprint, 2003.
2. Valder – Perez, “Microcontroller – Fundamentals and Applications with Pic,” Yeesdee
Publishers, Tayler & Francis, 2013.
QUESTION BANK
PART-A (2-Marks)
YEAR/SEM : III/V
1. What is meant by Level triggered interrupt? Which are the interrupts in 8085 level triggered?
Triggering is used to enable the signal to make circuit active or to do its function. It is normally
by using the clock signal . It can be a negative level triggering in which the circuit is active when the clock
signal is low or a positive level triggering in which the circuit is active when the clock signal is high.
RST 6.5 ,RST 5.5 INTR, TRAP are the level triggered interrupts
2. To obtain a 320ns clock what should be the input clock frequency? What is the frequency of clock
signal at CLK OUT?
The input clock frequency must be 6.25 MHZ to obtain 320ns.The input clock signal frequency
at CLK OUT is 3 MHZ.
TRAP is a Non Maskable Interrupt. It means that it is unaffected by any mask or interrupt
enable. It has the highest priority. It is edge and level triggered which means it must go high and remain
high until it is acknowledged.
4. Define the function of parity flag and zero flag in 8085? May/June 2012
Parity flag is defined by the number of ones present in the accumulator. After an arithmetic or
logical operation if the result has an even number of ones. i.e. even parity the flag is set ,if the parity is
odd flag is reset.
Zero flag sets if the result of operation in ALU is zero and flag resets if result is non zero.
It is a special purpose register which at a given time stores the address of the next instruction to
be fetched. It acts as a pointer to the next instruction.
6. Write down the control and status signals of 8085. Nov/Dec 2012
7. Specify the size of data, address, memory word and memory capacity of 8085 microprocessor.
(A/M’11)
16
8085 operate 8bit data. The 8085 has 16 address lines, hence it can access (2 )
64 Kbytes of memory
8. Draw the schematic of latching low order address bus in 8085 microprocessor. (N/D’11)
The ALE signal goes high at the beginning of each machine cycle indicating the availability of the
address on the address bus, and the signal is used to latch the loworder address bus.
11. Specify the function of Address bus and the direction of the information flow on the address
bus? Nov./Dec 2012 (R 2004)
12. What do you mean by masking the interrupt? How it is activated in 8085?
Masking is preventing the interrupt from disturbing the current program execution. When
the processor is performing an important job (process) and if the process should not be interrupted
then all the interrupts should be masked or disabled. In processor with multiple 'interrupts, the
lower priority interrupt can be masked so as to prevent it from interrupting, the execution of
interrupt service routine of higher priority interrupt
13. What are the two limitations of the 8085 that may not allow it to qualify entirely as a μP?
T-State is defined as one subdivision of the operation performed in one clock period. These
subdivisions are internal states synchronized with the system clock, and each T-State is precisely equal
to one clock period.
The data conditions, after arithmetic or logical operations, are indicated by setting or
resetting the flip-flops called flags.
The Software interrupt is initiated by the main program, but the hardware interrupt is initiated by
the external device. In 8085, Software interrupts cannot be masked or disabled, but in hardware
interrupts except TRAP all other interrupts can be masked.
19. Why are the program counter and the stack pointer 16-bit registers?
Memory locations for the program counter and stack pointer have 16-bit addresses. So
the PC and SP have 16-bit registers.
PART – A
1. What is the different control machine control instructions used in 8085 microprocessor? M/J 2013
EI-Enable Interrupt
DI-Disable interrupt
NOP- No operation
HLT- Halt, SIM, RIM.
3. Mention the similarity and difference between compare and Subtract instructions (M/J 2014)
COMPARE:
This instruction compares the given numbers by subtracting it and gives the result if the number
is greater than, lesser than or equal to the status of sign and carry flag will be affected.
SUBTRACT:
This instruction subtracts the two given numbers and the flag registers will not be affected.
JP – 16 bit Address – Jump on Plus JPE – 16 bit Address – Jump on Even Parity
JPO – 16 bit address – Jump on Odd Parity JNZ – 16 bit address – Jump on No Zero
8. How is PUSH B instruction executed? Find the status after the execution (A/M’11)
This instruction decrements SP by one and copies the higher byte of the register pair into the memory
location pointed by SP. Then decrements the SP again by one and copies the lower byte of the register
pair into the memory location pointed by SP.
13. Give two examples for two byte and three byte instruction. M/J 2012 (R2004)
1. MVIA, 08
2. IN CO……..2 byte instruction
1. LDA 4500
2. STA 5000……3 byte instruction
14. What happens when the RET instruction at the end of the subroutine is executed? N/D 2012
This instruction pops the return address (address of the instruction next to the CALL instruction
in the main program) from the stack and loads program counter with this return address. Thus transfers
program control to the instruction next to Call in the main program.
15. What are the instructions associated with the subroutine. N/D2013
CALL 16 bit address: The program sequence is transferred to the address specified by the
operand. Before the transfer, the address of the next instruction to CALL( the contents of the program
counter) is pushed to the stack.
18. Show the different instruction formats used in 8085. Give examples
(i) One byte instruction –CLR A (ii)
Two byte instruction -MVIA, 00 (iii)
Three byte instruction-STA 5000
19. Define Opcode and operand?
The operation to be performed is called Opcode. The data to be operated is called operand.
20. Give the difference between JZ and JNZ?
JZ change the program sequence to the location specified by the 16-bit address if the zero flag
is set and JNZ change the program sequence to the location specified by the 16-bit address if the zero
flag is reset.
21. Explain the need of software interrupt?
Executing a group of instruction number of times can generate the time delays in few microseconds.
These software timers are called time delay or software delays. It is necessary to keep time delays
between 2 transitions.
22. What is subroutine?
A Subroutine is a group of instructions which performs a particular subtask, which is executed
number of times. It is written separately. The microprocessor executes the subroutine by transferring
program control to the subroutine program. After completion the program control is returned back to
the main program. It is a very important technique in designing software for microprocessor systems
because it eliminates the need to write a subtask repeatedly: thus it uses memory more efficiently.
28. What happens in a single board microcomputer when the power is turned on and the
When the power is turned on, the monitor program stored either in EPROM or ROM comes alive.
The reset key clears the program counter and the program counter holds the memory address 0000H.
some system automatically reset when the power is turned ON ( called power-on Reset)
29. What is an assembler?
An assembler is a program that translates the mnemonics into their machine code. It is generally not
available on a single board microcomputer.
PART - A
MOV B, #data
2 MUL AB
INC DPTR
MOV A, B
MOVX @ DPTR, A
19. Name any four additional hardware features available in microcontrollers when compared
to microprocessors.
• Two multiple mode
• 16 bit timers/counters
• Four register banks
• integrated Boolean processor
•
20. Write the steps necessary to initialize a counter in write operations?
• Write a control word into the control register
• Load the low-order address byte
• Load the high order byte
1. What are the different ways to end the interrupt execution in 8259 PIC? (A/M’11)
AEOI (Automatic End of Interrupt) mode the ISR bit is reset at the end of the second INTA
pulse. Otherwise, the ISR bit remains set until the issue of an appropriate EOI command at
the end of the interrupt subroutine.
Scan section which has two modes (i) Encoded Mode (ii) Decoded Mode
Encoded Mode: In this mode, Scan counter provides a binary count from 0000 to 1111 the
four scan lines (SC3 – SC0) with active high outputs.
Decoded Mode: The internal decoder decodes the least significant 2 bits of binary count and
provides four possible combinations on the scan lines (SC3- SC0) : 1110,1101,1011 and
0111.
ISR- Interrupt service Register Stores all the levels that are currently being serviced.
PR– Priority Resolver determines the priorities of the bits set in the IRR (Interrupt Request
register). The bit corresponding to the highest priority interrupt input is set in the ISR during
the INTA input.
5. What are the salient features of INTEL 8259 Programmable interrupt controller? M/J
14
7. What are the applications of D/A converter interfacing with 8255? M/J ‘12
Generating square, triangular and sine waveform, used in automatic process control
9. What are the different peripheral interfacing used with 8085 processor? M/J 13
8255PPI, 8279 Keyboard and display controller, 8251 USART, 8259 PIC and
8254 - timer
10. What are the output terminals in USART 8251? M/
J 13 RD, WR
11. What is the need for 8259 PIC?
It is necessary to solve multiple interrupt requests (more than five) we use an
external device called a PIC. It is possible to increase the interrupt handling capacity of
the microprocessor. When executing an interrupt an ISR can be serviced.
iii) Monotonicity : If a clock has monotonicity, then each successive time reading from that
clock will yield a time further in the future than the previous reading.
iv)Conversion time: The time required by an analog to digital converter to fully convert
and analog input sample.
When the IO device needs a DMA transfer, it will send DMA request signal to the
DMA controller. The DMA controller in turn sends a HOLD request to the processor.
When the processor receives a HOLD request, it will drive its tristated pins to high
impedance state at the end for current instruction execution and send an acknowledge
signal to the DMA controller. Now the DMA controller will perform DMA transfer
23. What is the function of C/T bit in TMOD register in timer in 8051?
C/T bit in the TMOD register decides the timer/counter functioning as a counter or a
timer. When C/T = 0, the timer mode is selected and the crystal is used as a source of
frequency. When C/T =1, the counter mode is selected, it gets its pulse from outside the
8051. The counter counts up for each clock pulse applied at the pins of port 3
Interrupt.
28.What is meant by two key lockout and N key roll over in 8279?
The keys are automatically de bounced and the keyboard can operate in two modes:
i) Two key Lock out – In this mode if two keys are pressed almost simultaneously,
only the first key is recognized.
ii) N key roll over- In this mode simultaneous keys are recognized and their codes are
stored in the internal buffer; it can also be set up so that no key is recognized until one
key remains pressed.
PART – A
a. Logical Instructions
b. Arithmetic Instructions
c. Data transfer Instructions
d. Branch Instructions
e. Jump & CALL Instruction
2. What are the various operations performed by Boolean variable instructions of 8051?
4. Draw the flow chart for the programming of serial port of 8051 (May/June -2012)
6. How is the pulse generated from microcontroller for stepper motor control (May/June
- 2013)
To cause the stepper to rotate, we have to send a pulse to each coil in turn. The 8051
does not have sufficient drive capability on its output to drive each coil, so there are a number
of ways to drive a stepper, Stepper motors are usually controlled by transistor or driver IC like
ULN2003. Driving current for each coil is then needed about 60mA at +5V supply.
9. What is the operation carried out when 8051 executes the instruction MOVC A,
@ A + DPTR? (Nov-2007)
This instruction loads the accumulator from the contents of program memory whose address
is given by the sum of the contents of accumulator and contents of DPTR register (A) ‹— ((A)
+ (DPTR))
10. Write program to load accumulator, DPH, &DPL using 8051? (Nov-2007)
MOV A,#30
MOV DPH, A
MOV DPL, A
12. Write a program to mask the 0th &7th bit using 8051? (APRIL-2009)
MOV A,#data
ANL A,#81
MOV DPTR,#4500
MOVX @DPTR,A
LOOP SJMP LOOP
16. How many ports are bit addressable in an 8051 microcontroller?(N/D ‘12’)
In 8051 there are many bit-addressable registers such as A (ACC), B, SCON,
PCON, TCON, p0, p1, p2, p3.
17. Write a program to find the 2’s complement using 8051?( NOV-2008)
MOV A, R0
CPL A
INC A
20. What does the mnemonics “LCALL” and “ACALL” stands for? (Nov/Dec-2012)
There are two subroutine CALL instructions. They are LCALL (Long CALL)
ACALL (Absolute CALL). Each increments the PC to the 1st byte of the instruction
& pushes them in to the stack.
21. What are the use of PWM in motor control using microcontroller?
The speed of the dc motor depends on the applied voltage. The average applied dc
voltage and power can be varied using a technique called pulse width modulation. In this
technique the dc power supply is not a voltage of fixed amplitude ie it is a pulsating DC
voltage. By changing the pulse width we can change the applied power.
22. Calculate the reload value of timer1 for achieving a baud rate of 4800in 8051 for a
crystal frequency of 11.0592MHz?
TH = 256 – k * Oscillatory frequency
-------------------------------
384 * Baud rate
25. What are the different addressing modes of microcontroller 8051? ( A/ M -2008)
i) Register addressing
ii) Direct byte addressing
iii) Register indirect addressing
iv) Immediate addressing
v) Register specific
vi) Index
26. Give the PSW setting for making register bank 2 as default register bank in 8051
microcontroller ( M / J 2007)
MOV PSW, #10 ; SELECT BANK 2
MOV A, R0 ; (A) ‹— (R0) FROM BANK 2
MOV PSW, #00 ; SELECT BANK 0
CLR C ; CLEAR CARRY
SUBB A, R1 ; A ‹— A- (R1) FROM BANK 0
The above program is to subtract the contents of R1 of BANK0 from the contents of RO
of Bank 2.
UNIT – І 16 MARKS
8085 PROCESSOR
a) Registers
b) Arithmetic and Logic Unit
c) Instruction decoder
d) Address buffer
e) Address / Data buffer
f) Increment / Decrement address latch
g) Interrupt control
h) Serial I/O control
i) Timing and control circuitry
a) Registers:
It has eight addressable 8-bit registers (A, B, C, D, E, H, L, and F) and two 16-bit
registers (SP, PC). Registers are further classified as four types.
i. General purpose register:
B, C, D, E, H and L – 8 bit registers
BC, DE and HL – 16 bit register pair. For storing and reading data from the
register, bus access is not required.
ii. Temporary register:
Temp. Data register, W and Z register. These temporary data registers are used
to hold 8-bit data during the execution of some instructions.
iii. Special purpose registers:
1) Register A (Accumulator):
Tristate 8 bit register used in arithmetic, logic, load and store equations and
I/O operations. Mostly the result of ALU may stored in register A
2) Flag register:
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X CY
of bit 3 i.e. Carry from lower nibble to higher nibble. (D3 bit to D4 bit)
P – Parity flag Parity is defined as the number of ones present in
Accumulator.
CY –Carry flag Carry flag is set if there is an overflow out of bit 7. The carry
flag also serves as a borrow flag for subtraction.
2. 2. Describe the functional pin diagram of 8085. (M/J 12), (May/June 2014)
The signals of 8085 can be classified into 7 groups according to their functions.
i. Power supply and frequency signals
VCC +15V
VSS Ground
X1 & X 2 clock signals
Clock out
ii. Data bus and address bus
AD0 – AD7
A8 – A15
iii. Control and status signals
ALE (Address Latch Enabled)
&
IO / , S0 & S1
Ready
iv.Interrupt signals
INTR
TRAP
RST 5.5
RST 6.5
RST 7.5
v. Serial I /O signals
SID
SOD
vi. DMA Signals
HOLD
HLDA
vii. Reset signal
RESET IN
RESET OUT
3. How address decoding is done in memory interfaces. (N/D’11)
Memory Interfacing:
While executing a program, the microprocessor needs to access memory quite frequently
to read instruction codes and data, which are stored in memory, the interfacing circuits enable
that success. Both memory and microprocessor require a set of signals to read and write data
from register and memory respectively. The interfacing process involves designing the circuits
that will match the memory requirements with microprocessor signals.
4.Draw timing diagrams for the OP code fetch and I/O read machine cycles. May/June 2012
5. With timing diagram, explain the memory read operation in 8085 microprocessor
(A/M’11) (M/J 12)
6. Draw the timing diagram for IN and OUT instruction of 8085 and explain. (N/D’11)
Interrupts
Types of interrupts:
The 8085 has multi level interrupt system. It supports two types of interrupts.
Hardware
Software
Hardware:
Some pins on the 8085 allow peripheral devices to interrupt the main program for I/O
operations. These types of interrupts, where MPU pins are used to receive interrupt requests, are
called “Hardware Interrupts”.
Software:
In software interrupts, the cause of the interrupt is an execution of the instruction.
These are special instructions supported by the microprocessor.
1. TRAP
2. RST 7.5
3. RST 6.5
4. RST 5.5
5. INTR
Interrupt Structure
When any of these pins, except INTR is active, the internal control circuit of 8085 produces a
CALL to a predetermined memory location. This memory location, where the sub routine starts
is referred to as vector location and such interrupts are called vectored interrupts. The INTR is
not a vectored input. It receives the address of the sub routine from the external device. In 8085,
all interrupts except TRAP are maskable. When logic symbol is applied to a maskable interrupt
input, the 8085 is interrupted only if that particular interrupt is enabled.
TRAP:
This interrupt is a non- maskable interrupt. It has the highest priority. This must go high
and remain high until it is acknowledged since it is edge and level triggered. The positive edge of
TRAP signal sets the D flip-flop. However, due to AND gate, it is necessary to sustain high level
on the TRAP input.
RST 7.5:
The RST 7.5 interrupt is a maskable interrupt. It has the second highest priority. It is
positive edge triggered and this is stored internally by the D flip-flop until it is cleared by
software reset using SIM instruction or by internally generated ACKNOWLEDGE signal.
INTR:
It is a maskable, non-vectored interrupt. In response to the signal, external logic
places an instruction opcode on the data bus. In case of multi byte instruction, additional
interrupt acknowledge machine cycles are generated by the 8085 to transfer the additional
bytes into the microprocessor.
Software interrupts:
The 8085 has eight software interrupts from RST 0 to RST 7. The vector
address for these interrupts can be calculated as follows.
Interrupt number * 8 = vector address
UNIT II
PROGRAMMING OF 8085 PROCESSORS
1. Explain the Different types of instruction in 8085. (M/J 12) (A/M’11) (M/J 12)
Instruction Classification:
Instruction Format:
Each instructions has two parts, one is the task to be performed called
operation code (opcode) & other is the data to be operated is called the operand.
Instructions format are further classified into
1. one byte instruction
Format:
Opcode
Eg: Mov A, B
2. two byte instruction
Format:
Opcode operand Eg:
MVI B, 02
3. three byte instruction
Format:
Opcode Operand Operand
Eg: JMP 6200H
Opcode Format:
8085 microprocessor has 8 bit opcodes. The opcode is unique for each
instruction about operations, registers to be used, and memory to be used.
Register Opcode
B 000
C 001
D 010
E 011
H 100
L 101
M(memory) 110
A 111
There are different codes for each operation. Some of the codes operations are
given below.
NOTATIONS MEANING
r 8 bit register
rp 16 bit register pair
rs Source register
rd Destination register
DDD Destination register
SSS Source register
DD register pair
2. What are the different addressing modes in 8085? Explain with example. N/D 2012,M/J
2012, (A/M’11) (M/J 12)
Addressing Modes:
The ways that microprocessor can access data ate referred to as addressing modes.
a) Immediate addressing modes
b) Register addressing modes
c) Direct addressing modes
d) Indirect addressing modes
e) Implied addressing modes
1) MVI r, data(8):
Move 8 bit immediate data to register r(r A, B, C, D, E, H,
and L)
Operation : r 8 bit data
No of bytes : 2
Addressing modes: Immediate
Example:
MVI B, 60H
This instruction will load 60Hdirectly into B register.
Before execution
A F
B C
D E
H L
MVI B, 60H
After execution
A F
B 60 C
D E
H L
2) MVI M, data(8):
Move 8 bit data immediate to memory whose address is in HL
register pair.
Operation : M8 bit data
No of bytes : 2
Addressing modes: Immediate
Example:
If H=20H and L=50H
MVI M, 40H
This instruction will load 40H into memory whose address is 2050.
3) MOV rd, rs:
Move data from source register to destination register. The content
of source register remains unchanged after execution of the instruction.
Operation : rdrs
No of bytes : 1
4) MOV M, rs:
Move data from source register to memory whose address is in HL
register pair.
Operation : Mrs
No of bytes : 1
Addressing modes: indirect
Example:
5) MOV rd, M:
Move data from memory location specified by HL register pair to rd.
Operation : rdM
No of bytes : 1
Addressing modes: Indirect
6) LXI rp, data(16):
Load 16 bit data immediate to
specified register pair.
rp data
Operation : (16)
No of bytes : 3
Addressing modes: Immedi
8) LDA addr:
Load data into A register directly form the address given within
instruction. The contents of memory remain unchanged.
Operation : A addr
No of bytes :3
Addressing modes: direct
Example
If STA 2000H=30H
LDA 2000H
A 30 20 20
A 50
H 20 L 50
H 20 L 50
3. ADI data (8): add immediate 8 bit data to accumulator.
Operations; A (A + data)
No. of bytes: 2
Address modes: immediate
E.g.: if A=50H
ADI 70H
Before execution after execution
A 50
A CO
A 50 A 71
B 20 B 20
ADDITION:
1. ADD r
2. ADD M
3. ADI data(8)
4. ADC r
5. ADC M
6. ACI data(8)
7. DAD rp
SUBTRACTION:
1. SUB R
2. SUB M
3. SUI data(8)
4. SBB r
5. SBB M
6. SBI data(8)
If higher order 4 bit i.e. (D7-D4)in the accumulator is greater than 9 0r if carry flag
is set, the instruction adds 06(0110) to the higher order 4 bits.
No of bytes: 1
Ex: if A=39
B=12
0011 1001
0001 0010
0100 1011 4B BCD
4BH here D3-D0 i.e. lower order nibble in accumulator is greater than 9.
Since 1011>9
Add 0110 in lower order four bits.
0100 1011
0110
0101 0001 51 BCD
This is the actual result store in accumulator.
Ex: if A=96, D=07
1001 0110
0000 0111
RANCH GROUPING:
This group instruction allows the microprocessor to change the sequence of the program,
either unconditionally or under certain test codes. The instructions are
1. Jump instruction
2. Call & return instruction
3. Restart instructions
1. JUMP INSYRUCTIONS
D) LOGIC GROUP:
In this group, instructions perform logic operations such as
„AND‟,‟OR‟,‟X-OR‟. These instructions „compare data between registers (or)
between register and memory‟, ‟rotate and complement data in register‟.
00001010 =0A
00100000 =20
3) ANI data (8): AND the given data immediate with accumulator.
Operation: A<-A r
No of bytes: 1
Addressing mode: immediate
Flags: all flags are affected. After execution cy=0, ac=1
Ex: If A=AA H;
ANA 20
AA= 10101010
0F = 00100000
00100000 =20
op:
sp <- sp-1
(sp) <- rph
sp <- sp-1
(sp)<- rpl
Example:
If sp = 2200, (DE) = 1050
Push D
SP 2000 1FFD
B C 1FFE
D 10 E 50 1FFF
H L 2000
SP 1FFE 1FFD
B C 1FFE 50
D 10 E 50 1FFF 10
H L 2000
2) PUSH PSW: write the data from accumulator and flag reg to stack
op:
sp <- sp-1
(sp) <- A
sp <- sp-1
(sp) <- F
SP 2000
A 10 F 50
D E
HL
PUSH PSW
SP 1FFE 1FFD
A 10 F 50 1FFE 50
D E 1FFF 10
H L 2000
3) POP rp: read the content from stack and store on specified reg pair op:
rpl <-(sp)
sp <- sp+1
rph <- (sp)
sp <- sp+2
Ex: If sp = 1FFE, (1FFE) = 50, (1FFF) = 10
POP D
SP IFFE 1FFD
B C 1FFE 50
D E 1FFF 10
H L 2000
SP 2000 1FFD
B C 1FFE 50
D 10 E 50 1FFF 10
H L 2000
4) POP PSW: read contents from stack and store in A and flag op:
F <- (sp) Sp <-
sp+1 A <- (sp)
Sp <- sp+2
SP 2000 1FFE 50
A 10 F 50 1FFF 10
5) SPHL: copy the contents of HL reg pair into the stack pointer op:
(sp) <- HL
op:
L<-(SP)
H <-(SP+1)
XTHL
2701 60
2700 50
SP 2700 2701 30
A F 2700 40
H 60 L 50
SP 2700
A F
H 30 L 40
5. Compare the similarities and differences of CALL and RET instructions with PUSH and POP
instructions. (N/D’11)
Branch Operations:
1) Call Instructions
1. CALL addr: call unconditionally a sub routine whose starting addr is given within the
instructions
op:
(sp-1) <- pch
(sp-2) <- pcl sp<-
(sp-2) pc <- addr
No of bytes: 3
Addr mode: Immediate reg indirect
pc <- pc+3
EX: If A = 0E or A = C0
SIM
D7 D6 D5 D4 D3 D2 D1 D0
SOD SOE X RST 7.5 MSE M 7.5 M 6.5 M 5.5
0 0 0 0 1 1 1 0
1 1 0 0 0 0 0 0
6. RIM: Read Interrupt Mask. This instruction copies the status of interrupt into the
accumulator. It also reads serial data through the SID pin.
D7 D6 D5 D4 D3 D2 D1 D0
SID I 7.5 I 6.5 I 5.5 IE M 7.5 M 6.5 M 5.5
UNIT III
8051 MICROCONTROLLER
1. Draw the pin diagram of 8051 microcontroller and explain its port structure. (N/D’11)
PIN-OUT 8051:-
The 8051 is packaged in a 40 pin DIP. It has 32 IO pins configured as 4 8bit parallel ports
like port0 (P0), port1 (P1), port2 (P2), port3 (P3).Each port may consist of a latch, an output driver
and an input buffer.
Functional Block Diagram Of 8051:-
Blocks Of 8051
1. CPU:
It consists of 8 bit ALU, registers like A, B and Program Status word (PSW), SP, PC and Data
Pointer (DPTR). Along with it has a set of special function registers.
ALU – Arithmetic and Logic Unit (+, -, /, *) (AND, OR, EXOR, Rotate, Clear, Complement)
An important unique feature of 8051 architecture is that the ALU can also manipulate on bit as
well as eight-bit data types, individual bits may be set, cleared, complement, moved, tested and
used in logical computation.
2. Internal RAM:
Working registers (Addr 00H to 1FH 32 registers)
Bit addressable (Addr 20H to 2FH 128 Addr bits)
General purpose (Addr 30H to 75H)
In working registers only one register bank is in use at a time. PSW determines which bank of
register is currently in use. On reset, bank 0 is selected.
In bit-Addrarea, forming a total of 128(16*8) addressable bits. Byte
ADDR 20
07 06 05 04 03 02 01 00
Bit addr 00H to 7FH (128)
Byte addr 20H to 2FH (16)
3. Internal ROM:
The 8051 has 4K bytes of internal ROM; it is programmed by manufacturer when the chip
is built. This can‟t be erased or altered after fabrication.
4. Input/Output Ports:
The 8051 has 32 I/O pins configured as eight bit parallel ports; each port consists of latch, an
output driver and an input buffer.
Port 0 outputs and port 2 outputs the lower order and higher order byte of the external
memory address, when the address is 16 bit wide.
SFR are implemented in the address space immediately above the 128 bites of RAM .All
SFR‟S are accessed to the 4 IO ports, CPU registers, timer or counter & interrupt control register
etc. Address of SFR is in between of 80H & FFH.
4.Explain the program memory and data memory structure of 8051 microcontroller.(N/D’11)
5.Draw the TMOD register format and explain the different operating modes of timer in 8051
microcontroller. (N/D’11)
TCON has control bits &flags for the timers in the upper nibble &control bits &flags for
the external interrupt in the lower nibble as shown below.
TF1 Timer 1 overflow flag
TR1 Timer 1 run control bit
TF0 Timer 0 overflow flag
TR0 Timer 0 run control bit
IE1 External interrupt 1 edge flag
IT1 External interrupt 1 control bit INT 1
IE0 External interrupt 0 edge flag
IT0 External interrupt 0 control bit INT 0
TMOD is divided into two timers &can be considered to be two duplicate 4bit
register each of which controls the action of one of the timers as shown below.
Bit 7/3(Gate) OR Gate enable bit which controls run/stop of timer 1/0.
6/2(C/ T) set to 1 for counter action
set to zero for timer action
5/1(M1) Timer/counter operating mode selection bits 4/0(M0)
M1 M0 Mode
0 0 0
0 0 1
1 0 2
1 1 3
TIMING:-
If a counter is programmed to be a timer it will count the internal clock frequency of
8051 oscillator divided by 12d.
In other words the counter is configured as a timer when the timer pulses are gated to the
counter by the run bit AND the gate bit OR the external input bits INTX shown below.
c) Timer mode 2
d) Timer mode 3
b) MODE 1:-
This mode is same as mode 0 except that the timer register is being run with all 16 bits.
c) MODE 2:-In mode 2 the timer register as an 8bit counter (TLx) with automatic reload
shown below. Overflow from TLx not only sets TFx, but also reloads TLx with the contents of
THx, which is present by software. The reload leaves THx unchanged.
d) Mode 3:-
Timer 1 in mode 3 simply holds its count &Timer0 in mode 3establishes TL0&TH0 as 2
separate counters.Mode3 is provided for applications requiring an extra 8bit timer or counter.
6.Explain the interrupt structure with the associated registers in 8051 microcontroller.
(A/M’11).
INTERRUPTS:-
Interrupts may be generated by internal chip operations or may be provided by external
sources. Any interrupt can cause 8051 to perform a CALL operation for a subroutine that is located
at a predetermined absolute address in program memory.
Five interrupts are provided in the 8051
1) Timer flag0 (TF0) Generated internally
2) Timer flag1 (TF1)
3) Serial port Interrupt
4) INT0
All interrupt functions are under the control of the program. The programmer is able
to alter control bits in the following register.
1) Interrupt enable register (IE)
2) Interrupt priority register (IP) &
3) Timer control register (TCON)
The program can block all or any combination of the interrupts from acting on the
program by suitably setting or clearing bits in the above register.
EA enable interrupt bit (0–disable all interrupt, 1–enable all interrupt)
- Not implemented ET2
Reserved for future use
ES Enable aerial port interrupt (0 – disable serial port, 1 – enable serial port)
ET1 Enable timer 1 overflow interrupt (1 – enable TF1, 0 – disable TF1)
EX1 Enable external interrupt 1 (1 – enable INT 1, 0 – disable INT 1)
ET0 Enable timer 0 overflow interrupt (1 – enable TF0, 0 – disable TF0)
EX0 Enable external interrupt 0 (1 – enable INT 0, 0 – disable INT 0)
- Not implemented
PT2 Reserved for future use
PS Priority of serial port interrupt
PT1 Priority of timer 1 overflow interrupt (set / cleared by program)
PX1 Priority of external interrupt 1
PT0 Priority of timer 0 overflow interrupt (set / cleared by program)
PX0 Priority of external interrupt 0
EXTERNAL INTERRUPTS:-
The pins INT0&INT1 are used by external circuitry. Inputs on these pins can set the
interrupt flags IE0&IE1 in the TCON register to 1 by 2 different method.
1) The Iex (IE0 (or) IE1) flags may be set when the INTX (INT0 & INT1) pin
signals reaches a LOW level.
(Or)
2) The flags may be set when a HIGH to LOW transition takes place on the INTX
Flags Iex will be RESET when a transition generated interrupt is accepted by the
processor & the interrupt subroutine is accessed.
INTERRUPT PRIORITY:-
The interrupt priority (IP) register which determine if any interrupt is to have a HIGH
or LOW priority.
If bit is 1 HIGH priority
If bit is 0 LOW priority
If two Interrupts have the same priority & occurs at the same time then they will have the
following ranking
1) IE0 (External Interrupt 0)
2) TF0 (Timer flag0)
3) IE0
4) TF1
5) SerialRI (Receive Interrupt flag)(or) TI(Transmit Interrupt flag)
Serial Communication:-
Serial data communication is the cost effective way to communicate the datas, send
&receive serially. Serial buffer is physically two register, one is write only which is used to hold
data to be transmitted via TxD & another one is read only &holds received data from external
sources via RxD.
For serial communication, the following two SFR‟s are acting vital role
(i) SCON (Serial port control)-For control data communication
(ii) PCON (Power mode control)-For control data rates
SM2 Multi processor communication bit (For mode 2 & 3, set 1 an interrupt is generated. If
9th bit of received data is a „1‟ otherwise set to „0‟)
REN receive enable bit (1 = enable reception, 0 = disable reception)
TB8 Transmitted bit 8
RB8 Received bit 8 (If mode 1, stop bit, for mode 2 and 3, receive bit 8)
TI Transmit interrupt flag
RI Receive interrupt flag
SMOD Serial baud rate modify bit (If 1 – Double baud rate, 0 – Timer 1 baud rate) GF1
General Purpose user flag (bit 1) set or cleared by program
GF0 General Purpose user flag (bit 0) set or cleared by program
PD Power down bit (1 for C HMOS processor)
IDL Ideal mode bit.
There are 4 programmable modes for serial data communication that are chosen by
setting the SM0,SM1 bits in SCON register(SMX)
On receive the stop bit goes to RB8 in SCON SFR .The baud rate is variable.
C) Mode 2-Multi Processor Mode
In this mode 11 bits are transmitted &received.
11bits A start bit (0) + 8data bits (LSB first) + a programmable 9th data bit + a stop bit (1) On
transmit the 9th bit [TB8 in SCON] can be assigned the value of zero (or) 1. On receive the 9th data
bits goes into RB8 in SCON SFR. Here the baud rate is programmed to either 1/32 or
1/64 of the oscillator frequency.
D) Mode 3-9 Bit Uart Mode:-
This mode is same as mode 2 in all aspects except that the baud rate is variable.
UNIT – IV
PERIPHERAL INTERFACING
2.With neat block diagram explain the functions of 8259. (M/J 2013)
Block diagram
Interrupt operation:
To implement interrupts, the 8259 should be initialized by writing control
words in the control register. The 8259 requires two types of control words.
1. Initialization command words (ICW) – Used to set up the proper conditions and
specify RST vector addresses.
2. Operational command words (OCW) – used to perform masking interrupts,
setting up status, reading operations and etc.
3.Bring about the features of 8251.ii) Discuss how 8251 is used for serial
communication of data.M/J2013
Block diagram
PIN DIAGRAM
4.Draw the control word of 8253 timer/counter and explain the operating modes of
8253 timer/counter. (N/D’11)
Features
BLOCK DIAGRAM
5.Why do we need ADC and DAC? Draw the block diagram to interface 8085
microprocessor with ADC and DAC. (N/D’11) (M/J 12)
DAC INTERFACING
Introduction:
Digital systems such as microprocessors use a binary system of ones and zeroes. So
for the purpose of processing, transmission and storage, it is often more convenient to
express analog to digital form.
D/A Converter:
D/A converters are used when a binary output from a digital system must be
converted to some equivalent analog voltage or current. It accepts an n-bit input word b1, b2,
b3 … bn in binary and produces an analog signal proportional to it.
The IC 1408 consists of a reference current amplifier, an R/2R ladder and high speed
current switches. It has eight input data lines A1 (MSB) through A8 (LSB) which control the
positions of current switches.
It requires 2 mA reference current for full scale input and two power supplies VCC =
+5V and VEE = -15V.
The voltage VREF and resistor R14 determines the total reference current source and
R15 is generally equal to R14 to match the input impedance of the reference current amplifier.
The output current IO can be given as
Block Diagram
The circuit drawn below shows evidently that it is giving output in the bipolar range.
Here resistor RB (5K) is connected between VREF and the output terminal of IC 1408. This
gives a constant current source of 1 mA.
6.Show and explain the ADC interfacing with 8085 microprocessor. (A/M’11)
ADC Interfacing
A/D Converters:
The A/D conversion is a quantizing process whereby an analog signal is converted
into equivalent binary word. Thus the A/D converter is exactly opposite function that of D/A
converter.
Features:
8-bit successive approximation ADC
Conversion time is 100 µs.
Access time is 135 nano seconds
It has an ON-Chip clock generator
It does not require any zero adjustment
It operates on single 5V power supply
Output meet TTL voltage level specifications
Operation:
When the input goes low, the internal successive approximation register (SAR) is
reset. As long as both and remain low, the ADC will remain in its reset state. One to
eight clock periods after or makes a low to high transition and conversion starts. The
signal is hold high during conversion process. After conversion, goes low which
is used as end of conversion signal. By making and signals low, an output can be
read through DB0 to DB7 data signals.
Features:
8 bit successive approximation ADC
8 channel multiplexer with address logic
Conversion time is 100 micro seconds
It eliminates the need for external zero and full scale adjustments
Easy to interface to all microprocessors
It operates on single 5V power supply
Output meet TTL voltage level specifications
ADC 0808/0809 has 8 input channels, so to select desired input channel, it is
necessary to send 3 bit address on A, B and C inputs. The address of the desired channel is
sent to the multiplexer address inputs through port pins. After at least 50 nano seconds, this
address must be latched. This can be achieved by sending ALE signal. After another 2.5
micro seconds, the start of conversion (SOC) signal must be sent high and then low to start
the conversion process. To indicate end of conversion ADC 0808/0809 activates EOC signal.
The microprocessor system can read converted digital word through data bus by enabling the
output enable signal after EOC is activated.
UNIT V
MICROCONTROLLER PROGRAMMING & APPLICATIONS
1.Explain the data transfer instructions and program control instructions of
8051 microcontroller (A/M’11)
1.3.MOVX DESTINATION,SOURCE
1. MOVX A,@DPTR A (DPTR)^
2. MOVX A,@Rp A (Rp)^
3. MOVX @Rp,A (Rp)^ A
4. MOVX @DPTR,A (DPTR)^ A
2. PUSH add (sp) (add)
2.ARITHMETIC OPERATIONS
2.1.ADDITION OPERATION
1. ADD A,Rr A A+Rr
2. ADD A,addr A A+(addr)
3. ADD A,@Rp A A+Rp
4. ADD A,#n A A+n
5. ADDC A,Rr A A+C+Rr
6. ADDC A,addr A A+C+(addr)
7. ADDC A,@Rp A A+C+(Rp)
8. ADDC A,#n A A+C+n
2.4MULTIPLICATION &DIVISION
1. MUL AB A AB0-7 ; B AB8-15
2. DIV AB A A/B ;B A%B
3.LOGICAL INSTRUCTIONS
3.1 ANL INSTRUCTIONS
1. ANL A,Rr A A AND Rr
2. ANL A,addr A A AND (addr)
3. ANL A,@Rp A A AND (Rp)
4. ANL A,#n A A AND n
5. ANL addr,A (addr) (addr) AND A
6. ANL addr,#n (addr) (addr) AND A
3.2.ORL INSTRUCTIONS
1. ORL A,Rr A A OR Rr
2. ORL A,addr A A OR (addr)
3. ORL A,@Rp A A OR (Rp)
4. ORL A,#n A A OR n
5. ORL addr,A (addr) (addr) OR A
6. ORL addr,#n (addr) (addr) OR n
3.3.XRL INSTRUCTIONS
1. XRL A,Rr A A XOR Rr
2. XRL A,addr A A XOR (addr)
3. XRL A,@Rp A A XOR (Rp)
4. XRL A,#n A A XOR n
5. XRL addr,A (addr) (addr) XOR A
6. XRL addr,#n (addr) (addr) XOR n
4.BOOLEAN INSTRUCTIONS
1. CLR c c 0
2. CLR b b 0
3. CPL c c c
4. CPL b b b
5. SETB c c 1
6. SETB b b 1
7. MOV c,b c b
8. MOV b,c b c
9. ANL c,b c c AND b
10. ANL c, b c c AND b
11. ORL c,b c c OR b
12. ORL c, b c c OR b
SJMP b
a: INC R1
b: DJNZ R0,BACK
d: SJMP d
Keyboard Interfacing:-
Simple Keyboard Interfacing:-
Keyboard &display are the external devices used to give information to the
Microcontroller &to see the result from Microcontroller respectively. The transfer of data between
keyboard, display to Microcontroller is called I/O data transfer.
Here 8 keys are individually connected to specific pins of port P1.Each port pin gives the
status of the key connected to that pin .When 4th pin is logic 1, key is open, and otherwise key is
closed.
The following program is the software routine to get key code with key debounce is given below.
START: MOV A, P1
CJNE A, #FFH : START
PRO: LCALL Debounce delay
AGAIN: MOV A, P1
CJNE A, #FFH, PRO1
LJMP : AGAIN
PRO1: LCALL Debounce delay
MOV A, P1
RET
The above program may check whether all keys are opened with the help of compare
port1 (P1) & data FFH. If all keys are open, instruction compare sets the zero flag &the program
waits for key debounce delay (10ms)
KEY CODE
Key D7 D6 D5 D4 D3 D2 D1 D0
K1 1 1 1 1 1 1 1 0
K2 1 1 1 1 1 1 0 1
K3 1 1 1 1 1 0 1 1
K4 1 1 1 1 0 1 1 1
K5 1 1 1 0 1 1 1 1
K6 1 1 0 1 1 1 1 1
K7 1 0 1 1 1 1 1 1
K8 0 1 1 1 1 1 1 1
4.How do you interface a 4X4 matrix keyboard using 8051 microcontroller. (N/D’11)
LOOK UP TABLE:-
ORG 2000H
Kcode 0: 0,1,2,3
Kcode1 : 4,5,6,7
Kcode2 : 8,9,A,B
Kcode3 : C,D,E,F
PROGRAM:-
MOV P2, FFH Configure P2 as input port
K3: MOV P1, #00H Ground all rows
K1: MOV A, P2 Read columns
ANL A, #0FH Masking
CJNE A, #0FH, K1
ACALL delay Debouncing time
K2: MOV A, P2
ANL A, #0FH
CJNE A, #0FH, Over
SJMP K2
Over: ACALL delay wait for bouncing delay
MOV A, P2 Read columns
ANL A, #0FH Masking
CJNE A, #0FH Over1
SJMP K2
Over1: MOV P1, #FEH Ground row0
MOV A, P2
ANL A, #0FH
CJNE A, #0FH, Row0
MOV P1, #FDH Ground Row1
MOV A, P2
ANL A, #0F
CJNE A, #0FH, Row1
MOV P1, #FBHGround Row2
MOV A, P2
ANL A, #0FH
CJNE A, #0FH, Row2
MOV P1, #F7HGround Row3
MOV A, P2
ANL A, #0FH
CJNE A, #0FH, Row3
SJMP K3
Row 0: MOV DPTR, #Kcode0
SJMP Find
Row1: MOV DPTR, #Kcode1
SJMP Find
Row2: MOV DPTR, #Kcode2
SJMP Find
Row3: MOV DPTR, #Kcode3
SJMP Find
Find: RRC A
JNC MatchIf cy = 0 go to match
INC DPTR
SJMP Find
Match: CLR A
MOVC A,@A+DPTR
MOV DPTR, #3000H
MOVX @DPTR, A
SJMP K3
Display Interfacing:-
Usually datas are displayed using LED, LCD&CRT displays.
For displaying large &small amount of datas we use CRT&LED or LCD respectively. Here
we analyze 7 segment LED&LCD interfacing.
PROGRAM:-
MOV R0, #07
MOV R1, #7F
MOV DPTR, #6000H
MOV P3, R1
a: MOVX A, @DPTR
MOV P1, A
MOV A, R1
INC DPTR
RR A MOV
P3, A MOV
R1, A
DJNZ R0, a
b: SJMP b
Liquid crystals are the materials that have the properties of liquid as well as solid crystal.
The term liquid crystal refers to the fact that these compounds have a crystalline arrangement of
molecules, yet they flow like a liquid .According to the operation, LCD may be classified as two
types
6.Explain with a program to rotate the stepper motor in both clockwise and anticlockwise
direction using 8051 microcontroller. (N/D’11)
We know that the stepper motor is stepped from one position to the next by changing the
currents through the fields in the motor. The winding inductance opposes the change in current and
this puts limit on the stepping rate. For higher stepping rates and more torque, it is necessary to use a
higher voltage source and current limiting resistors as shown in figure. By adding series resistance,
we decrease L/R time constant, which allows the current to change more rapidly in the windings.
There is a power loss across series resistor, but designer has to compromise between power and
speed.
PROGRAM:-
AGAIN:
BACK:
ETC:
MOV R0 #
COUNT
MOC DPTR, #ETC
MOV R1, #04
MOVX A,
@DPTR
MOV P1, A
LCALL DELAY
INC DPTR
DJNZ R1, BACK
DJNZ R0, AGAIN
RET
ORG 3000H
DB 03H, 06H, 09H,
0CH