Page 1

MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

sv ie

tk

u.

ur

an

tk

8085 MICROPROCESSOR PROGRAMS

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 1


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

ADDITION OF TWO 8 BIT NUMBERS AIM: To perform addition of two 8 bit numbers using 8085. ALGORITHM: Start the program by loading the first data into Accumulator. Move the data to a register (B register). Get the second data and load into Accumulator. Add the two register contents. Check for carry. Store the value of sum and carry in memory location. Terminate the program.

sv

1) 2) 3) 4) 5) 6) 7)

C, 00 Initialize C register to 00 4150 Load the value to Accumulator. B, A Move the content of Accumulator to B register. 4151 Load the value to Accumulator. B Add the value of register B to A LOOP Jump on no carry. C Increment value of register C 4152 Store the value of Accumulator (SUM). A, C Move content of register C to Acc. 4153 Store the value of Accumulator (CARRY) Halt the program.

tk

u.

ur

MVI LDA MOV LDA ADD JNC INR LOOP: STA MOV STA HLT

an

tk

ie

PROGRAM:

OBSERVATION: Input: Output:

80 (4150) 80 (4251) 00 (4152) 01 (4153)

RESULT: Thus the program to add two 8-bit numbers was executed. C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 2


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

SUBTRACTION OF TWO 8 BIT NUMBERS AIM: To perform the subtraction of two 8 bit numbers using 8085.

sv

ALGORITHM:

Start the program by loading the first data into Accumulator. Move the data to a register (B register). Get the second data and load into Accumulator. Subtract the two register contents. Check for carry. If carry is present take 2’s complement of Accumulator. Store the value of borrow in memory location. Store the difference value (present in Accumulator) to a memory location and terminate the program.

PROGRAM:

A C 4152 A, C 4153

Initialize C to 00 Load the value to Acc. Move the content of Acc to B register. Load the value to Acc.

tk

C, 00 4150 B, A 4151 B LOOP

u.

MVI LDA MOV LDA SUB JNC CMA INR INR LOOP: STA MOV STA HLT

ur

an

tk

ie

1. 2. 3. 4. 5. 6. 7. 8. 9.

Jump on no carry. Complement Accumulator contents. Increment value in Accumulator. Increment value in register C Store the value of A-reg to memory address. Move contents of register C to Accumulator. Store the value of Accumulator memory address. Terminate the program.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 3


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL OBSERVATION: Input: 06 (4150) 02 (4251) Output: 04 (4152) 01 (4153)

RESULT:

sv

Thus the program to subtract two 8-bit numbers was executed.

tk

u.

ur

an

tk

ie C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 4


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

MULTIPLICATION OF TWO 8 BIT NUMBERS AIM: To perform the multiplication of two 8 bit numbers using 8085.

sv

ALGORITHM:

Start the program by loading HL register pair with address of memory location. Move the data to a register (B register). Get the second data and load into Accumulator. Add the two register contents. Check for carry. Increment the value of carry. Check whether repeated addition is over and store the value of product and carry in memory location. 8) Terminate the program.

PROGRAM:

Initialize register D to 00 Initialize Accumulator content to 00 Get the first number in B - reg

tk

NEXT:

D, 00 A, 00 H, 4150 B, M H C, M B NEXT D C LOOP 4152 A, D 4153

u.

LOOP:

MVI MVI LXI MOV INX MOV ADD JNC INR DCR JNZ STA MOV STA HLT

ur

an

tk

ie

1) 2) 3) 4) 5) 6) 7)

Get the second number in C- reg. Add content of A - reg to register B. Jump on no carry to NEXT. Increment content of register D Decrement content of register C. Jump on no zero to address Store the result in Memory Store the MSB of result in Memory Terminate the program.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 5


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: Input: Output:

FF (4150) FF (4151) 01 (4152) FE (4153)

sv

RESULT:

tk

u.

ur

an

tk

ie

Thus the program to multiply two 8-bit numbers was executed.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 6


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

DIVISION OF TWO 8 BIT NUMBERS AIM: To perform the division of two 8 bit numbers using 8085.

sv

ALGORITHM:

Start the program by loading HL register pair with address of memory location. Move the data to a register(B register). Get the second data and load into Accumulator. Compare the two numbers to check for carry. Subtract the two numbers. Increment the value of carry . Check whether repeated subtraction is over and store the value of product and carry in memory location. 8) Terminate the program.

PROGRAM:

Get the dividend in B – reg. Clear C – reg for qoutient

tk

LOOP:

H, 4150 B, M C, 00 H A, M B LOOP B C NEXT 4152 A, C 4153

u.

NEXT:

LXI MOV MVI INX MOV CMP JC SUB INR JMP STA MOV STA HLT

ur

an

tk

ie

1) 2) 3) 4) 5) 6) 7)

Get the divisor in A – reg. Compare A - reg with register B. Jump on carry to LOOP Subtract A – reg from B- reg. Increment content of register C. Jump to NEXT Store the remainder in Memory Store the quotient in memory Terminate the program.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 7


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: FF (4150) FF (4251)

Output:

01 (4152) ---- Remainder FE (4153) ---- Quotient

sv

Input:

ie

RESULT:

Thus the program to divide two 8-bit numbers was executed.

tk

u.

ur

an

tk C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 8


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

LARGEST NUMBER IN AN ARRAY OF DATA AIM: To find the largest number in an array of data using 8085 instruction set.

sv

ALGORITHM:

PROGRAM:

LOOP:

AHEAD:

LXI MOV INX MOV DCR INX CMP JNC MOV DCR JNZ STA HLT

H,4200 B,M H A,M B H M AHEAD A,M B LOOP 4300

tk

u.

ur

an

tk

ie

1) Load the address of the first element of the array in HL pair 2) Move the count to B – reg. 3) Increment the pointer 4) Get the first data in A – reg. 5) Decrement the count. 6) Increment the pointer 7) Compare the content of memory addressed by HL pair with that of A - reg. 8) If Carry = 0, go to step 10 or if Carry = 1 go to step 9 9) Move the content of memory addressed by HL to A – reg. 10) Decrement the count 11) Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step. 12) Store the largest data in memory. 13) Terminate the program.

Set pointer for array Load the Count

Set 1st element as largest data Decrement the count If A- reg > M go to AHEAD Set the new value as largest Repeat comparisons till count = 0 Store the largest value at 4300

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 9


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: 05 (4200) ----- Array Size 0A (4201) F1 (4202) 1F (4203) 26 (4204) FE (4205)

Input:

sv

Output:

ie

RESULT:

FE (4300)

Thus the program to find the largest number in an array of data was executed

tk

u.

ur

an

tk C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 10


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

SMALLEST NUMBER IN AN ARRAY OF DATA AIM: To find the smallest number in an array of data using 8085 instruction set.

sv

ALGORITHM:

PROGRAM:

LOOP:

AHEAD:

LXI MOV INX MOV DCR INX CMP JC MOV DCR JNZ STA HLT

H,4200 B,M H A,M B H M AHEAD A,M B LOOP 4300

tk

u.

ur

an

tk

ie

1) Load the address of the first element of the array in HL pair 2) Move the count to B – reg. 3) Increment the pointer 4) Get the first data in A – reg. 5) Decrement the count. 6) Increment the pointer 7) Compare the content of memory addressed by HL pair with that of A - reg. 8) If carry = 1, go to step 10 or if Carry = 0 go to step 9 9) Move the content of memory addressed by HL to A – reg. 10) Decrement the count 11) Check for Zero of the count. If ZF = 0, go to step 6, or if ZF = 1 go to next step. 12) Store the smallest data in memory. 13) Terminate the program.

Set pointer for array Load the Count

Set 1st element as largest data Decrement the count If A- reg < M go to AHEAD Set the new value as smallest Repeat comparisons till count = 0 Store the largest value at 4300

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 11


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: 05 (4200) ----- Array Size 0A (4201) F1 (4202) 1F (4203) 26 (4204) FE (4205)

Input:

sv

Output:

ie

RESULT:

0A (4300)

Thus the program to find the smallest number in an array of data was executed

tk

u.

ur

an

tk C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 12


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

ARRANGE AN ARRAY OF DATA IN ASCENDING ORDER AIM: To write a program to arrange an array of data in ascending order ALGORITHM:

sv

Initialize HL pair as memory pointer Get the count at 4200 into C – register Copy it in D – register (for bubble sort (N-1) times required) Get the first value in A – register Compare it with the value at next location. If they are out of order, exchange the contents of A –register and Memory Decrement D –register content by 1 Repeat steps 5 and 7 till the value in D- register become zero Decrement C –register content by 1 Repeat steps 3 to 9 till the value in C – register becomes zero

PROGRAM:

SKIP:

tk

LOOP:

H,4200 C,M C D,C H,4201 A,M H M SKIP B,M M,A H M,B H D LOOP C REPEAT

u.

REPEAT:

LXI MOV DCR MOV LXI MOV INX CMP JC MOV MOV DCX MOV INX DCR JNZ DCR JNZ HLT

ur

an

tk

ie

1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 13


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: Input:

sv

05 (Array Size) 05 04 03 02 01

4200 4201 4202 4203 4204 4205

05(Array Size) 01 02 03 04 05

RESULT:

an

tk

ie

Output:

4200 4201 4202 4203 4204 4205

Thus the given array of data was arranged in ascending order.

tk

u.

ur C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 14


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

ARRANGE AN ARRAY OF DATA IN DESCENDING ORDER AIM: To write a program to arrange an array of data in descending order ALGORITHM:

sv

Initialize HL pair as memory pointer Get the count at 4200 into C – register Copy it in D – register (for bubble sort (N-1) times required) Get the first value in A – register Compare it with the value at next location. If they are out of order, exchange the contents of A –register and Memory Decrement D –register content by 1 Repeat steps 5 and 7 till the value in D- register become zero Decrement C –register content by 1 Repeat steps 3 to 9 till the value in C – register becomes zero

PROGRAM:

LOOP:

tk

SKIP:

H,4200 C,M C D,C H,4201 A,M H M SKIP B,M M,A H M,B H D LOOP C REPEAT

u.

REPEAT:

LXI MOV DCR MOV LXI MOV INX CMP JNC MOV MOV DCX MOV INX DCR JNZ DCR JNZ HLT

ur

an

tk

ie

1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 15


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: Input:

sv

05 (Array Size) 01 02 03 04 05

4200 4201 4202 4203 4204 4205

05(Array Size) 05 04 03 02 01

RESULT:

an

tk

ie

Output:

4200 4201 4202 4203 4204 4205

tk

u.

ur

Thus the given array of data was arranged in descending order.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 16


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

BCD TO HEX CONVERSION AIM: To convert two BCD numbers in memory to the equivalent HEX number using 8085 instruction set ALGORITHM:

sv

Initialize memory pointer to 4150 H Get the Most Significant Digit (MSD) Multiply the MSD by ten using repeated addition Add the Least Significant Digit (LSD) to the result obtained in previous step Store the HEX data in Memory

PROGRAM:

ur

Initialize memory pointer MSD X 2 Store MSD X 2 MSD X 4 MSD X 8 MSD X 10 Point to LSD Add to form HEX

u.

H,4150 A,M A B,A A A B H M H M,A

an

LXI MOV ADD MOV ADD ADD ADD INX ADD INX MOV HLT

tk

ie

1) 2) 3) 4) 5)

Store the result

tk

OBSERVATION: Input:

4150 : 02 (MSD) 4151 : 09 (LSD)

Output:

4152 : 1D H

RESULT: Thus the program to convert BCD data to HEX data was executed.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 17


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

HEX TO BCD CONVERSION AIM: To convert given Hexa decimal number into its equivalent BCD number using 8085 instruction set ALGORITHM:

sv

Initialize memory pointer to 4150 H Get the Hexa decimal number in C - register Perform repeated addition for C number of times Adjust for BCD in each step Store the BCD data in Memory

PROGRAM:

u.

Store the Least Significant Byte Store the Most Significant Byte

tk

LOOP1 D C LOOP2 4151 A,D 4152

Initialize memory pointer Clear D- reg for Most significant Byte Clear Accumulator Get HEX data Count the number one by one Adjust for BCD count

ur

LOOP1:

H,4150 D,00 A C,M 01

an

LOOP2:

LXI MVI XRA MOV ADI DAA JNC INR DCR JNZ STA MOV STA HLT

tk

ie

1) 2) 3) 4) 5)

OBSERVATION: Input:

4150 : FF

Output:

4151 : 55 (LSB) 4152 : 02 (MSB)

RESULT: Thus the program to convert HEX data to BCD data was executed. C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 18


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

HEX TO ASCII CONVERSION AIM: To convert given Hexa decimal number into its equivalent ASCII number using 8085 instruction set. ALGORITHM: Load the given data in A- register and move to B – register Mask the upper nibble of the Hexa decimal number in A – register Call subroutine to get ASCII of lower nibble Store it in memory Move B –register to A – register and mask the lower nibble Rotate the upper nibble to lower nibble position Call subroutine to get ASCII of upper nibble Store it in memory Terminate the program.

sv

1. 2. 3. 4. 5. 6. 7. 8. 9.

Mask Upper Nibble Get ASCII code for upper nibble Mask Lower Nibble

tk

SKIP:

CPI JC ADI ADI RET

Get Hexa Data

u.

SUB1:

4200 B,A 0F SUB1 4201 A,B F0

ur

LDA MOV ANI CALL STA MOV ANI RLC RLC RLC RLC CALL STA HLT

an

tk

ie

PROGRAM:

SUB1 Get ASCII code for lower nibble 4202 0A SKIP 07 30

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 19


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: Input:

4200

E4(Hexa data)

Output:

4201 4202

34(ASCII Code for 4) 45(ASCII Code for E)

sv

RESULT:

Thus the given Hexa decimal number was converted into its equivalent ASCII Code.

tk

u.

ur

an

tk

ie C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 20


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

ASCII TO HEX CONVERSION AIM: To convert given ASCII Character into its equivalent Hexa Decimal number using 8085 instruction set.

sv

ALGORITHM:

Load the given data in A- register Subtract 30 H from A – register Compare the content of A – register with 0A H If A < 0A H, jump to step6. Else proceed to next step. Subtract 07 H from A – register Store the result Terminate the program

PROGRAM:

SKIP:

4500 30 0A SKIP 07 4501

OBSERVATION: 4500

31

Output:

4501

0B

tk

Input:

u.

ur

LDA SUI CPI JC SUI STA HLT

an

tk

ie

1. 2. 3. 4. 5. 6. 7.

RESULT: Thus the given ASCII character was converted into its equivalent Hexa Value.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 21


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

SQUARE OF A NUMBER USING LOOK UP TABLE AIM: To find the square of the number from 0 to 9 using a Table of Square. ALGORITHM: Initialize HL pair to point Look up table Get the data . Check whether the given input is less than 9. If yes go to next step else halt the program Add the desired address with the accumulator content Store the result

sv

1. 2. 3. 4. 5. 6.

H,4125 4150 0A AFTER A,FF 4151

ur

Add the desired Address

Store the result Terminate the program

tk

u.

C,A B,00 B A,M 4151

LOOKUP TABLE: 4125 4126 4127 4128 4129 4130 4131 4132 4133

Initialsie Look up table address Get the data Check input > 9 if yes error Error Indication

an

AFTER:

LXI LDA CPI JC MVI STA HLT MOV MVI DAD MOV STA HLT

tk

ie

PROGRAM:

01 04 09 16 25 36 49 64 81

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 22


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: Input:

4150: 05

Output:

4151

Input :

4150: 11

sv Output:

4151: FF (Error Indication)

ie

RESULT:

25 (Square)

tk

u.

ur

an

tk

Thus the program to find the square of the number from 0 to 9 using a Look up table was executed.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 23


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

sv tk

ie tk

u.

ur

an

INTERFACING WITH 8085

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 24


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

INTERFACING 8251 (USART) WITH 8085 PROCESSOR AIM: To write a program to initiate 8251 and to check the transmission and reception of character

sv

THEORY:

tk

ie

The 8251 is used as a peripheral device for serial communication and is programmed by the CPU to operate using virtually any serial data transmission technique. The USART accepts data characters from the CPU in parallel format and then converts them into a continuous serial data stream for transmission. Simultaneously, it can receive serial data streams and convert them into parallel data characters for the CPU. The CPU can read the status of USART ant any time. These include data transmission errors and control signals.

ur

an

Prior to starting data transmission or reception, the 8251 must be loaded with a set of control words generated by the CPU. These control signals define the complete functional definition of the 8251 and must immediately follow a RESET operation. Control words should be written into the control register of 8251. These control words are split into two formats: 1. MODE INSTRUCTION WORD 2. COMMAND INSTRUCTION WORD

u.

1. MODE INSTRUCTION WORD

tk

This format defines the Baud rate, Character length, Parity and Stop bits required to work with asynchronous data communication. By selecting the appropriate baud factor sync mode, the 8251 can be operated in Synchronous mode. Initializing 8251 using the mode instruction to the following conditions 8 Bit data No Parity Baud rate Factor (16X) 1 Stop Bit gives a mode command word of 01001110 = 4E (HEX)

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 25


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

MODE INSTRUCTION - SYNCHRONOUS MODE

S2

S1

EP

PEN

L2

L1

B2

B1

sv

5 BITS

an

tk

ie

BAUD RATE FACTOR 0 1 0 0 0 1 SYNC MODE (1X) (16X) CHARACTR LENGTH 0 1 0 0 0 1 6 7 BITS BITS

1 1 (64X)

1 1 8 BITS

PARITY ENABLE 1= ENABLE 0 = DISABLE

NUMBER OF STOP BITS 0 1 0 0 0 1 1.5 1 BIT BIT

u.

ur

EVEN PARITY GEN/CHECK 0 =ODD 1 = EVEN

INVALID

1 1 2 BIT

tk C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 26


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

MODE INSTRUCTION - ASYNCHRONOUS MODE

S2

S1

EP

PEN

L2

L1

B2

B1

sv

CHARACTER LENGTH 0 1 0 1 0 0 1 1 5 BITS 6 BITS 7 BITS 8 BITS

ie

PARITY ENABLE 1= ENABLE 0 = DISABLE

EXTERNAL SYNC DETECTS 1 = SYSDET IS AN INPUT 0 = SYSDET IS AN IOUTPUT SINGLE CHARACTER SYNC 1 = SINGLE SYNC CHARACTER 0 = DOUBLE SYNC CHARACTER

2. COMMAND INSTRUCTION WORD

tk

u.

ur

an

tk

EVEN PARITY GEN/CHECK 0 =ODD 1 = EVEN

This format defines a status word that is used to control the actual operation of 8251. All control words written into 8251 after the mode instruction will load the command instruction. The command instructions can be written into 8251 at any time in the data block during the operation of the 8251. to return to the mode instruction format, the master reset bit in the command instruction word can be set to initiate an internal reset operation which automatically places the 8251 back into the mode instruction format. Command instructions must follow the mode instructions or sync characters. Thus the control word 37 (HEX) enables the transmit enable and receive enable bits, forces DTR output to zero, resets the error flags, and forces RTS output to zero. C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 27


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

EH

IR

RTS

ER

SBRK

RXE

DTR

TXEN

sv

TRANSMIT ENABLE 1=Enable 0 = Disable

ie

DATA TERMINAL READY HIGH will force DTR Output to Zero

tk

RECEIVE ENABLE 1=Enable 0 = Disable

ERROR RESET 1=Reset Error Flags PE,OE,FE REQUEST TO SEND HIGH will force RTS Output to Zero

tk

u.

ur

an

SEND BREAK CHARACTER 1 = Forces TXD LOW 0 = Normal Operation

INTERNAL RESET HIGH Returns 8251 to Mode Instruction Format

ENTER HUNT MODE 1= Enable a Search for Sync Characters( Has No Effect in Async mode)

COMMAND INSTRUCTION FORMAT

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 28


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL ALGORITHM: Initialise timer (8253) IC Move the mode command word (4E H) to A -reg Output it to port address C2 Move the command instruction word (37 H) to A -reg Output it to port address C2 Move the the data to be transferred to A -reg Output it to port address C0 Reset the system Get the data through input port address C0 Store the value in memory Reset the system

sv

1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.

ie

PROGRAM:

A,36H CEH A,0AH C8H A,00 C8H H,4200 A,4E C2 A,37 C2 A,41 C0 1 4200 C0 4500 1

4500

41

tk

ORG IN STA RST

u.

ur

an

tk

MVI OUT MVI OUT MVI OUT LXI MVI OUT MVI OUT MVI OUT RST

OBSERVATION: Output: RESULT: Thus the 8251 was initiated and the transmission and reception of character was done successfully. C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 29


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

INTERFACING ADC WITH 8085 PROCESSOR AIM: To write a program to initiate ADC and to store the digital data in memory PROGRAM:

sv LOOP:

tk

u.

ur

OBSERVATION:

A,10 C8 A,18 C8 A,10 D0 A A A A,00 D0 D8 01 01 LOOP C0 4150

an

tk

ie

MVI OUT MVI OUT MVI OUT XRA XRA XRA MVI OUT IN ANI CPI JNZ IN STA HLT

Compare the data displayed at the LEDs with that stored at location 4150 RESULT: Thus the ADC was initiated and the digital data was stored at desired location

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 30


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

INTERFACING DAC WITH 8085 AIM: To interface DAC with 8085 to demonstrate the generation of square, saw tooth and triangular wave. APPARATUS REQUIRED:

sv • •

tk

ie

THEORY:

8085 Trainer Kit DAC Interface Board

Output Voltage - 5.00 - 4.96 - 4.92 … 0.00 … 4.92 4.96 5.00

tk

u.

Input Data in HEX 00 01 02 … 7F … FD FE FF

ur

an

DAC 0800 is an 8 – bit DAC and the output voltage variation is between – 5V and + 5V.The output voltage varies in steps of 10/256 = 0.04 (appx.). The digital data input and the corresponding output voltages are presented in the Table1.

Referring to Table1, with 00 H as input to DAC, the analog output is – 5V. Similarly, with FF H as input, the output is +5V. Outputting digital data 00 and FF at regular intervals, to DAC, results in different wave forms namely square, triangular, etc,. The port address of DAC is 08 H.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 31


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

ALGORITHM: (a) Square Wave Generation Load the initial value (00) to Accumulator and move it to DAC Call the delay program Load the final value(FF) to accumulator and move it to DAC Call the delay program. Repeat Steps 2 to 5

sv

1. 2. 3. 4. 5.

ie

(b) Saw tooth Wave Generation

tk

Load the initial value (00) to Accumulator Move the accumulator content to DAC Increment the accumulator content by 1. Repeat Steps 3 and 4.

(c) Triangular Wave Generation

Load the initial value (00) to Accumulator Move the accumulator content to DAC Increment the accumulator content by 1. If accumulator content is zero proceed to next step. Else go to step 3. Load value (FF) to Accumulator Move the accumulator content to DAC Decrement the accumulator content by 1. If accumulator content is zero go to step2. Else go to step 7.

tk

u.

2. 3. 4. 5. 6. 7. 8. 9.

ur

an

1. 2. 3. 4.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 32


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

PROGRAM:

(a) Square Wave Generation

START:

sv

A,00 Port address of DAC DELAY A,FF Port address of DAC DELAY START

MVI MVI DCR JNZ DCR JNZ RET

B,05 C,FF C L2 B L1

DELAY: L1: L2:

(b) Saw tooth Wave Generation

MVI OUT INR JNZ JMP

tk

START: L1:

u.

ur

an

tk

ie

MVI OUT CALL MVI OUT CALL JMP

A,00 Port address of DAC A L1 START

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 33


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

(c) Triangular Wave Generation START: L1:

sv L2:

L,00 A,L Port address of DAC L L1 L,FF A,L Port address of DAC L L2 START

RESULT:

an

tk

ie

MVI MOV OUT INR JNZ MVI MOV OUT DCR JNZ JMP

Thus the square, triangular and saw tooth wave form were generated by interfacing DAC with 8085 trainer kit.

tk

u.

ur C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 34


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

INTERFACING 8253 (TIMER IC) WITH 8085 PROCESSOR AIM: To interface 8253 Programmable Interval Timer to 8085 and verify of 8253 in six different modes.

the operation

sv

APPARATUS REQUIRED: 8085 Microprocessor toolkit. 8253 Interface board. VXT parallel bus. Regulated D.C power supply. CRO.

tk

ie

1) 2) 3) 4) 5)

MODE 0-Interrupt On Terminal Count:-

ur

an

The output will be initially low after mode set operation. After loading the counter, the output will remain low while counting and on terminal count, the output will become high until reloaded again. Let us see the channel in mode0. Connect the CLK 0 to the debounce circuit and execute the following program. ;Channel 0 in mode 0. ;LSB of count.

;MSB of count.

tk

MVI A, 30H OUT CEH MVI A, 05H OUT C8H MVI A, 00H OUT C8H HLT

u.

PROGRAM:

It is observed in CRO that the output of channel 0 is initially low. After giving ‘x’ clock pulses, we may notice that the output goes high. MODE 1-Programmable One Shot:After loading the count, the output will remain low following the rising edge of the gate input. The output will go high on the terminal count. It is retriggerable; hence the output will remain low for the full count after any rising edge of the gate input. C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 35


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

The following program initializes channel 0 of 8253 in Mode 1 and also initializes triggering of gate. OUT 0 goes low as clock pulses and after triggering It goes back to high level after five clock pulses. Execute the program and give clock pulses through the debounce logic and verify using CRO. PROGRAM:

sv

;Channel 0 in mode 1. ; ;LSB of count. ;MSB of count. ;Trigger Gate 0.

tk

ie

MVI A, 32H OUT CEH MVI A, 05H OUT C8H MVI A, 00H OUT C8H OUT DOH HLT

MODE 2-Rate Generator:

MODE 3-Square Generator:

ur

an

It is a simple divide by N counter. The output will be low for one period of the input clock. The period from one output pulse to next equals the number of input count in the count register. If the count register is reloaded between output pulses, the present period will not be affected, but the subsequent period will reflect a new value.

tk

u.

It is similar to mode 2 except that the output will remain high until one half of the count and goes low for the other half provided the count is an even number. If the count is odd the output will be high for (count +1)/2 counts. This mode is used for generating baud rate of 8251. PROGRAM: MVI A, 36H OUT CEH MVI A, 0AH OUT C8H MVI A, 00H OUT C8H HLT

;Channel 0 in mode 3. ; ;LSB of count. ;MSB of count.

We utilize mode 3 to generate a square wave of frequency 150 kHz at Channel 0.Set the jumper so that the clock of 8253 is given a square wave of Frequency 1.5 MHz. This program divides the program clock by 10 and thus the Output at channel 0 is 150 KHz. C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 36


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

MODE 4-Software Triggered Strobe: The output is high after the mode is set and also during counting. On Terminal count, the output will go low for one clock period and becomes high again. This mode can be used for interrupt generation.

sv

MODE 5-Hardware Triggered Strobe:

ie

RESULT:

an

tk

Counter starts counting after rising edge of trigger input and the output goes low for one clock period. When the terminal count is reached, the counter is retrigerrable. On terminal count, the output will go low for one clock period and becomes high again. This mode can be used for interrupt generation.

tk

u.

ur

Thus the 8253 PIT was interfaced to 8085 and the operations for mode 0, Mode 1 and mode 3 was verified.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 37


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

INTERFACING 8279 KEYBOARD/DISPLAY CONTROLLER WITH 8085 MICROPROCESSOR AIM:

sv

To interface 8279 Programmable Keyboard Display Controller to 8085 Microprocessor. APPARATUS REQUIRED:

ie PROGRAM:

tk

MVI MVI DCR JNZ DCR JNZ RET

u.

DELAY: LOOP2: LOOP1:

H,4130H D,0FH ;Initialize counter. A,10H C2H ;Set Mode and Display. A,CCH ;Clear display. C2H A,90H ;Write Display C2H A,M C0H DELAY H D LOOP START

ur

LOOP:

LXI MVI MVI OUT MVI OUT MVI OUT MOV OUT CALL INX DCR JNZ JMP

an

START:

8085 Microprocessor toolkit. 8279 Interface board. VXT parallel bus. Regulated D.C power supply.

tk

1) 2) 3) 4)

B, A0H C, FFH C LOOP1 B LOOP2

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 38


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

Pointer equal to 4130 .FF repeated eight times.

sv

4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 413A 413B 413C 413D 413E 413F

ur

an

RESULT:

tk

ie

- FF –FF –FF –FF –FF –FF –FF –FF –98 –68 -7C -C8 -1C -29 -FF -FF

tk

u.

Thus 8279 controller was interfaced with 8085 and program for rolling display was executed successfully.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 39


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

sv tk

ie tk

u.

ur

an

8051 MICROCONTROLLER PROGRAMS

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 40


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

ADDITION OF TWO 8 – BIT NUMBERS

AIM: To perform addition of two 8 – bit numbers using 8051 instruction set.

sv

ALGORITHM:

Clear C – register for Carry Get the data immediately . Add the two data Store the result in memory pointed by DPTR

PROGRAM:

HERE:

66 23

Output:

89 (4500)

tk

Input:

u.

OBSERVATION:

4100 C A,#data1 A,#data2 DPTR,#4500 @DPTR,A HERE

ur

ORG CLR MOV ADD MOV MOVX SJMP

an

tk

ie

1. 2. 3. 4.

RESULT: Thus the program to perform addition of two 8 – bit numbers using 8051 instruction set was executed.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 41


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

SUBTRACTION OF TWO 8 – BIT NUMBERS

AIM: To perform Subtraction of two 8 – bit numbers using 8051 instruction set.

sv

ALGORITHM:

Clear C – register for Carry Get the data immediately . Subtract the two data Store the result in memory pointed by DPTR

PROGRAM:

HERE:

66 23

Output:

43 (4500)

tk

Input:

u.

OBSERVATION:

4100 C A,#data1 A,#data2 DPTR,#4500 @DPTR,A HERE

ur

ORG CLR MOV SUBB MOV MOVX SJMP

an

tk

ie

1. 2. 3. 4.

RESULT: Thus the program to perform subtraction of two 8 – bit numbers using 8051 instruction set was executed.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 42


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

MULTIPLICATION OF TWO 8 – BIT NUMBERS

AIM: To perform multiplication of two 8 – bit numbers using 8051 instruction set.

sv Get the data in A – reg. Get the value to be multiplied in B – reg. Multiply the two data The higher order of the result is in B – reg. The lower order of the result is in A – reg. Store the results.

PROGRAM:

4100 C A,#data1 B,#data2 AB DPTR,#4500 @DPTR,A DPTR A,B @DPTR,A HERE

tk

HERE:

ORG CLR MOV MOV MUL MOV MOVX INC MOV MOVX SJMP

u.

ur

an

tk

1. 2. 3. 4. 5. 6.

ie

ALGORITHM:

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 43


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: Input:

80 80

Output:

00 (4500) 19 (4501)

sv ie

RESULT:

Thus the program to perform multiplication of two 8 – bit numbers using 8051 instruction set was executed.

tk

u.

ur

an

tk C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 44


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

DIVISION OF TWO 8 – BIT NUMBERS

AIM:

sv

To perform division of two 8 – bit numbers using 8051 instruction set.

Get the data in A – reg. Get the value to be divided in B – reg. Divide the two data The quotient is in A – reg. The remainder is in B – reg. Store the results.

PROGRAM:

4100 C A,#data1 B,#data2 AB DPTR,#4500 @DPTR,A DPTR A,B @DPTR,A HERE

tk

HERE:

ORG CLR MOV MOV DIV MOV MOVX INC MOV MOVX SJMP

u.

ur

an

1. 2. 3. 4. 5. 6.

tk

ie

ALGORITHM:

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 45


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: Input:

05 03

Output:

01 (4500) 02 (4501)

sv ie

RESULT:

tk

u.

ur

an

tk

Thus the program to perform multiplication of two 8 – bit numbers using 8051 instruction set was executed.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 46


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

RAM ADDRESSING

AIM: To exhibit the RAM direct addressing and bit addressing schemes of 8051 microcontroller.

sv

ALGORITHM:

For Bit addressing, Select Bank 1 of RAM by setting 3rd bit of PSW Using Register 0 of Bank 1 and accumulator perform addition For direct addressing provide the address directly (30 in this case) Use the address and Accumulator to perform addition Verify the results

Bit Addressing: SETB MOV MOV ADD MOV MOVX SJMP

PSW.3 R0,#data1 A,#data2 A,R0 DPTR,#4500 @DPTR,A HERE

MOV MOV ADD MOV MOVX SJMP

30,#data1 A,#data2 A,30 DPTR,#4500 @DPTR,A HERE

Direct Addressing:

HERE:

tk

u.

HERE:

ur

an

PROGRAM:

tk

ie

1. 2. 3. 4. 5.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 47


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

OBSERVATION: Bit addressing: Input:

54 25

Output:

79 (4500)

sv

Direct addressing:

79 (4500)

ur

an

RESULT:

54 25

tk

Output:

ie

Input:

Thus the program to exhibit the different RAM addressing schemes of 8051 was executed.

tk

u. C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 48


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

INTERFACING STEPPER MOTOR WITH 8051 AIM: To interface stepper motor with 8051 parallel port and to vary speed of motor, direction of motor.

sv

APPARATUS REQUIRED:

ie • •

an

tk

THEORY:

8051 Trainer Kit Stepper Motor Interface Board

A motor in which the rotor is able to assume only discrete stationary angular position is a stepper motor. The rotor motion occurs in a stepwise manner from one equilibrium position to next.

ur

The motor under our consideration uses 2 – phase scheme of operation. In this scheme, any two adjacent stator windings are energized. The switching condition for the above said scheme is shown in Table.

A1 1 0 0 1

Anti - Clockwise B1 A2 0 1 1 0 1 0 0 0

tk

B2 1 0 1 0

u.

A1 1 0 0 1

Clockwise B1 A2 0 0 1 0 1 0 0 1

B2 0 1 0 1

In order to vary the speed of the motor, the values stored in the registers R1, R2, R3 can be changed appropriately.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 49


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

ALGORITHM: Store the look up table address in DPTR Move the count value (04) to one of the register (R0) Load the control word for motor rotation in accumulator Push the address in DPTR into stack Load FFC0 in to DPTR. Call the delay program Send the control word for motor rotation to the external device. Pop up the values in stack and increment it. Decrement the count in R0. If zero go to next step else proceed to step 3. Perform steps 1 to 9 repeatedly.

sv

PROGRAM:

4100 DPTR,#4500H R0,#04 A,@DPTR DPH PDL DPTR,#FFC0H R2, 04H R1,#FFH R3, #FFH R3,DLY R1,DLY1 R2,DLY1 @DPTR,A DPL DPH DPTR R0,AGAIN START

tk

u.

DLY1: DLY:

ORG MOV MOV MOVX PUSH PUSH MOV MOV MOV MOV DJNZ DJNZ DJNZ MOVX POP POP INC DJNZ SJMP

ur

AGAIN:

an

START:

tk

ie

1. 2. 3. 4. 5. 6. 7. 8. 9. 10.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 50


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

DATA: 4500: 09, 05, 06, 0A

RESULT:

sv

Thus the speed and direction of motor were controlled using 8051 trainer kit.

tk

u.

ur

an

tk

ie C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 51


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

INTERFACING DAC WITH 8051 AIM: To interface DAC with 8051 parallel port to demonstrate the generation of square, saw tooth and triangular wave.

sv

APPARATUS REQUIRED:

ie

• •

8051 Trainer Kit DAC Interface Board

an

tk

THEORY:

Output Voltage - 5.00 - 4.96 - 4.92 … 0.00 … 4.92 4.96 5.00

tk

Input Data in HEX 00 01 02 … 7F … FD FE FF

u.

ur

DAC 0800 is an 8 – bit DAC and the output voltage variation is between – 5V and + 5V.The output voltage varies in steps of 10/256 = 0.04 (appx.). The digital data input and the corresponding output voltages are presented in the Table below .

Referring to Table1, with 00 H as input to DAC, the analog output is – 5V. Similarly, with FF H as input, the output is +5V. Outputting digital data 00 and FF at regular intervals, to DAC, results in different wave forms namely square, triangular, etc,.

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 52


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

ALGORITHM:

(a)

Triangular Wave Generation

u.

ur

Move the port address of DAC to DPTR Load the initial value (00) to Accumulator Move the accumulator content to DAC Increment the accumulator content by 1. If accumulator content is zero proceed to next step. Else go to step 3. Load value (FF) to Accumulator Move the accumulator content to DAC Decrement the accumulator content by 1. If accumulator content is zero go to step2. Else go to step 7.

tk

1. 2. 3. 4. 5. 6. 7. 8. 9.

Move the port address of DAC to DPTR Load the initial value (00) to Accumulator Move the accumulator content to DAC Increment the accumulator content by 1. Repeat Steps 3 and 4.

an

(c)

Saw tooth Wave Generation

tk

1. 2. 3. 4. 5.

ie

(b)

Move the port address of DAC to DPTR Load the initial value (00) to Accumulator and move it to DAC Call the delay program Load the final value(FF) to accumulator and move it to DAC Call the delay program. Repeat Steps 2 to 5

sv

1. 2. 3. 4. 5. 6.

Square Wave Generation

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 53


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL PROGRAM: (a) Square Wave Generation

START:

sv

4100 DPTR,PORT ADDRESS OF DAC A,#00 @DPTR,A DELAY A,#FF @DPTR,A DELAY START

MOV MOV DJNZ DJNZ RET SJMP

R1,#05 R2,#FF R2,HERE R1,LOOP

DELAY: LOOP: HERE:

an

tk

ie

ORG MOV MOV MOVX LCALL MOV MOVX LCALL LJUMP

u.

4100 DPTR,PORT ADDRESS OF DAC A,#00 @DPTR,A A LOOP

tk

LOOP:

ORG MOV MOV MOVX INC SJMP

ur

(b) Saw tooth Wave Generation

START

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 54


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

(c) Triangular Wave Generation

START: LOOP1:

sv LOOP2:

4100 DPTR,PORT ADDRESS OF DAC A,#00 @DPTR,A A LOOP1 A,#FF @DPTR,A A LOOP2 START

tk

ie

RESULT:

ORG MOV MOV MOVX INC JNZ MOV MOVX DEC JNZ LJMP

Thus the square, triangular and saw tooth wave form were generated by interfacing DAC with 8051 trainer kit.

tk

u.

ur

an C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 55


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

PROGRAMMING 8051 USING KEIL SOFTWARE

AIM: To perform arithmetic operations in 8051 using keil software.

sv

PROCEDURE:

Click KeilµVision2 icon in the desktop From Project Menu open New project Select the target device as ATMEL 89C51 From File Menu open New File Type the program in Text Editor Save the file with extension “.asm” In project window click the tree showing TARGET A source group will open. Right Click the Source group and click “Add files to Source group” A new window will open. Select our file with extension “.asm” Click Add. Go to project window and right click Source group again Click Build Target (F7). Errors if any will be displayed. From Debug menu, select START/STOP Debug option. In project window the status of all the registers will be displayed. Click Go from Debug Menu. The results stored in registers will be displayed in Project window. Stop the Debug process before closing the application.

tk

u.

ur

an

tk

ie

1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19.

PROGRAM: ORG CLR MOV MOV DIV

4100 C A,#05H B,#02H AB

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 56


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL OBSERVATION: A: 02 B: 01 SP:07 Note that Stack pointer is initiated to 07H

RESULT:

sv

Thus the arithmetic operation for 8051 was done using Keil Software.

tk

u.

ur

an

tk

ie C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 57


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

SYSTEM DESIGN USING MICROCONTROLLER

AIM:

sv

To Design a microcontroller based system for simple applications like security systems combination lock etc.

ie

PROCEDURE:

1. Read number of bytes in the password

tk

2. Initialize the password

3. Initialize the Keyboard Display IC (8279) to get key and Display

an

4. Blank the display

5. Read the key from user

ur

6. Compare with the initialized password

7. If it is not equal, Display ‘E’ to indicate Error. 8. Repeat the steps 6 and 7 to read next key

u.

9. If entered password equal to initialized password, Display ‘O’ to indicate open.

tk

PROGRAM: MOV MOV MOV MOV MOV MOV MOV MOV MOV MOV

51H,# 52H,# 53H,# 54H,# R1,#51 R0,#50 R3,#04 R2,#08 DPTR,#FFC2 A,#00

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 58


MICROPROCESSOR & MICROCONTROLLER LAB MANUAL

LOOP: AGAIN: WAIT:

sv

DPTR,#FFCO A,#68 @DPTR,A YY

tk

YY:

MOV MOV MOVX SJMP

u.

NEQ:

@DPTR,A A,#CC @DPTR,A A,#90 @DPTR,A A,#FF DPTR,#FFCO @DPTR,A R2,LOOP DPTR,#FFC2 A,@DPTR A,#07 WAIT A,#40 @DPTR,A DPTR,#FFCO A,@DPTR @R0,A A,@R1 A,50H,NEQ R1 R3,AGAIN DPTR,#FFCO A,#OC @DPTR,A XX

ur

XX:

an

tk

ie

MOVX MOV MOVX MOV MOVX MOV MOV MOVX DJNZ MOV MOVX ANL JZ MOV MOVX MOV MOVX MOV MOV CJNE INC DJNZ MOV MOV MOVX SJMP

RESULT: Thus the program for security lock system was executed

C.SARAVANAKUMAR. M.E., LECTURER, DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING 59

8085 Micro processor Programmes  

s v i e t k a n u r u . t k 8085 MICROPROCESSOR PROGRAMS 1) Start the program by loading the first data into Accumulator. 2) Move the data t...

8085 Micro processor Programmes  

s v i e t k a n u r u . t k 8085 MICROPROCESSOR PROGRAMS 1) Start the program by loading the first data into Accumulator. 2) Move the data t...

Advertisement