MPMC Answers
MPMC Answers
13. b. i. Draw the connections between an ADC and 8086, using 8255 as an interface. Write a
program to generate a triangular waveform using this setup.
Sample and Hold circuit – to keep the analog signal constant during the conversion
The conversion is initiated by PC7 pin of 8255 which makes the converter to initiate busy signal.
When the busy signal goes down after conversion, the strobe signal send through PC4 which
makes the digital data sending to port A.
13. b. ii. Draw the block diagram of the 8251 and discuss how it caters to serial communication.
Write the steps in transmitting one byte of data serially.
8251 is a Universal Synchronous and Asynchronous Receiver and Transmitter
compatible with Intel‘s processors. This chip converts the parallel data into a serial stream of bits
suitable for serial transmission. It is also able to receive a serial stream of bits and convert it into
parallel data bytes to be read by a microprocessor.
Basic Modes of data transmission
a) Simplex
b) Duplex
c) Half Duplex
a) Simplex mode
Data is transmitted only in one direction over a single communication channel. For
example, the processor may transmit data for a CRT display unit in this mode.
b) Duplex Mode
In duplex mode, data may be transferred between two transceivers in both directions
simultaneously.
Program:
ASSUME CS:CODE
CODE SEGMENT
START: MOV AX,2000H
MOV DS,AX ; DS points to byte string segment
MOV SI,5000H ; SI points to byte string
MOV CL, 0AH ; Length of string in CL (hex)
MOV AL,0FEH ; Mode control word to
OUT 0FEH,AL ; D0–D7
MOV AX,11H ; Load command word
OUT 0FE,AL ; to transmit enable and error reset
WAIT: IN AL,0FEH ; Read status
AND AL,01H ; Check transmitter enable
JZ WAIT ; bit, if zero wait for the transmitter to be ready
MOV AL,[SI] ; If ready, first byte of string data
OUT 0FCH, AL ; is transmitted
INC SI ; Point to next byte
DEC CL ; Decrement counter
JNZ WAIT ; If CL is not zero, go for next byte
MOV AH, 4CH : If CL is zero, return to DOS
INT 21H
CODE ENDS
END START
14. a. For 8051 microcontroller, discuss the following.
Each register bank has 8 registers of one byte each. A register bank is selected depending
upon two bank select bits in the PSW register. Next 16bytes are bit addressable. In total, 128bits
(16X8) are available in addressable area.
Each bit can be accessed and modified by suitable instructions. The bit addresses are from
00H (LSB of the first byte in 20H) to 7FH (MSB of the last byte in 2FH). Remaining 80bytes of
RAM are available for general purpose.
14. a. ii. How many register banks are present in RAM and how is bank switching executed?
As seen from Figure 4.5, the bits PSW.3 and PSW.4 are designated as RSO and RSI,
respectively, and are used to change the bank registers. They are explained in the next section.
The PSW.5 and PSW.l bits are general-purpose status flag bits and can be used by the
programmer for any purpose. In other words, they are user definable. See Figure 2-4 for the bits
of the PSW register
Fig 4.5: Processor Status Word
PSW register stores the important status conditions of the microcontroller. It also stores the
bank select bits (RS1 & RS0) for register bank selection.
14. b. i. Write a program in 8051 assembly language to find the biggest of three numbers.
MOV DPTR,#5000H
CLR C
MOV R2,#09H
MOVX A,@DPTR
MOV 30H,A
UP: INC DPTR
MOVX A,@DPTR
CJNE A,30H,DN
SJMP NEXT
DN: JC NEXT
MOV 30H,A
NEXT: DJNZ R2,UP
INC DPTR
MOV A,30H
MOVX @DPTR,A
RET
14. b. ii. Write a program in 8051 assembly language to create a delay of 0.5 seconds, for a clock
frequency of 20 MHz.
The program shown below produces a delay of around 1 second. In this program subroutine for
delaying 1mS (DELAY) is called 2 times back to back and the entire cycle is repeated 250 times.
As result, a delay of 2 x 1mS x 250 = 500 mS = 0.5 second is produced.
15. a. Draw and explain the interfacing connections between an 8051 and a stepper motor by
using driver IC as an interface. Write the steps and assembly program to rotate the stepper motor
in the clockwise direction.
Stepper motor is a brush less motor which converts electrical pulses into mechanical
rotation. As the name indicates it rotates in steps according to the input pulses. A stepper motor
usually have a number of field coils (phases) and a toothed rotor. The step size of the motor is
determined by the number of phases and the number of teeth on the rotor. Step size is the angular
displacement of the rotor in one step. If a stepper motor has 4 phases and 50 teeth, it takes
50×4=200 steps to make one complete rotation. So step angle will be 360/200=1.8°.
The stepper motor we are using has 4 poles and a 1/64 reduction gear mechanism for
increasing torque. The step angle of the motor is 5.64°. But when considering the reduction gear,
the step angle of the output shaft is 5.64/64°. The internal schematic of the stepper motor is given
below.
The circuit diagram for interfacing stepper motor to 8051 is shown above. P1.0, P1.1,
P1.2 and P1.3 pins are used for controlling the phases A1, A2, A3 and A4 of the stepper motor
respectively. ULN2003 is used for driving the individual phases of the stepper motor.
ULN2003 is a darlington transistor array used for driving high current loads such as relays and
motors. ULN2003 has 8 individual channels each with 1A capacity.
The channels can be paralleled to increase the current capacity. Each channels are fitted
with individual freewheeling diodes. The ULN2003 is operated in current sinking mode. Each
channel is activated by giving a logic LOW at the corresponding input. For example if we make
pin 1 of ULN2003 LOW, phase A1 of the stepper motor gets switched ON.
Program:
15. b. i. Write the assembly language program to generate a square wave using any timer, for an
8051 microcontroller.
ORG 0000H
MOV TMOD,#01H
UP:SETB P3.2
LCALL DELAY
CLR P3.2
LCALL DELAY
SJMP UP
DELAY:
MOV TH0,#0FEH
MOV TL0,#0CH
CLR TF0
SETB TR0
HERE:JNB TF0,HERE
RET
END
15. b. ii. For the above generated square wave, if the crystal frequency is 20 MHz and the
frequency of the wave is 10 KHz. Write the assembly language program referring to the bit
configurations given below.
MOV TMOD,#20;Timer 1,mode 2,auto reload
END