Professional Documents
Culture Documents
Mpes Solved Dec 2017
Mpes Solved Dec 2017
Mpes Solved Dec 2017
Address and Data will appear on AD0-AD7 lines. When AD lined carry address, ALE will go high
and enables the latch. This will make the latch to conduct and the address will appear across A0-A7.
When there is data in AD lines, then ALE=0, the latch is disabled, there is no output across A0-A7,
and data appears in D0-D7 pins.
2 Write a delay subroutine program in 8085 for 0.4 ms. Assume the clock frequency as 3 MHz.
(5)
3 Differentiate between maskable and non-maskable interrupts and list the interrupt related
instructions. (5)
An interrupt that can be disabled by writing some instruction is known as Maskable Interrupt,
otherwise it is called Non-Maskable Interrupt. TRAP is non maskable interrupt with the highest
priority. Hardware interrupts RST7.5, 6.5, 5.5, INTR are maskable. The SIM instruction is used to
mask or unmask RST hardware interrupts. When executed, the SIM instruction reads the content of
accumulator and accordingly mask or unmask the interrupts.
5 Write an ALP using 8051 to generate a square wave of 50% duty cycle. (5)
] i.DB directive is the most widely used data directive in the assembler
It is used to define the 8-bit data
When DB is used to define data, the numbers can be in decimal, binary, hex,
ASCII formats
ii.ORG (origin)
The ORG directive is used to indicate the beginning of the address
The number that comes after ORG can be either in hex and decimal
If the number is not followed by H, it is decimal and the assembler will convert it
to hex
iii.END
This indicates to the assembler the end of the source (asm) file
The END directive is the last line of an 8051 program
Mean that in the code anything after the END directive is ignored by the assembler
iv.EQU (equate)
This is used to define a constant without occupying a memory location
The EQU directive does not set aside storage for a data item but associates a
constant value with a data label
When the label appears in the program, its constant value will be substituted for the
label
8 Explain the function of TMOD and TCON registers of 8051 Microcontroller. (5)
9 Explain the architecture of 8085 microprocessor with the help of a neat functional block
diagram. (10)
It is an 8 bit microprocessor. It is manufactured with N-MOS technology. It has 16 bit address bus and
hence can address upto 216 = 65536 bytes (64KB) memory locations through A 0-A15. The first 8
lines of address bus and 8 lines of databus are multiplexed AD 0 – AD 7. Data bus is a group of 8
lines D 0 – D 7. It supports external interrupt request. A 16 bit program counter (PC). A 16 bit stack
pointer (SP). Six 8-bit general purpose register arranged in pairs: BC, DE, HL. It requires a signal
+5V power supply and operates at 3 MHZ single phase clock.
Memory:
Program, data and stack memories occupy the same memory space. The total addressable memory
size is 64 KB. Program memory - program can be located anywhere in memory. Jump, branch and
call instructions use 16-bit addresses, i.e. they can be used to jump/branch anywhere within 64 KB.
All jump/branch instructions use absolute addressing. 8-bit H and 8-bit L registers can be used as one
16-bit HL register pair. When used as a pair the L register contains low-order byte. HL register
usually contains a data pointer used to reference memory addresses. Stack pointer is a 16 bit register.
This register is always decremented/incremented by 2 during push and pop. Program counter is a 16-
bit register.
Registers
Accumulator or A register is an 8-bit register used for arithmetic, logic, I/O and load/store operations.
Flag Register has five 1-bit flags.
Sign - set if the most significant bit of the result is set.
Zero - set if the result is zero.
Auxiliary carry - set if there was a carry out from bit 3 to bit 4 of the result.
Parity - set if the parity (the number of set bits in the result) is even.
Carry - set if there was a carry during addition, or borrow during
subtraction/comparison/rotation.
General Registers :
8-bit B and 8-bit C registers can be used as one 16-bit BC register pair. When used as a pair the C
register contains low-order byte. Some instructions may use BC register as a data pointer. 8-bit D and
8-bit E registers can be used as one 16-bit DE register pair. When used as a pair the E register
contains low-order byte. Some instructions may use DE register as a data pointer.
Interrupts
10
The processor has 5 interrupts. They are presented below in the order of their priority (from lowest to
highest): INTR is maskable 8080A compatible interrupt. When the interrupt occurs the processor
fetches from the bus one instruction, usually one of these instructions: One of the 8 RST instructions
(RST0 - RST7). The processor saves current program counter into stack and branches to memory
location N * 8 (where N is a 3-bit number from 0 to 7 supplied with the RST instruction). CALL
instruction (3 byte instruction). The processor calls the subroutine, address of which is specified in the
second and third bytes of the instruction. RST5.5 is a maskable interrupt. When this interrupt is
received the processor saves the contents of the PC register into stack and branches to 2CH
(hexadecimal) address. RST6.5 is a maskable interrupt. When this interrupt is received the processor
saves the contents of the PC register into stack and branches to 34H (hexadecimal) address. RST7.5 is
a maskable interrupt. When this interrupt is received the processor saves the contents of the PC
register into stack and branches to 3CH (hexadecimal) address. TRAP is a non-maskable interrupt.
When this interrupt is received the processor saves the contents of the PC register into stack and
branches to 24H (hexadecimal) address.
RESET IN : When this signal goes low, the program counter (PC) is set to Zero, µp is reset and resets
the interrupt enable and HLDA flip-flops. RESET OUT: This signal indicates that µp is being reset.
This signal can be used to reset other devices. The signal is synchronized to the processor clock and
lasts an integral number of clock periods.
Serial Communication
SID - Serial Input Data Line: The data on this line is loaded into accumulator bit 7 when ever a RIM
instruction is executed. SOD – Serial Output Data Line: The SIM instruction loads the value of bit 7
of the accumulator into SOD latch if bit 6 (SOE) of the accumulator is 1.
DMA Signals
HOLD: Indicates that another master is requesting the use of the address and data buses. The CPU,
upon receiving the hold request, will relinquish the use of the bus as soon as the completion of the
current bus transfer. HLDA: Hold Acknowledge : Indicates that the CPU has received the HOLD
request and that it will relinquish the bus in the next clock cycle.
READY : This signal Synchronizes the fast CPU and the slow memory, peripherals. If READY is
high during a read or write cycle, it indicates that the memory or peripheral is ready to send or receive
data.
11
Architecture of MP-8085
LDAX D - Load accumulator indirect - The contents of the designated register pair ‘DE’ point to a
memory location. This instruction copies the contents of that memory location into the accumulator.
The contents of either the register pair or the memory location are not altered. The Machine cycles
included are,
i. Opcode fetch to read and decode the opcode from memory
ii. Memory Read to read the contents of address location in DE register pair and to copy it ti
Accumulator register.
12
Fetch Cycle
For fetching a byte, the microprocessor must find out the memory location where it is stored.
Then provide condition (control) for data flow from memory to the microprocessor. The process
of data flow and timing diagram of fetch operation are shown in Figs. The μP fetches opcode of the
instruction from the memory as per the sequence below.
Read Cycle
The high order address (A15 -A8) and low order address (AD7 -AD0) are asserted on 1st low going
transition of the clock pulse. The timing diagram for IO/M read are shown . The A15 -A8 remains
valid in T1, T2, and T3 i.e. duration of the bus cycle, but AD7 -AD0 remains valid only in T1. Since it
has to remain valid for the whole bus cycle, it must be saved for its use in the T2 and T3. ALE is
asserted at the beginning of T1 of each bus cycle and is negated towards the end of T1. ALE is active
during T1 only and is used as the clock pulse to latch the address (AD7-AD0) during T1. The RD is
asserted near the beginning of T2. It ends at the end of T3. As soon as the RD becomes active, it
forces the memory or I/O port to assert data. RD becomes inactive towards the end of T3, causing the
port or memory to terminate the data.
The process of identifying the operands for a particular instruction can be carried out in several ways.
The various types of addressing modes are as shown below.
i. Immediate Addressing Mode:
In this type of addressing mode the operand is specified within the instruction itself. Consider this
instruction ADI 34H – This instruction adds the immediate data, 34H to the accumulator. 34H is the
13
data here. H represents Hexadecimal value and the immediate value is added to the accumulator. In
this case 34H is added to the accumulator. Suppose if accumulator has a value 8H and when this
instruction is executed, 34H is added to the 8H and the result is stored in accumulator. In the above
instruction the operand is specified within instruction itself.
T-state is one sub-division of an operation performed in one clock cycle. Each clock cycle is called as
T-states. For 3MHz clock, one T state is (1/3MHz), which is 0.33micro seconds.
14
Machine cycle is the time required by the microprocessor to complete the operation of accessing the
memory devices or I/O devices. In machine cycle various operations like opcode fetch,
memory read, memory write, I/O read, I/O write are performed.
15
2K RAM/ROM Chip requires 8 Data lines (D0 to D7) and 11 Address lines(A0 to A10) to interface
with 8085. Three address lines (A11 to A13) is used as three decoder inputs to the 3 to 8 decoder
74LS138. Remaining two address lines are used to enable the decoder using a NAND gate.
Interfacing diagram
16
13 a) Give the current trends and challenges in the field of Embedded Systems. (5)
17
18
19
20
21
22
Linker: In high level languages, some built in header files or libraries are stored. These libraries are
predefined and these contain basic functions which are essential for executing the program. These
functions are linked to the libraries by a program called Linker. If linker does not find a library of a
function then it informs to compiler and then compiler generates an error. The compiler automatically
invokes the linker as the last step in compiling a program.Not built in libraries, it also links the user
defined functions to the user defined libraries. Usually a longer program is divided into smaller
subprograms called modules. And these modules must be combined to execute the program. The
process of combining the modules is done by the linker.
Loader: Loader is a program that loads machine codes of a program into the system
memory. In Computing, a loader is the part of an Operating System that is responsible for loading
programs. It is one of the essential stages in the process of starting a program. Because it places
programs into memory and prepares them for execution. Loading a program involves reading the
contents of executable file into memory. Once loading is complete, the operating system starts the
program by passing control to the loaded program code. All operating systems that support program
loading have loaders. In many operating systems the loader is permanently resident in memory.
23
This three-state bi-directional 8-bit buffer is used to interface the 8255 to the system data bus. Data is
transmitted or received by the buffer upon execution of input or output instructions by the CPU.
Control words and status information are also transferred through the data bus buffer.
24
25
26
27
28
29
30
31
32
SBUF is an 8-bit register used solely for serial communication. For a byte data to be transferred via
the TxD line, it must be placed in the SBUF register. The moment a byte is written into SBUF, it is
framed with the start and stop bits and transferred serially via the TxD line. SBUF holds the byte of
data when it is received by 8051 RxD line. When the bits are received serially via RxD, the 8051 de-
frames it by eliminating the stop and start bits, making a byte out of the data received, and then
placing it in SBUF. SCON is an 8-bit register used to program the start bit, stop bit, and data
bits of data framing, among other things. The basic steps in serial data ttransfer in 8051 are the
following.
1. TMOD register is loaded with the value 20H, indicating the use of timer 1 in mode 2 (8-bit auto-
reload) to set baud rate
2. The TH1 is loaded with one of the values to set baud rate for serial data transfer
3. The SCON register is loaded with the value 50H, indicating serial mode 1, where an 8- bit data is
framed with start and stop bits
4. TR1 is set to 1 to start timer 1
5. TI is cleared by CLR TI instruction
6. The character byte to be transferred serially is written into SBUF register
33
7. The TI flag bit is monitored with the use of instruction JNB TI,xx to see if the character has been
transferred completely
8. To transfer the next byte, go to step 5
17 Show how an LCD can be interfaced with 8051 and also write a program to send
‘Y’, ‘E’, ‘S’ to LCD continuously. (10)
All types of text LCDs have 8 data pins and 3 control signals. here data pins are connected with
P1 and three control pins RS, R/W and EN are connected with P2.0, P2.1 and P2.2 respectively.
It is a 16X2 LCD.
2. Displaying Data:
To continuously load data into the data register of LCD and to display it, the following
signals are required.
RS=1, R/W=0, E=1, Port P1= Data to be displayed on LCD
Make E=0 on completion of data transfer.
As LCD is a slow device, every transfer of Control word or data to it will require
more time. Hence a time delay should follow the data transfer from 8051 to LCD.
34
#include <reg51.h>
void main()
{
1data = value; //control word
RS=0; //Select control register
RW=0; //Select write to LCD
EN=1; //Enable LCD
msdelay(100); //Wait for LCD to read control word
EN=0; //Disable LCD
Return; //Return to main program
}
void lcddata(unsigned char value) // function to write a data to data register to display
{
1data=value; //data to data register for displaying
RS=1; //Select data register
RW=0; //Select write to LCD
EN=1; //Enable LCD
msdelay(100); //Wait for LCD to read data
EN=0; //Disable LCD
35
{
unsigned int i, j; // define i, j
for(i==0, i<dtime, i++) //time delay outer loop
for(i==0, i<FFFh, i++); //time delay inner loop
return;
}
36