200503 Microprocessor and Interfacing
200503 Microprocessor and Interfacing
Solution
1. a)
MICROPROCESSOR-
Microprocessor is a semiconductor device based on LSI or VLSI technique.
Memory and I/O device are connected externally.
Microprocessor can be used for multitasking.
In microprocessor memory connected externally so it can be used for large program.
It is more flexible.
MICROCOMPUTER-
Microcomputer is a device which consists of CPU, I/O device, and memory
fabricated on single PCB.
Here memory and I/O devices are connected internally on single PCB
Microcomputer can be used for general purpose.
In microcomputer memory is fixed so it can be used for the small program.
Microcomputer is less flexible.
1b)
It is an 8-bit register. It is associated with ALU. The accumulator is also called A-register. During the
arithmetic / logic operations, one of the operand is available in Accumulator. The result of the arithmetic /
logic operations is also stored in the Accumulator.
The Program Counter (PC) is a 16-bit register. It is used to point the address of the next instruction to be
fetched from the memory. When one instruction is fetched from memory, PC is automatically
incremented to point out the next instruction.
Instruction register
When an instruction is fetched from memory, it is stored in the Instruction register. It is an 8-bit register.
This resister cannot be used in the programs.
Serial data is transmitted to the peripherals through SOD(serial output data) pin and received through the
SID(serial input data) pin. The SOD and SID pins are handled by the Serial I/O control unit using the SIM
and RIM instructions.
2 a)
2b)
Instruction cycle :
The fetching, decoding and execution of a single instruction constitutes an instruction cycle, which
consists of one to five read or write operations between processor and memory or input/output devices.
Machine cycle.
:Each memory or I/O operation requires a particular time period, called machine cycle. In other words, to
move byte of data in or out of the microprocessor, a machine cycle is required.
T-states.
Each machine cycle consists of 3 to 6 clock periods/cycles, referred to as T-states.
2c) Memory read cycle
2003 MVI C, 00
2005 MVI D, 0A
2007 INX H
2008 MOV A, M
2009 ANI 01
200E INR C
200F DCR D
2013 MOV A, C
2017 HLT
In immediate addressing mode the source operand is always data. If the data is 8-bit, then
the instruction will be of 2 bytes, if the data is of 16-bit then the instruction will be of 3
bytes.
Example:
MVI B 45 (move the data 45H immediately to register B)
3a) 8251 universal synchronous asynchronous receiver transmitter (USART) acts as a mediator
between microprocessor and peripheral to transmit serial data into parallel form and vice
versa.
1. It takes data serially from peripheral (outside devices) and converts into parallel data.
2. After converting the data into parallel form, it transmits it to the CPU.
3. Similarly, it receives parallel data from microprocessor and converts it into serial form.
4. After converting data into serial form, it transmits it to outside device (peripheral).
3 b) 8155
The essential features of 8155 are
1. 8-bit 256 word RAM memory
2. Two programmable 8-bit I/O port
3. One programmable 6-bit IO port
4. One programmable 14-bit binary Timer/Counter
5. An internal address latch
6. A control/status (C/S) register
7. An internal decoder.
Functionally, it has two sections—(i) R/W memory and (b) programmable I/O and timer
section
8255
1. Basically there are three ports in 8255, viz., Port A, Port B and Port C, each having 8 pins.
2. Again Port C can be divided into Ports C and Port Clower—each having four pins upper
i.e., a nibble.
3. Thus 8255 can be viewed to have four ports—Port A, Port B, Port Cupper and Port C lower.
4. PPI 8255 can operate in three modes. (a) Mode 0 (b) Mode 1 and (c) Mode 2.
5. Apart from the above, there is another mode called BSR mode (Bit Set/Reset mode)
3c) Direct memory access (DMA) is a feature of computer systems that allows certain hardware
subsystems to access main system memory (random-access memory), independent of the central
processing unit or microprocessor.
Without DMA, when the CPU is using programmed input/output, it is typically fully occupied
for the entire duration of the read or write operation, and is thus unavailable to perform other
work. With DMA, the CPU first initiates the transfer, then it does other operations while the
transfer is in progress, and it finally receives an interrupt from the DMA controller (DMAC)
when the operation is done. This feature is useful at any time that the CPU cannot keep up with
the rate of data transfer, or when the CPU needs to perform work while waiting for a relatively
slow I/O data transfer. Many hardware systems use DMA, including disk
drive controllers, graphics cards, network cards and sound cards. DMA is also used for intra-chip
data transfer in multi-core processors. In 8085 HOLD and HLDA pins support DMA operation.
3d) Assumption – 1. Assume the port addresses are 80 H, 81 H, 82 H, 83 H for C0 (Counter 0),
C1(Counter 1), C2(Counter 2), CR(Control Register).
2. Clock frequency of 8254 is 2 MHz
For the above problem, 8254 must work in Mode 3 which is the square wave generator.
Now the data is 16 bit so value of RW1 = 1 and RW0 = 1 in Control Register.
Select C1 (Counter 1) the value of SC1 = 0 and SC0 = 1 in Control Register.
Value of M2 = 0, M1 = 1 and M2 = 1 for Mode 3 in Control Register.
For binary counter value of LSB in CR is 0.
Therefore the control word is 76H
Program –
MEMORY ADDRESS MNEMONICS
2000 MVI A 76
2002 OUT 83
2004 MVI A D0
2006 OUT 81
2008 MVI A 07
200A OUT 81
200C HLT
3e)
Interfacing circuit for memory mapped
4b)
1. Enable Interrupt (EI) – The interrupt enable flip-flop is set and all interrupts are enabled
following the execution of next instruction followed by EI. No flags are affected. After a
system reset, the interrupt enable flip-flop is reset, thus disabling the interrupts. This
instruction is necessary to enable the interrupts again (except TRAP).
2. Disable Interrupt (DI) – This instruction is used to reset the value of enable flip-flop
hence disabling all the interrupts. No flags are affected by this instruction.
START
MOV AX,DATA
MOV DS,AX
MOV SI,ARRAY pointer
MOV AX,0
MOV CX,0A
REPEAT:
MOV BL,ARRAY[SI]
MOV BH,0
ADD AX,BX
INC SI
LOOP REPEAT
MOV SUM, AX
INT 21H
END
Maximum Mode 8086 System •In the maximum mode, the 8086 is operated by strapping the MN/MX
pin to ground.
•In this mode, the processor derives the status signal S2, S1, S0. Another chip called bus controller
derives the control signal using this status information.
•In the maximum mode, there may be more than one microprocessor in the system configuration.
•The components in the system are same as in the minimum mode system.
•The basic function of the bus controller chip IC8288, is to derive control signals like RD and WR ( for
memory and I/O devices), DEN, DT/R, ALE etc. using the information by the processor on the status
lines.
•The bus controller chip has input lines S2, S1, S0 and CLK. These inputs to 8288 are driven by CPU.
•It derives the outputs ALE, DEN, DT/R, MRDC, MWTC, AMWC, IORC, IOWC and AIOWC.
5a)
5 b) PSW (program status word) register.
The program status word (PSW) register is an 8-bit register. It is also referred to as the flag register.
Although the PSW register is 8 bits wide, only 6 bits of it are used by the 8051. The two unused bits are
user-definable flags.
The four of the flags are called conditional flags, meaning that they indicate some conditions that results
after an instruction is executed, these four are CY(carry), AC(auxiliary carry), P(parity) and
OV(overflow) the bits PSW.3 and PSW.4 are designated as RS0 and RS1 register selection bit and are
used to change the bank register.
5c)
The watchdog timer is an important device in the embedded system , which is used to develop
reliable products. Most of the embedded systems need to be self-reliant in order to restart and restore the
system if any software bug disturbs the system. It is not always possible for human operators to wait for
rebooting the system for every software problem. The watchdog timer is a piece of hardware that provides
ultimate solutions for the real-time industries, which used to detect system abnormalities automatically
and to reset the processor.
The watchdog timer is a simple electronic device that is responsible to resetting the microcontroller or
microprocessor for invalid software status. Generally a microcontroller is programmed with software that
contains several loops and number of subroutines that direct variety of activities. If any reason, if the loop
isfail to execute, then it finds and resets the device at starting or top of the loop.
5 d) An embedded system is a combination of computer hardware and software, either fixed in capability
or programmable, designed for a specific function or functions within a larger system.
An Embedded System is one which contains both hardware and software components for a system which
makes it to dedicate for a specific application..Right from the time we wake up in the early morning to the
time we return to bed we live along with embedded systems which makes lives simpler in this earth.
Digital Clocks we use daily either in our wrist or in the wall is a very good example of an embedded
system. It displays us the time along with the alarm, calendar facilities. Other examples like like Washing
machine, Micro wave oven, Traffic light signals, and various luxury operations in the latest cars, etc.
Similarly 8051 Embedded System can be built based on the platform of 8051 family of microcontroller.
The hardware module varies depending upon the application which is connected to the 8051
microcontroller. an example of digital thermostat embedded system is given below:- the processor used is
8051 microcontroller.
You may any example
Counters/Timers
The 8051 has two counters/timers timer0 and timer1. which can be used either as timer to generate a
time delay or as counter to count events happening outside the microcontroller. Both timers are 16 bits
wide. Since the 8051 has an 8-bit architecture, each 16-bit is accessed as two separate registers of low
byte and high byte. First we shall discuss about Timer0 registers.
Timer 0 registers is a 16 bits register and accessed as low byte and high byte. The low byte is referred as
a TL0 and the high byte is referred as TH0. These registers can be accessed like any other registers.
Timer1 registers is also a 16 bits register and is split into two bytes, referred to as TL1 and
TH1.
TMOD (timer mode) Register: This is an 8-bit register which is used by both timers 0 and 1 to
set the various timer modes. In this TMOD register, lower 4 bits are set aside for timer0 and the
upper 4 bits are set aside for timer1. In each case, the lower 2 bits are used to set the timer mode
and upper 2 bits to specify the operation.
TMOD
In upper or lower 4 bits, first bit is a GATE bit. Every timer has a means of starting and
stopping. The second bit is C/T bit and is used to decide whether a timer is used as a time
delay generator or an event counter. If this bit is 0 then it is used as a timer and if it is 1 then it is
used as a counter.
In upper or lower 4 bits, the last bits third and fourth are known as M1 and M0 respectively.
These are used to select the timer mode.
TCON register- Bits and symbol and functions of every bits of TCON are as follows:
BIT Symbol Functions