Professional Documents
Culture Documents
TRAP 1
RST7.5 2
RST6.5 3
RST5.5 4
INTR 5
8.
8.What is the signal classification of 8085?
All the signals of 8085 can be classified into 6 groups
1 2
1.Address
. bus 2.Data
. bus
3 4
3.Control
. and status signals 4.Power
. supply and frequency signals
6
5.Externally
5 initiated signals 6.Serial
. I/O ports
Machine cycle is defined as the time required completing one operation of accessing
memory,I/O or acknowledging an external request.T –cycle is defined as one subdivision of
the operation performed in one clock period.
HOLD indicates that a peripheral such a DMA controller is requesting the use of
address bus, data bus and control bus.
READY is used to delay the microprocessor read or write cycles until a slow
responding peripheral is ready to accept or send data.
SID is used to accept serial data bit by bit.
13.Define flags?
The flags are used to reflect the data conditions in the accumulator.the 8085 flags are s-
sign flag,zero flag,auxillary flag,parity flag,
D7 D6 D5 D4 D3 D2 D1 D0
S Z AC P CY
The data transfer between any general- The data transfer only between
purpose register and I/O port accumulator and I/O port
The memory map(64kb)is shared The I/O map is independent of the
between I/O device and system memory memory map,256 input device and 256
output device
More hardware is required to decode 16- Less hardware is required to decode 8-
bit address bit address
To speedup the execution of program, the instructions fetching and execution of instructions
are overlapped each other. This technique is known as pipelining. In pipelining, when then the
instruction is executed, the n+1 the instruction is fetched and thus the processing speed is
increased.
3. 6-byte instruction queue is presented at the Bus Interface Unit (BIU). It is used to pre-fetch
and store at the maximum of 6 bytes of instruction code from the memory. Due to this,
overlapping instruction fetch with instruction execution increases the processing speed.
17.What are the basic units of microprocessosr?
STC – It sets the carry flag & does not affect any other flag
CLC – it resets the carry flag to zero &does not affect any other flag
CMC – It complements the carry flag & does not affect any other
flag
STD – It sets the direction flag to 1 so that SI and/or DI can be decremented automatically
after execution of string instruction & does not affect other flags
CLD – It resets the direction flag to 0 so that SI and/or DI can be incremented automatically
after execution of string instruction & does not affect other flags STI – Sets the interrupt flag
to 1. Enables INTR of 8086.
CLI – Resets the interrupt flagto0. 8086 will not respond to INTR.
When RESET IN pin is asserted low, the program counter, instruction register, interrupt mask bits
and all internal registers are cleared or reset. Also the RESET OUT signal is asserted high to clear
or reset all the peripheral devices in the system. After a reset, the content of program counter will
be 0000H and so the processor will start executing the program stored at 0000H.
20.In which lines the 8085 processor gives the output of IO port address during IO read/write
operation?
When the processor executes an IO read or write cycle, 8-bit port address is sent out both on low
order address bus and high order address bus. This facility offers a flexibility for system designer
to use either low-order address lines or high-order address lines for addressing ports and
generating chip select signals for IO devices.
In the second T-state of the last machine cycle of every instruction, the 8085 processor checks
whether an interrupt request is made or not.
The interrupt acknowledge cycle is a machine cycle executed by 8085 processor after acceptance
of the interrupt to get the address of the interrupt service routine in-order to service the interrupting
device.
23.What will be the status of the processor during bus idle cycle?
During bus idle cycle, the status signals S0 and S1 are both asserted low and data, address and
control pins are driven to high impedance state. Also, the processor will not sample the READY
signal.
The slow peripherals require longer read/write time than allowed by the processor. Hence to
interface slow peripherals, an extra hardware should be designed so that it introduces required
number of wait states in machine cycles between T1 and T2. An alternate solution is to interface
the slow peripherals using ports.
25.What is the difference between wait state and bus idle condition?
During bus idle condition, the tristate pins of the processor are driven to high impedance state, but
during wait state they are in normal states (either low or high). The READY is not sampled during
bus idle condition but it is sampled during wait state.
PART B
Address Bus:
The address bus is a group of 16 lines generally identified as A0 to A15. The address bus is
unidirectional and bits flow in one direction-from the MPU to peripheral devices.The MPU
uses the address bus to identify a peripheral or a memory (216 =
65,536) locations
Data Bus:
The data bus is a group of 8 lines used for data flow. These lines are bi-directional and data
flow in both directions between the MPU and memory and peripheral devices. The MPU
uses the data bus to transfer data.
Control Bus:
The control bus carries synchronization signals and providing timing signals.The MPU
generates specific control signals for every operation it performs.These signals are used to
identify a device type with which the MPU wants to communicate.
Registers of 8085:
The 8085 have six general-purpose registers to store 8-bit data dur ng program execution.
These registers are identified as B, C, D, E, H, and L.They can be combined as registerpairs-
BC, DE, and HL-to perform some 16-bit operations.
Accumulator (A):
The accumulator is an 8-bit register that is part of the arithmetic/logic unit (ALU).This
register is used to store 8-bit data and to perform arithmetic and logical operations.The result
of an operation is stored in the accumulator.
Flags:
The microprocessor uses the 5 flags for testing the data conditions.They are Zero (Z), Carry
(CY), Sign (S), Parity (P), a d Auxiliary Carry (AC) flags.The flagsare set or reset according
to the result of an operation.The bit position for the flags in flag register is,
3. Auxiliary Carry Flag (AC): If D3 generates any carry when doing any arithmetic and
logical operation, this flag is set. Otherwise it is reset.
4. Parity Flag (P): If the result of arithmetic and logical operation contains even number of
1's then this flag will be set and if it is odd number of 1's it will be reset.
5. Carry Flag (CY):If any arithmetic and logical operation result any carry then carry
flag is set otherwise it is reset.
Temporary Register:
It is used to hold the data during the arithmetic and logical operations.
Instruction Register:
When an instruction is fetched from the memory, it is loaded in the instruction register.
Instruction Decoder:
It gets the instruction from the instruction register and decodes the instruction. It
identifies the instruction to be performed.
RD (Active low) and WR (Active low) are used to indicate whether the operation is
reading the data from memory or writing the data nto memory respectively.
IO/M(Active low) is used to indicate whether the operation is belongs to the memory or
peripherals.
2.Draw the signal (pin diagram) configuration of 8085 and explain the purpose of
each signals. (Dec-2012)
8085 is a 40 pin IC, DIP package. The signals from the pins can be grouped as follows
Power supply and clock signals
Address bus
Data bus
Control and status signals
Interrupts and externally initiated signals
Serial I/O ports
Direct Memory Access (DMA):
During the opcode fetch operation, in the first clock cycle, the lines deliver the
lower
order address A0 - A7.
In the subsequent IO / memory, read / write clock cycle the lines are used as
data bus.
TheCPU may read or write out data through these lines.
This indicates that the selected memory location or I/O device is to be read and the data
bus is ready for accepting data from the memory or I/O device.
This status signal indicates that the read / write operation relates to whether the memory or
I/O device.
It goes high to indicate an I/O operation.
It goes low for memory operations.
Status Signals:S1,S0
It is used to know the type of current operation of the microprocessor.
S1 S0 Operation Specified
0 0 Halt
1 1 Instruction Fetch
i) TRAP
ii) RST 7.5
iii) RST 6.5
iv) RST 5.5
v) INTR
RESTART INTERRUPTS: These three inputs have the same timing as INTR. They
are RST 7.5,RST 6.5, RST 5.5
Types of Interrupts Priority
TRAP Highest
RST 7.5
RST 6.5
RST 5.5
INTR Lowest
On receipt of an interrupt, the microprocessor acknowledges the interrupt by the active low
INTA (Interrupt Acknowledge) signal.
HOLD :HOLD signal is generated by the DMA controller circuit. The I/O device request the
processor for the address/data bus for bulk data transfer. HLDA:(HOLD
ACKNOWLEDGE) On receipt of HOLD signal, the microprocessor acknowledges the
request by sending out HLDA signal and leaves out the control of the buses. After the HLDA
signal the DMA controller starts the direct transfer of data.
READY (input)
Memory and I/O devices will have slower response compared to microprocessors.
Before completing the present job such a slow peripheral may not be able to handle further
data or control signal from CPU.
The processor sets the READY signal after completing the present job to access the data.
The microprocessor enters into WAIT state while the READY pin is disabled.
SOFTWARE INTERRUPTS:
The software interrupts are program instructions. These instructions are inserted at desired
locations in a program. While running a program, lf a software interrupt instruction is
encountered, then the processor executes an interrupt service routine (ISR).
The software interrupts of 8085 are RST 0, RST 1, RST 2, RST 3, RST 4, RST 5, RST6
and RST7.
All software interrupts of 8085 are vectored interrupts. The software interrupts cannot be
masked and they cannot be disabled. When the p ocessor encounters the software instruction,
it pushes the content of PC to stack. Th n loads the Vector address in PC and starts executing
the ISR stored in this vector address. At the end of ISR, a return instruction – RET will be
placed. When the RET instruction is executed, the processor POP the content of stack to PC.
Interrupt Vector address
RST 0 0000H
RST 1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H
RST 6 0030H
RST 7 0038H
HARDWARE INTERRUPTS:
The hardware interrupts are initiated by an external device by placing an appropriate signal at
the interrupt pin of the processor.The processor keeps on checking the interrupt pins at the
second T-state of last machine cycle of every instruction.If the processor finds a valid
interrupt signal and if the interrupt is unmasked and enabled, then the processor accepts the
interrupt.The acceptance of the interrupt is acknowledged by sending an INTA signal to the
interrupted device. The processor saves the content of PC in stack and then loads the vector
address of the interrupt in PC.If the interrupt is non-vectored, then the interrupting dev ce has
to supply the address of ISR
when it receives INTA signal. It starts executing ISR in this address.At the end of ISR, a
return instruction, RET will be placed.When the processor executes the RET instruction, it
POP the content of top of stack to PC. Thus the processor control returns to main program
after servicing interrupt.
The hardware interrupts of 8085 are TRAP, RST 7.5, RST 6.5, RST 5.5 and INTR
Further the interrupts may be classified into VECTORED and NON-VECTORED
INTERRUPTS.
VECTORED INTERRUPT:
In vectored interrupts, the processor automatically branches to the specific address in
response to an interrupt.
The TRAP, RST 7.5, RST 6.5 and RST 5.5 are vectored interrupts.
The vector addresses of hardware interrupts are given in the table.
TRAP 0024H
NON-VECTORED INTERRUPT:
In non-vectored interrupts the interrupted device should give the address of the interrupt
service routine (ISR).
The INTR is a non-vectored interrupt.
When a device interrupts through INTR, it has to supply the address of ISR after receiving
interrupt acknowledge signal.
TRIGGERING EDGE OF 8085 INTERRUPTS:
The TRAP interrupt is edge and level sensitive.To init ate TRAP, the interrupt signal has to
make a low to high transition and then it has to r main high until the interrupt is
recognized.The RST 7.5 interrupt is positive edge s nsitive. To initiate the RST 7.5, the
interrupt signal has to make a low to high tra sition and it need not remain high until it is
recognized.The RST 6.5, RST 5.5 and INTR are level sensitive interrupts.Hence for these
interrupts the interrupting signal should remain high, until it is recognized.
Non-maskable Interrupts:
The interrupts hich cannot be disabled are called Non-maskable Interrupts.
TRAP is non-maskable interrupt.
Maskable Interrupts:
The interrupts which can be enabled or disabled are called Maskable Interrupts.
RST 7.5, RST 6.5, RST 5.5 and INTR are Maskable interrupt.
Masking is preventing the interrupt from disturbing the main program.When an interrupt is
masked the processor will not accept the interrupt signal.The interrupts can be masked by
executing SIM instruction. (SIM - Set InterruptMask).The status of maskable interrupts can
be read into accumulator by executing RIM instruction (RIM - Read Interrupt Mask).All the
hardware interrupts, except TRAP are disabled, when the processor is resetted.They can also
be disabled by executing DI instruction. (Dl-Disable Interrupt).When an interrupt is disabled,
it will not be accepted by the processor.To enable the disabled interrupt, the processor has to
execute El instruction (El-Enable Interrupt).
INTERRUPT PRIORITY:
The order in which the interrupt has to be serviced is called Interrupt Priority.The priority
order of the 8085 interrupt is
Interrupt Interrupt Priority
TRAP 1
RST 7.5 2
RST 6.5 3
RST 5.5 4
INTR 5
4..Draw the timing diagram for Opcode Fetch machine cycle, Memory Read machine
cycle,MemoryWrite,I/O read machine cycle and I/O write machine Cycle. (Nov/Dec-
2014)
Instruction Cycle:
The time required to execute an instruction is called instruction cycle.
Machine Cycle
The time required to access the memory or input/output devices is called machine cycle.
T-State
A portion of an operation carried out in one system clock period is called as T-state.The
machine cycle and instruction cycle takes multiple clock periods.
8085 places 16-bit address from PC on to the address bus and issues ALE pulse in first T-
state (T1). This is used to de-multiplex the address and data bus. It also issues IO/M‟ signal
to „0‟. This indicates that processor is performing memory related operation. In second T-
state (T2) processor issues RD‟ control signal to memory. This enables memory to put data
present at the address location given in previous T-state on to data bus. RD‟ control signal is
active for two clock pulses.
Fig: Timing Diagram of 8085 Microprocessor
In T3 state memory places opcode on Data bus. Processor reads opcode present on data bus
and de-asserts RD‟ signal. Thus data bus goes into high impedance state.
In T4 state processor decodes instruction and necessary actions are performed.
This machine cycle is required when an operand is present in memory. This machine cycle
requires three T-states. The following are the sequence of actions performed by
microprocessor during this machine cycle.
In the first T-state (T1) 8085 places address on address bus and issues ALE signal.
And also IO/M‟ signal is made low, since it is memory related operation.
In the second T-state (T2), processor issues RD‟ control signal to memory. In response to
this memory places data on data bus.
In the third T-state (T3), processor reads data from data bus, and de-asserts RD‟ signal.
In second T-state (T2), processor places data to be written on data bus and asserts WR‟
signal to the memory.
In the third T-state (T3), memory stores the data and processor de-asserts WR‟ signal.
In the first T-state (T1) 8085 places port address(for IO mapped addresses port address is
8-bit, but for memory mapped addresses IO device address is 16-bit, but reading from such is
performed by memory read machine cycle) on address bus and issues ALE signal. And also
IO/M‟ signal is made high, since it is IO related operation.
In the second T-state (T2), processor issues RD‟ control signal to IO peripheral.
In response to this input device places data on data bus.
In the third T-state (T3), processor reads data from data bus, and de-asserts RD‟ signal.
IO write Machine cycle:
This machine cycle is required when data needs to be output to an output device. This
machine cycle requires three T-states. The following are the sequence of actions performed
by processor during this machine cycle.
In first T-state (T1), 8085 processor places 8-bit port address on address bus (for IO
mapped addresses port address is 8-bit, but for memory mapped addresses, IO device address
is 16-bit, but writing to such is performed by memory write machine cycle) and issues ALE
signal. And also it makes IO/M‟ signal to high, indicating it is IO related operation.
In second T-state (T2), processor places data to be written on data bus and asserts WR‟
signal to the peripheral.
In the third T-state (T3), peripheral accepts the data and processor de-asserts
WR‟ signal.
5.Explain how the memory organization was done in 8085.
8085 has 16 bit address bus, hence it can access 216 no. of memory locations,
which is equal to 64KB memory. Memory is required to store program as well as data.
Since microprocessor doesn‟t have on-chip memory, we need to connect it externally.So it
requires addressing mechanism.
The following are the steps involved in interfacing memory with 8085 processor.
1. First decide the size of memory requires to be nterfaced. Depending on this
we can say how many address lines are required for it. For example if you
2. want to interface 4KB (212) memory it requires 12 address lines. Remaining address
lines can be used in address decoding.
3. Depending on the size of memory r quired and given address range, construct address
decoding circuitry. This address decoding circuitry can be implemented with NAND gates
and/or decoders or using PAL.
4. Connect data bus of memory to processor data bus.
5. Generate the control signals required for memory using IO/M‟, WR‟, RD‟ signals of
8085 processor.
Example:
Interface 4KB memory to 8085 with starting address A000H.
1. 4KB memory requires 12 address lines for addressing as already mentioned. But 8085 has
16 address lines. Hence four of address lines are used for address decoding
2. Given that starting address for memory is A000H. So for 4KB memory ending address
becomes A000H+0FFFH (4KB) = AFFFH.
A0-A11 address lines are directly connected to address bus of memory chip. A12-A15 are
used for generating chip select signal for memory chip.
A15 line is use for enabling 74x138 decoder chip. A12, A13, A14 lines are connected to
74X138 chip as inputs. When theses li es are 010 output should be „0‟. This is provided at
O2 pin of 74X138 chip.
Address decoding circuit using only NAND gates:
A15, A14, A13, A12 inputs should be 1010, for enabling the chip. So the circuit for this is
as shown above.
There are two types of address decoding mechanism, based on address lines used for
generating chip select signal.
1. Absolute decoding
2. Partial decoding
Absolute decoding:
All the higher order lines of microprocessor, left after usi g the required signals for memory
are completely used for generating chip select s gnal.This type of decoding is called absolute
decoding.
Partial decoding:
Only some of the address lines of m croprocessor left after using the required signals
for memory are used for generating chip select signal. Because of this multiple address
ranges will be formed. If total memory space is not required for the system then, this type of
address decoding can be used. The advantage of this technique is fewer components are
required for memory interfacing because of this board size reduces and in turn cost reduces.
UNIT-II PROGRAMMING OF 8085 PROCESSOR
PART - A
1. What is indexing?NOV/DEC 2012
Indexing technique allows programmer to point or refer the data stored in sequential
memory locations one by one.
14.What are the four instructions which control the interrupt structure of the 8085
microprocessor?
DI(disable interrupts)
EI(enable interrupts)
RIM(read interrupt masks)
SIM(set interrupt masks)
The timing and control unit synchronizes all the microprocessor operations with
clock and generates control signals necessary for communication between the
microprocessor and peripherals.
19.What is DAA ?
20.What is DAD and what are the flags affected by this instruction?
DAD refers to Double Addition. This instruction is used to perform addition of two 16-bit data.
Syntax : DAD rp
The content of register pair (rp) is added to the content of HL pair. After addition, the result
will be in HL pair. The register pair can be BC, DE, HL, or SP. On execution of this
instruction, only carry flag is affected.
22. What is the similarity and difference between subtract and compare instruction?
Similarity : Both the subtraction and comparison are performed by subtracting two data in ALU
and flags are altered depending upon the result.
Difference : After subtract instruction is executed, the result is stored in accumulator, but after
the execution of compare instruction the result is discarded ( i.e., the subtract instruction alters
the content of destination register (accumulator), but the compare instruction will not alter the
content of any register or memory).
PART - B
1. What are the different addr ssing modes in 8085 microprocessor? Explain it
with an example? NOV/DEC 2015,NOV/DEC 2014,NOV/DEC 2012,MAY/JUNE
2012 MAY/JUNE 2011
Example: MVI A, 01H- Move the data 01H given in the instruction to A register.
2.Direct Addressing :
In direct addressing mode, the address of the data is specified in the instruction.The data
will be in memory. In this addressing mod , the program instructions and data can be
stored in different memory blocks. This type of addressing can be identified by 16-bit
address present in the instruction.
Example:LDA 4500H- Load the data available in memory location 4500H in A register.
3.Register Addressing :
In register addressing mod , the instruction specifies the name of the register in which the
data is available.This type of addressing can be identified by register names in the
instruction.
This type of addressing can be identified by letter „M‟ present in the instruction.
5.Implied Addressing :
In implied addressing mode, the instruction itself specifies the type of operation and
location of data to be operated. This type of instruction does ot have any address, register
name, immediate data specified along with it.
Example:CMA - Complement the content of accumulator
MOV Rd, Rs
MOV M, Rs
MOV Rd, M
This instruction copies the contents of the source register into the destination register.
The contents of the source register are not altered.If one of the operands is a memory
location, its location is specified by the contents of the HL registers.
Example: MOV B, C - This instruction move the content of C register to B register.
MOV B, M -This instruction move the content of memory location pointed by HL
register to B register.
LOAD ACCUMULATOR:
EXCHANGE:
XCHG
The contents of register H are exchanged with the contents of register D, and the contents
of register L are exchanged with the contents of re ister E.
Example: XCHG :This instruction exchange the content of H and L with D and E
2.ARITHMETIC INSTRUCTIONS:
The arithmetic instructions includes addition, subtraction ,increment and decrement
operations.
ADDITION:
ADD REGISTER OR MEMORY TO ACCUMULATOR
ADD Rs
ADD M
The contents of the operand (register or memory) are added to the contents of the
accumulator and the result is stored in the accumulator. If the operand is a memory
location, its location is specified by the contents of the HL registers. All flags are
modified to reflect the result of the addition.
Example: ADD B – The content of A register is added with the content of B register and
the result is stored in A register.
ADD M -The content of A register is added with the content of
memory location pointed by HL register and the result is stored in A register.
SUBTRACTION:
Example: SUB B – The content of A register is subtracted with the content of B register
and the result is stored in A register.
SBB R
SBB M
The contents of the operand (register or memory ) and the Borrow flag are subtracted
from the contents of the accumulator and the result is placed n the accumulator. If the
operand is a memory location, its location is specified by the contents of the HL
registers.All flags are modified to reflect the result in accumulator.
Example: SBB B -The content of A register is subt acted with the content of B register
and also Borrow flag and the result is stored in A r gist r.
SBB M - The content of A register is subtracted with the content of memory
location pointed by HL register and also Borrow and the result is stored in A register.
3.LOGICALINSTRUCTIONS:
The logical instructions includes AND,OR,XOR,Complement operations.
Logical AND :
Logical AND register or memory with accumulator
ANA R
ANA M
The contents of the accumulator are logically ANDed with the contents of the operand
(register or memory), and the result is placed in the accumulator.If the operand is a
memory location, its address is specified by the contents of HL registers.S, Z, P are
modified to reflect the result of the operation. CY is reset. AC s set.
Example: ANA B - The content of A register is ANDed with the content of B register
and the result is stored in A register.
ANA M - The content of A register is ANDed with the content of
memory location pointed by HL register and the result is stor d A register.
XRA R
XRA M
The contents of the accumulator are Exclusive ORed with the contents of the operand
(register or memory), and the result is placed in the accumulator.If the operand is a
memory location, its address is specified by the contents of HL registers.
S, Z, P are modified to reflect the result of the operation. CY and AC are reset.
Example: XRA B -The content of A register is XORed with the content of B register
and the result is stored in A register.
XRA M -The content of A register is XORed with the content of
memory location pointed by HL register and the result is stored A
register.
ORA R
ORA M
The contents of the accumul tor are logically ORed with the contents of the operand
(register/memory), and the R sult is placed in the accumulator.If the operand is a memory
location, its address is specified by the contents of HL registers.
S, Z, P are modified to reflect the result of the operation. CY and AC are reset.
Example: ORA B -The content of A register is ORed with the content of B register
and the result is stored in A register.
ORA M- The content of A register is ORed with the content of
memory location pointed by HL register and the result is stored A register.
COMPLEMENT ACCUMULATOR:
CMA
The contents of the accumulator are complemented.
No flags are affected.
Example: CMA
COMPLEMENT CARRY:
CMC
The Carry flag is complemented.No other flags are affected.
Example: CMC
SET CARRY :
STC
The Carry flag is set to 1.No other flags are affected.
Example: STC
The branching instructions are used to change the execution order.They are divided into
conditional jump/call or unconditional jump/call.
JUMP UNCONDITIONALLY
Example:
JZ Jump on Zero Z =1
Example: CZ 4000
CZ Call on Zero Z =1
RET
The program sequence is transferred from the subroutine to the calling program. The two
bytes from the top of the stackare copied into the program counter, and program
execution begins at the new address.
Example: RET
Example: RZ
RZ Return on Zero Z =1
RNZ Return on no Zero Z=0
These instructions are used to manipulate the stack to perform the input /output and to
alter the internal control flags.Unless specified the flags are not affected.
STACK INSTRUCTION:
PUSH :
Example: PUSH PSW
The contents of register A and the contents of condition flags which form the PSW are
pushed onto the stack.
POP INSTRUCTION:
Example: POP PSW
The contents of register A and the contents of condition flags which form the PSW are
restored from the stack
I/O INSTRUCTION :
IN port
The data placed on the 8 bit bidirectional data bus by the specified port is moved to
register A.
OUT port
The contents of register A are placed on the 8 bit data bus is transferred to the specified
port.
DI
The interrupt system is disabled.
NOP
No Operation is performed.No flags are affected.
HLT
The processor is stopped.No flags are affected.
3.Write an 8085 ALP to add, subtract, multiply and divide two 8 bit
numbers stored at consecutive memory locations. NOV/DEC 2015
8 BIT ADDITION:
ALGORITHM:
PROGRAM:
8 BIT SUBTRACTION:
PROGRAM:
8 BIT DIVISION:
ALGORITHM:
LARGEST NUMBER:
ALGORITHM:
PROGRAM:
SMALLEST NUMBER:
ALGORITHM:
PROGRAM:
5.Write an 8085 ALP to arrange in ascending and descending order.
MAY/JUNE 2013,MAY/JUNE 2012
Ascending Order:
ALGORITHM:
1. Get the numbers to be sorted from the memory locations.
2. Compare the first two numbe s a d if the first number is larger than
second then interchange the number.
3. If the first number is small r, go to step 4
4. Repeat steps 2 and 3 until the numbers are in required order
PROGRAM:
DESCENDING ORDER
ALGORITHM:
1. Get the numbers to be sorted from the memory locations.
2. Compare the first two numbers and if the first numb r is
smaller than second then interchange the number.
3. If the first number is larger, go to step 4
4. Repeat steps 2 and 3 until the numbers are in required order
PROGRAM:
UNIT-III
8051 MICROCONTROLLER
PART - A
1. What is Microcontroller?
A device which contains the microprocessor with integrated peripherals like memory, serial ports,
parallel ports, timer/counter, interrupt controller, data acquisition interfaces like ADC, DAC is called
microcontroller.
P3.2 INT0
P3.3 INT1
P3.4 T0
P3.5 T1
P3.6 WR
P3.7 RD
5. What is the role of DPTR in 8051 Microcontroller?
The Data Pointer (DPTR) is the 8051s only user-accessible 16-bit (2-byte) register. The
Accumulator, "R" registers, and "B" register are all 1-byte values. DPTR, as the name suggests, is
used to point to data. It is used by a number of commands which allow the 8051 to access external
memory. When the 8051 accesses external memory it will access the external memory at the address
indicated by DPTR. While DPTR is most often used to point to data in external memory, many
programmers often take advantage of the fact that it‟s the only true 16-bit register available. It is
often used to store 2-byte values which have nothing to do with memory locations.
Stack pointer (SP) is a 8 bit wide register and is incremented before the data is stored into the stack
using PUSH or CALL instructions. It contains 8-bit stack top address. It is defined anywhere in the
on-chip 128-byte RAM. After reset, the SP register is initialized to 07. After each write to stack
operation, the 8-bit contents of the operand are stored onto the stack, after incrementing the SP
register by one. It is not a top-down data structure. It is allotted an address in the special function
register bank.
ALE/PROG is an address latch enable output pulse and indicates that valid address bits available on
the respective pins. The ALE pulses are emitted at a rate of one-sixth of the oscillator frequency. The
signal is valid only for external memory accesses.
8. Write the vector address and priority sequence of 8051 interrupts (Nov/Dec 2014)
The interrupts are Vector address
:
External interrupt 0 IE0: 0003H
:
Timer interrupt 0 TF0:000BH
:
External interrupt 1 IE1: 0013H
:
Timer Interrupt 1 TF1:001BH
:
Serial interrupt RI: 0023H
:
Transmit interrupt TI: 0023H
:
9. What are the addressing modes of 8051 microcontroller? (Nov/Dec 2014) The 8051 provides a
total of five distinct addressing modes.
(1) Immediate
(2) register
(3) direct
(4) register indirect
(5) indexed
11. List the interrupt sources in 8051 microcontroller. (May/June 2014) (Nov/Dec 2015)
16. List the instructions that affect the overflow flag in 8051
ADD,
ADDC,
SUBB,
DIV and
MUL.
17. Write the functions of TMOD register in 8051 Microcontroller. (Nov/Dec 2015)
18.Write a program to save the status of bits p1.2 and p1.3 on ram bit locations 6 and 7
respectively.
19. Write a program to see if bits 0 and 5 of register b r1. If they are not, make them so
and save it in r0. (Nov/Dec2011)
Access times for memory and Less access time for built-in memory
4 I/O devices are more and I/O devices
The special function register are stack pointer, index pointer (DPL and DPH), I/O port addresses, status
(PSW) and accumulator.
22. What are the uses of accumulator register?
The accumulator registers (A and B at addresses OEOh and OFOh, respectively) are used to store
temporary values and the results of arithmetic operations.
Program status word (PSW) is the set of flags that contains the status information and is considered as
one of the special function register.
Give the purpose of ALE/PROG signal. (May/June2014)
ALE/PROG is an address latch enable output pulse and indicates that valid address bits available on the
respective pins. The ALE pulses are emitted at a rate of one-sixth of the oscillator frequency. The signal is valid
only for external memory accesses.
Idle mode: In this mode, the oscillator continues to run and the interrupt, serial port and timer blocks are
active, but the clock to the CPU is disabled. The CPU status is preserved. This mode can be terminated
with a hardware interrupt or hardware reset signal. After this, the CPU resumes program execution from
where it left off.
Power down mode: In this mode, the on-chip oscillator is stopped. All the functions of the controller
are held maintaining the contents of RAM. The only way to terminate this mode is hardware reset. The
reset redefines all the SFRs but the RAM contents are left unchanged.
25.What are the two main features of sfr addresses?
The special function registers have addresses between 80H and FFH. These addresses are above 80H,
since the addresses 00 to 7FH are addresses of RAM memory inside the 8051.
Not all the address space of 80 to FH is used by the SFR. The unused locations 80Hto FFH are
reserved and must not used by the 8051 programmer.
PART - B
1. Explain with a neat block diagram the architectu e of 8051microcontroller.
(May/June 2013) (May/June 2015)
2.ProgramCounter(PC):
A program counter is a 16-bit register and it has no internal address.The basic function of program
counter is to fetch the next instruction to be executed.The PC increments automatically, holding the
address of the next instruction.
3.Registers:
Registers are usually known as data storage devices. 8051 microcontroller has 2 registers, namely
Register A and Register B.These registers are used to store the output of mathematical and logical
instructions.
Accumulator(A Register):
B Register:
Register B functions as a general purpose register. Register B is usually unused and comes into
picture only when multiplication and division functions are carried out by Register A.
RAM
The 8051 microcontroller is composed of 128 bytes of internal RAM. This is a volatile memory
since its contents will be lost if power is switched off. These 128 bytes of internal RAM are divided
into 32 working registers.This 32 working registers divided into 4 register banks (Bank 0-Bank 3)
with each bank consisting of 8 registers (R0 - R7). There are 128 addressable bits in the internal
RAM.It is also called as program memory.
6.FourParallelInput/OutputPorts:
The 8051 microcontroller has four 8-bit input/output ports. These are: P0,P1,P2,P3.
PORT P0:
When there is no external memory present, this port acts as a general purpose input/output port.In
the presence of external memory, it functions as a multiplexed address and data bus. It performs
dual funct ons.
PORT P1:
This port is used for various interfacing activities.This 8-bit port is a normal I/O port.
PORT P2:
This port can be used as a g n ral purpose port when there is no external memory.
When external memory is present it works in conjunction with PORT PO as an address
bus.
.
PORT P3:
PORT P3 behaves as a dedicated I/O port.
.InterruptControl:
A signal which is used to suspend or halt the normal program execution for a temporary period of
time in order to serve the request of another program or hardware device is called an interrupt. An
interrupt can either be an internal or external.
The interrupt mechanism keeps the normal program execution in a "put on hold" mode and
executes a subroutine program and after the subroutine is executed, it gets back to its normal
program execution.
In8051,5sourcesofinterruptsareprovided.Theyare:
a)2ExternalinterruptsourcesINT0andINT1
b) 3 Internal interrupt sources - Serial port interrupt, Timer Flag 0 and Timer Flag 1.
9.PSW(ProgramStatusWord):
Program Status Word is a register which holds a program's information and also monitors
the status of the program currently being executed.
PSW also has a pointer which points towards the address of the next instruction to be executed.
10.DataPointer(DPTR):
The data pointer or DPTR is 16-bit register. It is made up of two 8-bit registers called
DPH and DPL. Separate addresses are assigned to each of DPH and DPL. These 8-
bit registers are used for the storing the memory address.
11.StackPointer(SP):
The stack pointer (SP) in 8051 is an 8-bit register. The main purpose of SP is to
access the stack. Stack is a special area of data in memory. The SP acts as a pointer
for an address that points to the top of the stack.
12.DataandAddressBus:
A bus is group of wires using which data transfer takes place from one location to another
within a system There are mainly two kinds of buses - Data Bus and Address Bus
Data Bus:
The purpose of data bus is to transfer data. The no of data lines decides the word
length of the microcontroller. The data bus is bidirectional.
Address Bus:
The purpose of address bus is to transfer information. The information tells from
where within the components, the data should be sent to or received from. The no of
address lines decides the capacity of memory address. The address bus is
unidirectional.
13.Clock Circuits:
Internal operations can be synchronized using clock circuits which produce clock
pulses.
With each clock pulse, a particular function w ll be done and hence synchronization
is achieved. There are two pins XTAL1 and XTAL2 which form an oscillator circuit
which connect to a resonant network in the microcontroller.Quartz crystal is used to
generate gate pulse.
1. ALE(Address Latch Enable)Latches the address signals on Port P0
2. EA (External Address) - Holds the 4K bytes of program memory
3. PSEN (Program Store Enable) - Reads external program memory
4. RST (Reset) - Reset the ports and internal registers upon start up
2. Explain the interrupt structure of 8051 microcontroller. (May/June 2015)
An interrupt is a signal which interrupts normal program execution.
Program flow is always sequential, being altered only by those instructions and cause
program flow to deviate. Interrupts give to "put on hold" the normal program flow,
and execute a subroutine. After completion of subroutine microcontroller resume
normal program flow. This subroutine, called an ISR, which is only executed when a
certain interrupt occurs. The microcontroller 8051 has the following interrupt signals
External 0 Interrupt
Timer 0 over flow Interrupt
External 1 Interrupt
Timer 1 over flow Interrupt
Serial Interrupt
The various interrupts and their different code depending on interrupt was executed.
This is done by jumping to a fixed address when a given interrupt occurs.
Whenever Timer 0 overflows (i.e., the TF0 bit is set), the main program will be
temporarily suspended and control will jump to 000BH.The program code at address
000BH that handles the interrupt of Timer 0 overflowing.
This means that if a Serial Interrupt occurs at the exact same instant that an External
0 Interrupt occurs, the External 0 Interrupt will be executed first and the Serial
Interrupt will be executed once the External 0 I terrupt has completed.
Interrupt Priorities :
The 8051 offers two levels of interrupt priority: high and low. By using interrupt
priorities you may assign higher priority to certain interrupt conditions.Interrupt
priorities are controlled by the IP SFR (B8h).
When an interrupt is triggered, the following actions are taken automatically by the
microcontroller
End of Interrupt:
An interrupt ends when the program executes the RETI (Return from Interrupt)
instruction. When the RETI instruction is executed the following actions are taken by
the microcontroller:
Two bytes are popped off the stack into the Program Counter to restore normal
program execution.
Interrupt status is restored to its pre-interrupt status.
Serial Interrupts :
Serial Interrupts are slightly different than the rest of the interrupts. There are two
interrupt flags: RI and TI. If either flag is set, a serial interrupt is triggered. In the
serial port, the RI bit is set when a byte is received by the serial port and the TI bit is
set when a byte has been sent. The serial interrupt is executed, because the RI flag
was set or because the TI flag was set--or because both flags were set. The, ISR must
check the status of these flags to determine what action is appropriate. The 8051 does
not automatically clear the RI and TI flags and it can be clear by interrupt handler.
Program Memory:
Program memory – 64 KB of program memory includes the 4KB of the on- chip
ROM. If the address exceeds 0FFF H, it will access the external program memory.
The processor will come to know whether the user wants to use the Internal ROM or
not from the EA(active low) pin. If this pin is pulled low, it means that the user does
not want to use the Internal ROM available. The processor will 0000H-FFFFH from
the external Program Memory. If this pin is held high, the processor will access
0000H - 0FFFH from the Internal ROM and as address goes above 0FFFH, it will
access the external Program Memory that is interfaced it
If EA (active low)= 5V
5.Draw the pin diagram of 8051 microcontroller and explain its port structure.
P3.1-TxD:
It is O/P signal of serial port. Through this signal data is transmitted.
P3.2- (INT0):
It is external hardware interrupt I/P signal. Through this user, programmer or
peripheral interrupts to microcontroller.
P3.3-(INT1):
It is external hardware interrupt I/P signal. Through this user, programmer or
peripheral interrupts to microcontroller.
P3.4- T0:
It is I/P signal to internal timer-0 circuit. External clock pulses can connects to timer-
0 through this I/P signal.
P3.5-T1:
It is I/P signal to internal timer-1 circuit. xternal clock pulses can connects to timer-1
through this I/P signal.
P3.6-WR:
It is active low write O/P control signal. During External RAM (Data memory)
access it is generated by microcontroller. when [WR(bar)]=0, then performs write
operation.
P3.7- RD:
It is active low read O/P control signal. During External RAM (Data memory) access
it is generated by microcontroller. when [RD(bar)]=0, then performs read operation
from external RAM.
XTAL1 and XTAL2:
These are two I/P line for on-chip oscillator and clock generator circuit. A resonant
network as quartz crystal is connected between these two pin. 8051 microcontroller
also drives from external clock, then XTAL2 is used to drive 8051 from external
clock and XTAL1 should be grounded.
EA/VPP:
It is and active low I/P to 8051 microcontroller. when (EA)= 0, then 8051
microcontroller access from external program memory (ROM) only. When (EA) = 1,
then it access internal and external program memories (ROMS).
PSEN:
It is active low O/P signal. It is used to enable exte nal p ogram memory (ROM).
When [PSEN(bar)]= 0, then external program memory b comes enabled and
microcontroller read content of external memory location. Ther fore it is connected
to (OE) of external ROM. It is activated twice every external ROM memory cycle.
ALE:
Address latch enable: It is active high O/P signal. When it goes high, external
address latch becomes enabling and lower address of external memory (RAM or
ROM) latched into it. Thus it separates A0-A7 ddress from AD0-AD7. It provides
properly timed signal to latch lower byte addr ss. The ALE is activated twice in
every machine cycle. If external RAM & ROM is not accessed, then ALE is
activated at constant rate of 1/6 oscillator frequency, hich can be used as a clock
pulses for driving external devices.
RESET:
It is active high I/P signal. It should be maintained high for at least two machine
cycle while oscillator is running then 8051 microcontroller resets.
UNIT- IV PERIPHERAL INTERFACING
PART - A
Asynchronous synchronous
Data can be sent one character at a time used for transferring large
amount of data
5. What are the functions of USART? (Nov/Dec-2014)
The scan counter has two modes to scan the key matrix and refresh the display.
In the encoded mode, the counter provides binary count that is to be externally decoded
to provide the scan linesfor keyboard and display. In the decoded scan mode, the
counter internally decodes the least significant 2 bit and provides a decoded 1 out of 4
scan on SL3-SL 3. The keyboard and display both are in the same mode at a time.
(handshake mode) iii. Mode 2- Strobe bi-directional mode b) Bit Set/Reset Mode.
11. What are the different peripheral interfacing used with 8085
microprocessor? (May/June-2013)
13. What are the different types of command words used in 8259A? (Nov/Dec-2013)
The command words of 8259A are classified in two groups
1. Initialization command words (ICWs)
2. Operation command words (OCWs)
In this the data is transferred bit by bit that is used for one to one communication.
16.What are the different types of ADC?
The different types of ADC are successive approximation ADC, counter type
ADC flash type ADC, integrator converters and voltage to- frequency converters.
Serial data buffer is a special function register and it initiates serial transmission when byte
is written to it and if read, it reads received serial data. It contains two independent
registers internally. One of them is a transmit buffer, which is a parallel-in serial-out
register. The other is a receive buffer, which is a serial-in parallel-out register
Timer registers are two 16-bit registers and can be accessed as their lower and upper bytes.
TLO represents the lower byte of the timing register 0, while THO represents higher bytes
of the timing register 0. Similarly, TLI and THI represent lower and higher bytes of timing
register 1. These registers can be accessed using the addresses allotted to them, which lie in
the special function registers address range, i.e., 801 H to FF.
Timing and control unit is used to derive all the necessary timing and control signals
required for the internal operation of the circuit. It also derives control signals that are
required for controlling the external system bus.
The timer overflow bits are set when timer rolls over and reset either by the execution of an
RET instruction or by software, manually clearing the bits. The bits are located in the
TCON register along with timer run control (TRn) bits
Timer mode 0 and 1 operations are similar for the 13 bit (mode) or 16 bit (mode 1)
counter. When the timer reaches the limits of the count, the overflow flag is set and
the counter is reset back to zero. The modes 0 and 1 can be used to time external
events.
They can be used as specific time delays by loading with an initial value before
allowing them to execute and overflow
ii. Auto-reload mode: When the timer overflows, value is written into TH2/TL2
registers from RCA P2H/RCA P21 registers. This feature is used to implement a system
watch dog timer.
PART - B
1.Draw the block diagram of 8255A Programmable Peripheral Interface
(PPI) and explain each block . (May/June-2014)
The Programmable Peripheral Interface (PPI) chip is a peripheral chip.It is made in 40 pin
DIP. The 8255 is used to give the CPU access to programmable parallel I/O.. The 8255 has
24 input/output pins in all.These are divided into three 8-bit ports.
Port A and port B can be used as 8-bit input/output ports.Port C can be used as an 8-bit
input/output port or as two 4-bit input/output ports or to produce handshake signals for ports
A and B.
The address lines A1 and A0 allow to successively access any one of the ports or the control
register.The control signal chip select CS is used to e able the 8255 chip. when CS = '0', the
8255 is enabled.The RESET input is connected to the RESET pin8085.When the system is
reset, all the ports are initialized as input lines.
The control register or the command word register is an 8-bit register used to select the modes of
operation and input/output designation of the ports.
Operational modes of 8255
0 0 Port A
0 1 Port B
1 0 Port C
D7 D6 D5 D4 D3 D2 D1 D0
0 * * * B2 B1 B0 S/R
0 0 0 PC0
0 0 1 PC1
0 1 0 PC2
0 1 1 PC3
1 0 0 PC4
1 0 1 PC5
1 1 0 PC6
1 1 1 PC7
INPUT/OUTPUT MODE
This mode is selected wh n D7 bit of the Control Word Register is 1. There are three
I/O modes
The Intel 8253 and 8254 are Programmable Interval T mers (PITs), which perform
timing and counting functions and has the same pinout.
8253 8254
The timer has three counters.or timers which are named as "Counter 0", "Counter 1" and
"Counter 2".Each counter has 2 input pins – "CLK" (clock input) and "GATE" – and 1-pin,
"OUT", for data output. The 3 counters are 16-bit down counters independent of each other,
and can be easily re d by the CPU. The first counter is used to generate atimekeeping
interrupt.The s cond counter is used to trigger the refresh of DRAM memory. The last
counter is used to generate tones via the PC speaker.
Data/Bus Buffer:
This block contains the logic to buffer the data bus to / from the microprocessor, and to the
internal registers. It has 8 input pins, usually labelled as D7..D0, where D7 is the MSB.
Read/Write Logic:
D7 D6 D5 D4 D3 D2 D1 D0
When the GATE input is high , it will start counting. When the counter reaches 0, the output
will go low for one clock cycle – after that it will become high again, to repeat the cycle.
3.Draw and explain the functional block diagram of 8259 Programmable Interrupt
Controller. (Apr/May-2015)
Functional Description:
The 8259 A has eight interrupt request inputs, IR0- IR7.The 8259 A uses its INT output to
interrupt the 8085A via INTR pin.The 8259Areceives interrupt acknowledge pulses from the
at its input.Vector address used by the 8085 A to transfer control to the service subroutine of
the interrupting device, is provided by the 8259 A on the data bus.
The 8259A is a programmable device that must be in t al zed by command words sent by the.
After initialization the 8259A mode of op ration can be changed by operation command
words.
The descriptions of various blocks are,
Data bus buffer:
This 3- state, bidirectional 8-bit buffer is used to interface the 8259Ato the system data bus.
Control words and status information are transferred through the data bus buffer.
4.Draw the neat diagram ,explain the architecture and features of 8279
keyboard / display controller. (Apr/May-2015)
I/OControlandDataBuffer
The I/O control section controls the flow of data to/from the 8279. The data buffer interface
the external bus of the system with internal bus of 8279. The pin Ao, RD and WR select the
command, status or data read/write operat ons carried out by the CPU with 8279.
Control and Timing Register and Timing Control
These registers store the keyboard and display modes and other operating conditions
programmed by CPU.The registers are written with Ao=1 and WR =0.The timing and control
unit controls the basic timings for the operation of the circuit.Scan Counter divide down the
operating frequency of 8279 to derive scan keyboard and scan display frequencies.
Scan Counter
The Scan Counter has two modes to scan the key matrix and refresh the display.In the
Encoded mode, the counter provides a binary count that is to be externally decoded to
provide the scan lines for keyboard and display.In the decoded scan mode, the counter
internally decodes the least significant 2 bits and provides a decoded 1 out of 4 scan on SL0-
SL3.The Keyboard and Display both are in the same mode at a time.
DisplayModes
There are various options of data display The first one is known as left entry mode or type
writer mode. Since in a type writer the first character typed appears at the left-most position,
while the subsequent characters appears successively to the right of the first one.The other
display format is known as right entry mode, or calculator mode, since the calculator the first
character entered appears at the right-most position and this character is shifted one position
left when the next character is entered.
1.LeftEntryMode
In the Left entry mode, the data is entered from the left side of the display unit. Address0 of the
display RAM contains the leftmost display character and address 15 of the RAM contains the
rightmost display character.
2.RightEntryMode
In the right entry mode, the first entry to be displayed is entered on the rightmost display.The
next entry is also placed in the right most display but after the previous display is shifted left
by one display position.
All the Command words or status words are written or read with Ao = 1 and CS = 0 to or from
8279.
The format of the command word to select different modes of operation of 8279 is given below
with its bit definitions.
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 D D K K K
5.Draw the neat diagram ,explain the architecture and features of 8237Direct
Memory Access
Controller.
DMA Controller: A DMA controller is a device, usually peripheral to a CPU that is
programmed to perform a sequence of data transfers on behalf of the CPU.A DMA
controller can directly access memory and is used to transfer data from one memory
location to another, or from an I/O device to memory and vice versa.A DMA controller
manages several DMA channels, each of which can be programmed to perform a sequence
of these DMA transfers.A DMA request signal for each channel is routed to the DMA
controller.When the DMA controller sees a DMA request, it responds by performing one or
many data transfers from that I/O device into system memory or vice versa.Channels must
be enabled by the processor for the DMA controller to respond to DMA requests.A DMA
controller typically shares the system memory and I/O bus with the CPU and has both bus
master and slave capability. The d agram of DMA controller architecture and how the DMA
controller interacts with the CPU.In bus master mode, the DMA controller acquires the
system bus (address, data, and control lines)from the CPU to perform the DMA transfers.
Because the CPU eleases the system bus for the duration of the transfer, the process is
sometim s r f rred to as cycle stealing.In bus slave mode, the DMA controller is access d by
the CPU, which programs the DMAcontroller's internal registers to set up DMA
transfers.The internal registers consist of source and destination address registers and
transfer count registers for each DMA channel, as well as control and status registers for
initiating, monitoring, and sustaining the operation of the DMAcontroller.
DMA Transfer Types and Modes :
DMA controllers vary as to the type of DMA transfers and the number of DMA channels.
The two types of DMA transfers are
i) flyby DMA transfers
ii) fetch-and-deposit DMAtransfers.
iii) The three common transfer modes are single, block, and demand transfer modes.
READY:
This signal can be used to extend the memory read and write pulses from the
82C37A to accommodate slow memories or I/O devices.
The active high Hold Acknowledge from the CPU indicates that it has relinquished
control of the system busses.
IOR: READ:
I/O Read is a bidirectional active low three-state line. In the Idle cycle, it is an
input control signal used by the CPU to read the control registers. In the active cycle, it is
an output control signal used by the 82C37A to access data from the peripheral during a
DMAWrite transfer.
IOW: WRITE:
I/O Write is a bidirectional active low three-state line.
In the Idle cycle, it is an input control signal used by the CPU to load information into
the 82C37A. In the active cycle, it is an output control signal used by the 82C37A to
load data to the peripheral during a DMA
Read transfer.
A0-A3: ADDRESS: The four l ast significant address lines are bidirectional three-state
signals. In the Idle cycle, they are inputs and are used by the 82C37A to address the
control register to be loaded or read. In the Active cycle, they are outputs and provide
the lower 4-bits of the output
address.
A4-A7: ADDRESS: The four most significant address lines are three-state outputs and
provide 4-bits of address. These lines are enabled only during the DMA service.
HRQ: HOLD REQUEST: The Hold Request (HRQ) output is used to request control
of the system bus. When a DREQ occurs and the corresponding mask bit is clear, or
a software DMA request is made, the 82C37A issues HRQ. The HLDA signal then
informs the controller when access to the system busses is permitted. For stand-alone
operation where the 82C37A always controls the busses, HRQ may be tied to
HLDA. This will result in one S0 state before the transfer.
NC: NO CONNECT: Pin 5 is open and should not be tested for continuity.
Functional Description
The 82C37A direct memory access controller is designed to improve the data
transfer rate in systems which must transfer data from an I/O device to memory, or move a
block of memory to an I/O device. It will also perform memory-to-memory block moves, or
fill a block of memory with data from a single location. Operating modes are provided to
handle single byte transfers as well as discontinuous data streams, which allows the
82C37A to control data movement.Memory-to-memory operations require temporary
internal storage of the data byte between generation of the source and destination addresses,
so memory-to-memory transferstake place at less than half the rate of I/O operations, but
still much faster than with centralprocessor techniques. The block diagram of the 82C37A
consists of timing and control block, priority block, and internal registers are the main
components. The timing and control block derives internal timing from clock input, and
generates ext rnal control signals. The Priority Encoder block resolves priority contention
betw n DMA channels requesting service simultaneously.
DMA Operation:
In a system, the 82C37A address and control outputs and data bus pins are basically
connected in parallel with the system busses. An external latch is required for the upper
address byte. While inactive, the controller‟s outputs are in a high impedance state. When
activated by a DMAr quest and bus control is relinquished by the host, the 82C37A drives
the busses and generates the control signals to perform the data transfer.The operation
performed by activating one of the four DMA request inputs has previously been
programmed into the controller via the Command,Mode, Address, and Word Count
registers.For example, if a block of data is to be transferredfrom RAM to an I/O device, the
starting address of the data is loaded into the 82C37A Current and Base Address registers
for a particular channel, and the length of the block is loaded into the channel‟s Word Count
register. The corresponding Mode register is programmed for a memory to-I/O operation
(read transfer), and various options are selected by the Command register and the other
Mode register bits.The channel‟s mask bit is cleared to enable recognition of a DMArequest
(DREQ). The DREQ can either be a hardware signal or a software command. Once
initiated, the block DMA transfer will proceed as the controller outputs the data
address,simultaneous MEMR and IOW pulses, and selects an I/O device via the DMA
acknowledge(DACK) outputs.The data byte flows directly from the RAM to the I/O device.
After each byte is transferred, the address is automatically incremented (or decremented)
and the word count is decremented.The operation is then repeated for the next byte. The
controller stops transferring data when the Word Count register underflows, or an external
EOP is applied.
UNIT V
MICRO CONTROLLER PROGRAMMING & PPLICATIONS
PART -A
1. What are the applications of 8051 Microcontroll r? (M/J ‘12’)
(i) Washing Machine control,
(ii) Traffic Light control,
(iii)Servo Motor control,
(iv) Stepper motor control,
(v) DC motor control.
Each increments the pc to the 1st byte of the instruction & pushes them in to the stack.
10.Write the coil sequence for a full step rotation of a stepper motor.(May/June
2013)
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 9thdatabit 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.
In this mode,11 bits are transmitted(through TXD)or received(through RXD):a start bit(0),
8 data bits(LSB first),a programmable9th 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.
MOV A,#data
ANL A,#81
MOV DPTR,#4500
MOVX @DPTR,A
LOOP SJMP LOOP
19. Define baud rate. (May/June 2016)
Baud rate is used to indicate the rate at which data is being transferred.
In this mode serial enters and exits through RXD, TXD outputs the shiftclock. 8 bits are
transmitted /received 8 data bits first (LSB first).The baudrate is fixed at 1/12 the oscillator
frequency.
21. Which register is used for serial programming in 8051 microcontroller? Illustrate
it. (Apr/May2015)
Nesting of interrupts means that interrupts are re-enabled inside an interrupt handler. If
another interrupt request codes in, while the first interrupt handler is executing, processor
execution will acknowledge the new interrupt and jump to its vector.
24. How is the 8051 serial port different from other micro controllers?(Nov/Dec2013)
The 8051 serial port is a very complex peripheral and able to send data synchronously and
asynchronously in a variety of different transmission modes.
25. Explain synchronous data transmission.
Txd pin is used for clock output, while Rxd pin is for data transfer.
PART -B
8051 has about 111 instructions. These can be grouped into the following
categories.
The data transfer instruction is used to (copy) transfers data from source
location to destination location.
Syntax:
MOV Rn , Rn
Ex:MOV A,R0
Syntax:
MOV A, direct
Ex:MOV A,40H
Syntax:
MOV A, @Ri
Ex: MOV A, @R0
Syntax:
MOV A, #data
2.Arithmetic Instructions:
Thearithmeticinstructionsincludesaddition,subtraction,multiplication,division,increment,d
ecrement and etc.
Syntax:
ADD Rn , Rn
Ex:ADD A,R0
This instruction adds data from R0 register and Accumulator and finally
result is stored in Acc.
Syntax:
ADD A, direct
Ex:ADD A,40H
This instruction adds data from 40H location and Accumulator and finally
result is stored in Acc.
Syntax:
ADD A, @Ri
ADD A, #data
3.Logical Instructions
Syntax:
ANLRn , Rn
Ex:ANL A,R0
Syntax:
ANL A, direct
Ex:ANL A,40H
This instruction AND with data from 40H location,Accumulator and finally
result is stored in Acc.
Syntax:
ANL A, @Ri
Syntax:
ANL A, #data
ACALL addr11
AJMP addr11
Compare ith A ith memory location content if not equal then jump to relative address.
JC rel
JNC rel
1.Register Addressing:
This way of addressing accesses the bytes in the current register bank.
Data is available in the register spec f ed n the instruction.
The register bank is decided by 2 bits of ProgramStatusWord (PSW).
Example-
ADD A, R0
This instruction Adds content of R0 to A and stores in A
2.Direct Addressing:
The address of the data is available in the instruction.
Example -
MOV A, 88H;
Moves the content of address 88Hto A.
MOV A, @R0
Moves content of address pointed by R0 to A .
4.Immediate Addressing:
Data is immediately available in the instruction.
Example -
ADD A, #77H
Adds 77 H to A and stores in A
Example -
MOVC A, @A+DPTR
Moves content of address pointed by A+DPTR to A
3. Draw the schematic for interfacing a stepper motor with 8051 microcontroller and
write 8051 ALP for changi g speed and direction of motor.
The complete board consists of tr nsformer, control circuit, keypad and stepper motor . The
circuit has inbuilt 5 V pow r supply so when it is connected with transformer it will give the
supply to circuit and motor both.
The 8 Key keypad is connected with circuit through which user can give the command to
control stepper motor. The control circuit includes micro controller 89C51, indicating LEDs,
and current driver chip ULN2003A. By giving different commands the stepper motor can run
clockwise, run anticlockwise, increase/decrease RPM,increase/decrease revolutions, stop
motor, change the mode, etc. Stepper motor has four coils.One end of each coil is tied
together and it gives common terminal which is always connected with positive terminal of
supply. The other ends of each coil are given for interface. Specificcolor code may also be
given.
To vary the RPM of motor we have to vary the PRF (Pulse Repetition Frequency).
Number of applied pulses will vary number of rotations and last to change
direction we have to change pulse sequence. So all these three things just depends
on applied pulses. Now there are three different modes to rotate this motor
1. Single coil excitation
2. Double coil excitation
3. Half step excitation
Pulses for stepper motor module
The circuit consists of very few compo e ts. The major components are 7805, 89C51
and ULN2003A.
Connections:-
1. The transformer terminals a e given to bridge rectifier to generate rectified DC.
2. It is filtered and given to r gulator IC 7805 to generate 5 V pure
DC. LED indicates supply is ON.
3. All the push button micro switches J1 to J8 are connected with port P1 as
shown to form serial keyboard
4. 12 MHz crystal is connected to oscillator terminals of 89C51 with two
biasing capacitors.
5. All the LEDs are connected to port P0 as shown
6. Port P2 drives stepper motor through current driver chip ULN2003A.
7. The common terminal of motor is connected to Vcc and rest all four
terminals are connected to port P2 pins in sequence through ULN chip.
4. Draw the schematic for interfacing a servo motor with 8051 microcontroller and write
for servo motor control. (Nov/Dec 2014)
Servo motors are self-contained mechanical devices that are used to control the
machines with machines. Usually the servo motor is used to control the angular motion among
from 0° to 180° and 0° to 90°. The servo motor working principle based on the PWM (pulse
width modulation) pulses.
A Servo motor is one of the most commonly used motor for precise angular movement.
The advantage of using a servo motor is that the angular position of the motor can be
controlled without any feedback mechanism.
Pulse Width Modulated (PWM) waves are used as co trol signals and the angular position is
definite by the width of the pulse at the control input. Servo motor having angle of rotation
from 0-180° and angular position can be controlled by varying the duty cycles among 1ms to
2ms.The control of s rvo motor connected port0 of 8051 microcontroller. The 11.0592MHz
crystal osc llator is used to provide the clock pulsed to the microcontroller and 22pf ceramic
capacitors used to stabilize the operation of crystal. 10KΩ and 10uf capacitor is used to
provide the power on reset to the microcontroller.
Servo motor working principle mainly depends upon duty cycles. It uses Pulse Width
Modulated (PWM) aves as control signals. The angle of rotation is resolute by the pulse width
of the control pin.
The position sensor senses the location of the shaft from its fixed position and sends the
information to the control circuit. The control circuit decodes the signals accordingly from
the position sensor and compares the actual location of the motors with the preferred position
and accordingly controls the direction of rotation of the DC motor to get the necessary
position. Generally the servo motor requires 4.8V to 6 V DC supply.
5. Draw the schematic for interfacing a washing machine control with 8051
microcontroller and write8051 ALP for washing machine control. (Nov/Dec 2014) A
washing machine is an electronic device that is designed to wash laundry like clothes, sheets,
towels and other bedding. A washing machine is built with two steel tubs which are the inner
tub and the outer tub whose main role is to prevent water from spilling to other parts of the
machine.
Fig:Interfacing of washing machine with 8051 Microcontroller
Machine Operations:-
Fill:- water will be filled by the pump as per the load knob selected.
Agitate:- The wash basket will rotate in a clockwise direction for 10 revolutions, After
that basket will stop for 2 seconds, then rotate 10 revolutions in anticlockwise direction.
The process will be continued for specified minutes in cycle table.Drain:- After agitation,
the water and detergent are drained.
Spin:- During spin, agitator will be stationary, only the basket will rotate at high
speed. Then the moisture of clothes are removed through holes in the inner metallic
basket.
Machine Indicators:-
Machine ON
LED ON After completion of washing cycle, buzzer sound will be generated.
Washing cycle :
Heavy
Normal
Light
Delicate
Medium level
Low level
Drain
Washing machine ON LED
Heavy
Normal
Light
Delicate
Hot
Normal Buzzer sound Basket