Mp Lab Manual

  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Mp Lab Manual as PDF for free.

More details

  • Words: 3,772
  • Pages: 36
1. MULTIPLICATION OF TWO 8-BIT NUMBERS USING 8085 AIM: To write an assembly language program to multiply two 8-bit numbers using 8085 microprocessor. APPARATUS REQUIRED: 8085 microprocessor kit ALGORITHM: Step 1: Load the first data into accumulator Step 2: Move the first data from accumulator to B register Step 3: Load the second data in accumulator Step 4: Move the second data from accumulator to C register Step 5: Clear the accumulator again Step 6: Add B register content with accumulator Step 7: Decrement count value Step 8: Store the result in accumulator Step 9: Stop the program FLOW CHART FOR MULTIPLICATION OF TWO 8-BIT NUMBERS

START

LOAD THE FIRST DATA IN ACCUMULATOR AND SAVE IT IN B REGISTER CLEAR THE ACCUMULATOR

LOAD THE SECOND DATA IN ACCUMULATOR AND SAVE IT IN C REGISTER ADD B REGISTER CONTENT WITH A REGISTER

2

B

A B

A

DECREMENT THE COUNT VALVE C REGISTER

CHECK WHETHE R ZF=1

YES STORE THE RESULT

STOP

ASSEMBLY LANGUAGE PROGRAM:

NO

3

2. DIVISION OF TWO 16-BIT NUMBERS USING 8085 AIM: To write an assembly language program to divide two 16 bit numbers using 8085 microprocessor. APPARATUS REQUIRED: 8085 microprocessor kit ALGORITHM: Step 1: Get the divisor data from memory and store the 2’s complemented value of divisor in another memory location Step 2: Clear BC pair register for storing the quotient value Step 3: Clear the Quotient register (BC) Step 4: Get the 2’s complemented value of divisor number and store it in DE pair Step 5: Get the dividend number from one memory location to HL pair and add this number with DE pair Step 6: Increment the Quotient register (BC) Step 7: Store the remainder value in the dividend data location Step 8: Check whether high byte dividend is equal to high byte of divisor. If yes go to step 7 otherwise go to next step Step 9: Check whether high byte dividend is greater than high byte divisor. If yes go to step 4,otherwise go to next step Step 10: Store the quotient value in memory location Step 11: Stop the process Step 12: Get the lower byte of dividend and divisor to microprocessor and check whether they are equal or not. If they are equal go to step 4, otherwise go to next step Step 13: Check whether lower byte dividend is greater than lower byte divisor or not. If dividend is greater then go to step 4, otherwise go to next step Step 14: Store the quotient value from BC register to memory Step 15: Stop the process

4

FLOW CHART FOR DIVISION OF TWO 16-BIT NUMBERS START

GET THE DIVISOR DATA FROM 4202 MEMORY AND STORE THE 2’S COMPLEMENTED VALUE OF DIVISOR IN MEMORY 4206 CLEAR BC PAIR REGISTER FOR STORING THE QUETIENT VALUE

CLEAR THE QUOTIENT REGISTER (BC)

GET THE 2’S COMPLEMENTED VALUE OF DIVISOR NUMBER AND STORE IT IN DE REGISTER PAIR GET THE DIVIDEND NUMBER FROM 4200 TO HL REGISTER PAIR AND ADD THIS NUMBER WITH DE REGISTER PAIR INCREMENT THE QUOTIENT REGISTER (BC)

STORE THE REMAINDER VALUE IN THE DIVIDEND DATA LOCATION

CHECK WHETHER HIGH BYTE DIVIDEND IS EQUAL TO HIGH BYTE OF DIVISOR

A

YES

5 NO C

B

D

` C

D

C

CHECK WHETHER HIGH BYTE DIVIDEND IS GREATER THAN HIGH BYTE OF DIVISOR

YES

NO STORE THE QUOTIENT VALUE IN 4500 LOCATION

STOP

GET THE LOWER BYTE OF DIVIDEND AND LOWER BYTE OF DIVISOR

YES

CHEC K ZF=1 NO

YES

CHECK LOWER BYTE DIVIDEND > LOWER BYTE DIVISOR

E

B

6

NO

E

STORE THE QUOTIENT VALUE IN THE MEMORY LOCATION 4500

STOP

ASSEMBLY LANGUAGE PROGRAM:

7

3. CONVERSION OF THE GIVEN BINARY INTO EQUIVALENT BCD AIM: To write an assembly language program to convert the given binary number into a BCD number using microprocessor. APPARATUS REQUIRED: 8085 microprocessor kit ALGORITHM: Step 1: Clear D and E register to account for hundreds and tens Step 2: Load the binary data in A register Step 3: Compare A register with 64H.If carry flag is set, go to step 7 otherwise go to next step. Step 4: Subtract 64H from A register Step 5: Increment E register Step 6: Go to Step 3 Step 7: Compare A register with 0AH.If carry flag is set,go to step 11 else go to next step Step 8: Subtract 0AH from A register Step 9: Increment D register Step 10: Goto step 7 Step 11: Combine the units and tens to form 8-bit result Step 12: Save the units, tens and hundreds in memory Step 13: Stop the program FLOW CHART FOR CONVERSION OF THE GIVEN BINARY INTO EQUIVALENT BCD

START

CLEAR D AND E REGISTER

FROM MEMORY LOAD THE BINARY VALUE IN A REGISTER

COMPARE THE CONTENT OF A REGISTER WITH 64H

8

A A

B

CHECK WHETHE R CY=1

SUBTRACT 64H FROM A REGISTER AND INCREMENT E REGISTER

NO

B

YES COMPARE THE CONTENT OF A REGISTER WITH 0AH

CHECK WHETHE R CY=1

NO

SUBTRACT OAH FROM A REGISTER AND INCREMENT D REGISTER

YES SAVE THE CONTENT OF A REGISTER IN C REGISTER

MOVE THE TENS DIGIT TO A REGISTER ROTATE A REGISTER CONTENT FOUR TIMES AND ADD WITH C REGISTER STORE THE TENS AND UNITS FROM A REGISTER TO MEMORY

C

9

C

MOVE THE CONTENT OF E REGISTER TO A REGISTER

STORE HUNDREDS FROM A REGISTER TO MEMORY

STOP

ASSEMBLY LANGUAGE PROGRAM:

10

4. INTERFACING 8085 WITH 8279 (KEY BOARD DISPLAY CONTROLLER) AIM: To write an assembly program using 8085 and interfacing with 8279 (keyboard display controller) in order to display a character. APPARATUS REQUIRED: 1. 8085 microprocessor kit 2. 8279 keyboard / display THEORY: The block diagram of 8279 given in Fig(1) consists of 1. Keyboard section 2. Scan section 3. Display section 4. MPU interface KEYBOARD SECTION: It has 8 lines (RL0-RL7) that can be connected to a column of a keyboard pulses two additional lines shift,CNTL/STB.The keys are automatically debounced and keyboard can operate in two modes,2-key lock out and N-key roll over. In 2-key lockout mode 1 if two keys are placed simultaneously only the first key is recognized and their codes are stored in internal buffer. In N-key roll over, If N-keys are pressed only the keys are recognized until one key is pressed. SCAN SECTION: The scan section has scan counter and 4 scan lines (S L0-SL3).These four lines can be decoded using 4 to 16 decoder to generate 16 linesa for scanning.These lines can be connected to the rows of the matrix display. DISPLAY SECTION: The display section has output lines divided into outputs A0 -A3 and B0 -B3.These lines can be used either as a group of 8 lines or as two groups of four in conjuction with the scan lines for a multiplex display. This display can be blank by using BD lines. MPU INTERFACE SECTION: This section includes birectional data lines DB0-DB7.One interrupt request,time and size,lines are interface including the buffer address line A0.When A0 is high signals are interrupted as control signals and when A 0 is low

11 signals are interrupted as control signals and when A0 is low signals are interrupted as data. ALGORITHM: Step 1: Initialize the control register to set the keyboard and display mode Step 2: Clear display Step 3: Writing a command word format for display RAM Step 4: Writing a corresponding binary word for letter ‘A’ (To enable the segment, corresponding binary digit is 0.To disable the segment, corresponding binary digit is 1) Step 5: Blank the rest of the display

12

BLOCK DIAGRAM OF 8279 (KEYBOARD AND DISPLOAY CONTROLLER)

D0 - D7

RD WR CS A0

IRQ

DATA BUFFER

I/O CONTROLLER

FIFO/SENSORA M STATUS

CLK RESET INTERNAL DATA BUS (8)

DISPLAY ADDRESS REGISTER

16X8 DISPLAY RAM

DISPLAY ADDRESS REGISTER OUT A0 –A3 OUT B0 – B3

CONTROL AND TIMING REGISTER

8X8 FIFO/SENSOR RAM

KEYBOARD DEBOUNCE AND CONTROL

RETURN TIMING AND CONTROL

DISPLAY SCAN ADDRESS CONTROLLER REGISTER SL0 – SL3

BD

(Fig. 1)

RL0 – RL4 SHIFTCNTL / STB

13

DISPLAY MODE SETUP: The command word for keyboard and display mode is,

0

0

0

D

D

K

K

K

DD – DISPLAY MODE: 0 1 10 11

-- 8 8-bit character display – Left Entry – 16 8-bit character display – Left Entry -- 8 8-bit character display – Right Entry -- 16 8-bit character display – Right Entry

KKK – KEYBOARD MODE: 000 001 010 011 100 101 110 111

-

Encoded Scan Keyboard – 2 key Lockout Decoded Scan keyboard – 2 key Lockout Encoded Scan Keyboard – N key roll-over Decoded Scan Keyboard – N key roll-over Encoded Scan Sensor Matrix Decoded Scan Sensor Matrix Strobed input, Encoded Display scan Strobed input, Decoded Display scan

CLEAR DISPLAY: The command word format for clear display is,

1

1

0

CD

CD

CD

CF

CA

CD CD CD – The lower two CD bits specify the blanking code to be sent to the segments to turn them off while the 8279 is switching from one digit to next.

14

CD

CD

CD

0

X

- A0– 3 B0–3

= 00 (0000 0000)

0 1 1

0 0 1

- A0–3 B0– 3 =00(0000 0000) - A0– 3 B0 – 3 =20(0010 0000) - A0–3 B0 –3 =FF (1111 1111)

Enables clear Display when CD=1,the Rows of display RAM are cleared by Code set by lower two CD bits If CD=0 then the contents of RAM will Be displayed. CF -- If CF= 1, FIFO status is cleared, interrupt output line is reset. Sensor RAM pointer is set to row 0. CF -- Clear All bit has the combined effect of CD and CF.It uses CD clearing code on Display Ram and clears FIFO status. It also resynchronizes the internal timing chain. WRITE DISPLAY RAM: The write display RAM command word format is, 1

0

0

AI

A

A

A

A

This command is written with A0 = 1.All subsequent writes with A0 = 0 will be to the Display RAM. AI -- Auto Increment Flag. If AI = 1,the row address selected will be incremented after each following read or write to the Display RAM.

15 AAAA -- Selects one of the 16 rows of the Display RAM. FLOW CHART FOR INTERFACING 8085 WITH 8279(KEYBOARD AND DISPLAY CONTROLLER) START

INITIALIZE THE CONTROL REGISTER TO SET THE KEYBOARD AND DIPLAY MODE

CLEAR DISPLAY

WRITING A COMMAND WORD FORMAT FOR DISPLAY RAM

WRITING A CORRESPONDING BINARY WORD FOR LETTER ‘A’

BLANK THE REST OF THE DISPLAY

STOP

16

ASSEMBLY LANGUAGE PROGRAM:

17

5. INTERFACING 8085 WITH 8253 (TIMER) AIM: To generate a square wave using 8253 programmable interval timer by interfacing it with 8085. APPARATUS REQUIRED: 1. 8085 microprocessor kit 2. CRO 3. 8253 programmable interval timer THEORY: The 8253 programmable interval timer/counter is functionally similar to the software designed timers and counters. It generates accurate time delays and can be used for applications such as real time clock, an event counter, a digital one shot, a square wave generator and a complex waveform generator. To operate a counter, a 16 bit count is loaded in its register and a command begins to decrement the count until it reaches zero. 8253 can operate with a clock frequency from DC to 2 MHz.The block diagram of 8253 includes 3 counters 0,1,2 and a data bus buffer, read/write control logic and a control register. The Block diagram of 8253 is given in Fig(1) at its pin configuration is given in Fig(2). CONTROL UNIT REGISTER: The register is activated when buses A0 and A1 are at logic 1.It is used to write a command word which specifies the channel to be used, its mode and either a read/write operation. SQUARE WAVE GENERATOR: In this mode, when a count is loaded the output is high. The count is decremented by two at every clock cycle and when it reaches zero, the output goes low and the count is reloaded again. This is repeated continuously. Thus a continuous square wave with a period equal to that of the count is generated. ALGORITHM: Step 1: Initialise the 8253 to use binary counter, channel 0 enable reading of LSB first,MSB next and select mode 3 for square wave generation Step 2: Move the accumulator data to control register. Step 3: Read LSB data to accumulator. Step 4: Move the LSB value to channel 0. Step 5: Load the MSB data into accumulator

18 Step 6: Move the MSB value to channel 0. Step 7: Stop the program. BLOCK DIAGRAM OF 8253

D0-D7

RD WR A1 A0 CS

DATA BUS BUFFER

READ/WRITE CONTROL LOGIC

CONTROL WORD REGISTER

I N T E R N A L

CLK 0 GATE 0 OUT 0

COUNTER 1

CLK 1 GATE 1 OUT 1

B U S COUNTER 2

Fig (1)

PIN CONFIGURATION:

COUNTER 0

CLK 2 GATE 2 OUT 2

19

D7

1

24

D6

2

23

3

22

4

21

5

20

D5 D4 D3

VCC WR RD CS A1 A0

D2 D1

6

D0

7

18

OUT 2

8

17

GATE 2

CLK 0

8253

START

19

CLK 2

OUTINITIALISE 0 CLK 1 THE 9 8253 TO SELECT CHANNEL 16 0 TO ENABLE LOAD OF LSB FIRST, MSB NEXT, SELECT OUT 1 GATE 0 MODE 3 FOR 10 SQUARE WAVE GENERATION 15 GND

11

14

GATE 1

12 13 MOVE THE ACCUMULATOR DATA TO CONTROL REGISTER

LOAD LSB DATA TO FigACCUMULATOR (2)

MOVE THE LSB VALUE TO CHANNEL 0

LOAD MSB DATA TO ACCUMULATOR FLOW CHART FOR INTERFACING 8085 WITH 8253 (TIMER)

MOVE THE MSB VALUE TO CHANNEL 0

STOP

20

ASSEMBLY LANGUAGE PROGRAM:

21

6. DETERMINATION OF THE LENGTH OF THE STRING USING 8086 AIM:

22 To write an 8086 assembly language program to determine the length of ASCII string. Use PC keyboard to input the string and display itslength on Personal Computer monitor. APPARATUS REQUIRED: 1. 8086 Microprocessor kit 2. Personal computer ALGORITHM: (i). Main program Step 1: Initialize DS register Step 2: Display the message “ENTER THE STRING.INPUT =”using Macro DISP Step 3: Let CX register be used as counter. Initialize count as zero Step 4: Load the function code 01H in AH register and initiate DOS Interrupt INT 21H to get the ASCII value of key pressed in AL and Echo (display) the key symbol / character in the PC monitor Step 5: Compare the content of AL with ASCII value of ENTER key to Check whether ENTER key is pressed. If ZF = 1,go to step-8, Otherwise go to next step Step 6: Increment the counter (CX register) Step 7: Go to step-4 Step 8: Display the message “THE LENGTH OF STRING =” using the Macro DISP Step 9: Set SI as memory pointer for ASCII value of length Step 10: Copy the count value in AX register Step 11: Call procedure HEX2ASC to get the ASCII value of count in Memory pointed by SI Step 12: Display the length of string using the macro DISP Step 13: Load the function code 4CH in AH register and initiate the DOS Interrupt INT 21H to terminate the program Step 14: Stop (ii). Procedure HEX2ASC Step 1: Load the divisor(OAH) in BX register Step 2: Divide the hex value of length in AX with OAH to get units in DX and tens in AX Step 3: Add the ASCII value of zero to DL register to get ASCII value of units Step 4: Add the ASCII value of zero to AL register to get ASCII value of tens Step 5: Store the ASCII values in memory pointed by SI Step 6: Return FLOW CHART FOR MAIN PROGRAM

23

START

LOAD OFFSET ADDRESS OF DATA SEGMENT IN AX

COPY THE CONTENT OF AX TO DS REGISTER

DISPLAY MESSAGE-1 (MSG 1) USING MACRO-DISP

CLEAR CX REGISTER (INITIALIZE COUNT AS ZERO)

LOAD 01H IN AH REGISTER

CALL DOS SERVICE INT 21H TO GET KEYCODE IN AL AND ECHO IT ON MONITOR

COMPARE CONTENT OF AL WITH ODH

A

B B

A

24

IS ZF = 1?

NO

INCREMENT CX REGISTER

YES DISPLAY MESSAGE-2 USING MACRO DISP

SET SI AS POINTER FOR ASCII VALUE OF LENGTH

COPY THE COUNT VALUE IN AX REGISTER

CALL PROCEDURE HEX2ASC TO GET ASCII VALUE OF LENGTH IN MEMORY

DISPLAY THE LENGTH OF STRING USING MACRO-DISP

LOAD 4CH IN AH AND 00H IN AL

CALL DOS SERVICE INT 21H TO TERMINATE PROGRAM

STOP FLOW CHART FOR PROCEDURE HEX2ASC

25

START

LOAD OAH IN BX REGISTER AND OOH IN DX REGISTER

DIVIDE AX BY BX

ADD ASCII ZERO TO DL

ADD ASCII ZERO TO AL

STORE AL AND DL IN MEMORY POINTED BY SI

STORE ASCII VALUE OF $ AS END OF ASCII STRING

RETURN

ASSEMBLY LANGUAGE PROGRAM:

26

7. ADDITION OF TWO 8-BIT NUMBERS AND SUBTRACTION OF TWO 8-BIT NUMBERS USING 8051-MICROCONTROLLER

27

AIM: To write an assembly language program to add and subtract two 8-bit numbers using 8051 microcontroller. APPARATUS REQUIRED: 1. 8051 microcontroller kit 2. Power supply ALGORITHM: ADDITION Step 1: Clear the carry flag Step 2: Move the first data to accumulator Step 3: Add the second data to accumulator with carry Step 4: Set the pointer for the memory location where the data has to be stored Step 5: Store the result in memory Step 6: Stop the process SUBTRACTION: Step 1: Clear the borrow flag Step 2: Move the first data to accumulator Step 3: Subtract the second data with borrow from accumulator Step 4: Set the pointer for the memory location where the data has to be stored Step 5: Store the result in memory Step 6: Stop the process FLOW CHART FOR ADDITION OF TWO 8-BIT NUMBERS START

CLEAR THE CARRY FLAG

MOVE FIRST DATA TO ACCUMULATOR ADD SECOND DATA WITH CARRY TO ACCUMULATOR AA

28 SET THE POINTER FOR THE MEMORY LOCATION WHERE THE DATA HAS TO BE STORED

STORE THE RESULT IN MEMORY

STOP

FLOW CHART FOR SUBTRACTION OF TWO 8-BIT NUMBERS : START

CLEAR THE CARRY FLAG

MOVE FIRST DATA TO A REGISTER

SUBTRACT SECOND DATA WITH BORROW FROM A REGISTER

SET THE POINTER FOR THE MEMORY LOCATION WHERE THE DATA HAS TO BE STORED

STORE THE RESULT IN MEMORY

ASSEMBLY LANGUAGE PROGRAM: ADDITION

STOP

29

SUBTRACTION

8. FINDING THE LARGEST NUMBER USING 8051-MICROCONTROLLER

30 AIM: To write an assembly language program using 8051 microcontroller to find the largest number from a given 8 bit ten numbers. APPARATUS REQUIRED: 1. Microcontroller kit 2. CRO ALGORITHM: Step 1: Initialize the data pointer to memory where numbers are stored. Step 2: Initialize the counter. Step 3: Initialize the maximum value as 0. Step 4: Get the number from memory to accumulator. Step 5: Compare the number with the maximum value. Step 6: If both the values are not equal than go to step 8. Step 7: Otherwise go to step 10. Step 8: Check for carry flag. If carry comes go to step 10,otherwise go to next step Step 9: Maximum value is the number taken from memory. Step 10: Increment data pointer. Step 11: Decrement the count value. If count is 0 stop the process otherwise go to step 4. FLOW CHART FOR FINDING THE LARGEST NUMBER USING 8051 MICROCONTROLLER START

INITIALIZE THE DATA POINTER TO MEMORY LOCATION

INITIALIZE THE COUNTER

MAXIMUM VALUE=0 A

31 A

GET THE NUMBER TO BE CHECKED FROM MEMORY AND COMPARE IT WITH THE MAXIMUM VALUE

CHEC K ZF=1

YES

NO

YES CHECK CY=1 NO MAX VALUE=NUMBER TAKEN FROM MEMORY INCREMENT DATA POINTER

DECREMENT COUNT

NO

CHEC K ZF=1 YES STOP

ASSEMBLY LANGUAGE PROGRAM:

32

9. INTERFACING OF STEPPER MOTOR WITH 8051-MICROCONTROLLER AIM:

33 To run a stepper motor in both clock and anticlockwise direction by interfacing it with 8051 microcontroller. APPARATUS REQUIRED: 1.Stepper motor 3.8051 microcontroller kit 3. Stepper motor interfacing board THEORY: A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor. The rotary motion occurs in a stepwise manner from one equilibrium position to the next. Stepper motor control is a very popular application of microprocessor in control area. CONSTRUCTIONAL FEATURES: A Stepper motor could be either of the reluctance type or the permanent magnet type. A permanent magnet stepper motor consists of multi-phased stator and two-part permanent magnet rotor. The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles has its own winding. The excitation of any one winding generates a North Pole; a south pole gets induced at the diametrically opposite side. It can be noted that the step size is =360/NS.Nr Where,

NS=Number of stator poles Nr=Number of rotor poles

There are three different schemes available for stepping a stepper motor. They are i). Wave scheme ii). Two phase switching scheme iii). Half stepping or mixed scheme TWO-PHASE SWITHING SCHEME: In this scheme, only any two adjacent station windings are energized. There are two magnetic fields active in quadrature and none of the rotor pole faces can be in direct alignment with the stator poles. A partial but symmetric alignment of the rotor poles is of course possible. The step angle is 300 as in the wave scheme. However,the rotor is offset 0 by 15 in the two phase scheme with respect to move the rotor by 360 0.Two phase drivers produce more torque than the wave drivers. ALGORITHM: Step 1: Set the data pointer for the memory location where the energizing pulses are available. Step 2: Set the count value as step 4.

34 Step 3: Move the energizing pulse from memory to accumulator. Step 4: Save the data pointer value in stack. Step 5: Set the data pointer for the port address where the energizing pulses have to be given Step 6: Establish a delay routine. Step 7: Send the energizing pulse to output stepper motor port. Step 8: Get the address which is saved in stack. Step 9: Increment the data pointer value. Step 10: Decrement the count value if it is not zero than go to step 3. Step 11: Otherwise go to step 1. FLOW CHART FOR INTERFACING OF STEPPER MOTOR WITH 8051MICROCONTROLLER

START

SET THE DATA POINTER FOR THE ENERGIZING PULSES

SET THE COUNT VALUE FOR 4 ENERGIZING PULSES

MOVE THE ENERGZING PULSE FROM MEMORY TO ACCUMULATOR

B B

PUSH THE ENERGIZING PULSE ADDRESS FROM DATA POINTER TO STACK MEMORY A A THE OUTPUT SET THE DATA POINTER FOR STEPPER MOTOR PORT ADD

ESTABLISHIFA DELAY ZF= 1 SEND POP THE THEENERGIZING ENERGIZINGPULSE PULSEADDRESS FROM ACCUMULATOR FROM YES POINTER INCREMENT DECREMENT THE THE DATA COUNT VALUE TO STACK THE OUTPUT MEMORYPORT TO DATA POINTER

C

C

35

NO

ASSEMBLY LANGUAGE PROGRAM:

36

Related Documents

Mp Lab Manual
July 2020 5
Msc Lab Manual-mp
July 2020 6
Lab Manual
May 2020 7
Mp Lab Index Batch-2
June 2020 2