0% found this document useful (0 votes)
104 views10 pages

MPMC Answers

The program uses an 8051 microcontroller to generate a square wave using a timer. Timer 0 is configured in mode 1 to generate a delay. Port P3.2 is toggled and the DELAY subroutine is called to generate the high and low periods of the square wave. For a crystal frequency of 20MHz and a desired square wave frequency of 10kHz, timer 0 is reloaded with a value of 0FEH for the high timer and 0CH for the low timer. This generates a 50% duty cycle square wave at 10kHz frequency.

Uploaded by

Muralicheenu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views10 pages

MPMC Answers

The program uses an 8051 microcontroller to generate a square wave using a timer. Timer 0 is configured in mode 1 to generate a delay. Port P3.2 is toggled and the DELAY subroutine is called to generate the high and low periods of the square wave. For a crystal frequency of 20MHz and a desired square wave frequency of 10kHz, timer 0 is reloaded with a value of 0FEH for the high timer and 0CH for the low timer. This generates a 50% duty cycle square wave at 10kHz frequency.

Uploaded by

Muralicheenu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

MPMC

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

Group A – configured as input under mode 1

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.

Port B is acting as output in mode 0 under digital to analog conversion


Triangular Waveform program:

L3 : MOV AL,00H Load 00 in accumulator


L1 : OUT C0,AL Send through output port
INC AL Increment contents of accumulator
JNZ L1 Send through output port until it reaches FF
MOV AL,0FFH Load FF in accumulator
L2 : OUT C0,AL Send through output port
DEC AL Decrement contents of accumulator
JNZ L2 Send through output port until it reaches 00
JMP L3

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.

c) Half Duplex mode


In this mode, data transmission may take place in either direction, but at a time data may
be transmitted only in one direction. A computer may communicate with a terminal in this mode.
It is not possible to transmit data from the computer to the terminal and terminal to computer
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.

i. How is RAM organized and addressed.

The lower 32 bytes are divided into 4 separate banks.

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?

Processor Status Word (PSW) Address=D0H


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. Four of the flags are called conditional
flags, meaning that they indicate some conditions that result after an instruction is executed.
These four are CY (carry), AC (auxiliary carry), P (parity), and OV (overflow).

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.

DELAY1: MOV R5,#250D


LABEL: ACALL DELAY
ACALL DELAY
DJNZ R5,LABEL
RET
DELAY: MOV R6,#250D
MOV R7,#250D
LOOP1: DJNZ R6,LOOP1
LOOP2: DJNZ R7,LOOP1
RET

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

MOV TH1,#3;9600 baud

MOV TCON,#50;8 bit,I stop and REN enabled

SETB TR1;Start timer 1

CLR R1;R1 is cleared for reception

RPT : JNB R1,RPT;Wait for character to come in

MOV A,SBUF;Move received data into A

MOV P0,A;Move it into P0

MOV 60H,A;Move it into RAM location 60H

END

You might also like