Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Pc-Ee-692 Lab

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 55

TABLE OF CONTENTS:

SL No: Experiment Name

1. 16-bit Arithmetic Operations for 8086 Microprocessor

2. Sorting an Array using Bubble Sort on 8086 Microprocessor

3. Searching for a Number or Character in a String on 8086 Microprocessor

4. String Manipulations on 8086 Microprocessor

5. Digital Clock Design using 8086 Microprocessor

6. Interfacing ADC and DAC to 8086 Microprocessor

7. Parallel Communication between Two Microprocessors using 8255

8. Serial Communication between Two Microprocessor Kits using 8251

9. Interfacing and Programming to Control Stepper Motor with 8086

10. Programming Using Arithmetic, Logical, and Bit Manipulation Instructions of


8051

11. Program and Verify Timer/Counter in 8051


12. Program and Verify Interrupt Handling in 8051

13. UART Operation in 8051

14. Interfacing LCD to 8051

15. Interfacing Matrix Keyboard to 8051

16. Data Transfer from Peripheral to Memory using DMA Controller 8237/8257
Experiment Title: 16-bit Arithmetic Operations for 8086 Microprocessor

Objectives:

1. To perform 16-bit arithmetic operations (addition, subtraction, multiplication, division)


using various addressing modes on the 8086 microprocessor.
2. To understand and implement arithmetic instructions with immediate, register, direct,
indirect, and indexed addressing modes.
3. To verify the results of arithmetic operations using debuggers or simulators.

Equipment Needed:

 8086 microprocessor trainer kit or simulator software (e.g., DOSBox with TASM)
 Personal computer with assembler and debugger tools (e.g., TASM, DEBUG)
 Reference materials or datasheet for the 8086 microprocessor

Procedure:

Step 1: Setup and Initialization

1. Setup 8086 Trainer Kit or Simulator:


o Power on the 8086 trainer kit or launch the simulator software on the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Load the Assembler and Debugging Tools:
o Open the assembler tool (e.g., TASM) and debugger (e.g., DEBUG) on the
computer.
o Create a new assembly source file (.ASM) for writing the programs.

Step 2: Writing Programs for Arithmetic Operations

1. Addition Program with Various Addressing Modes:

; Program to perform addition using various addressing modes

; Direct addressing mode


MOV AX, [DATA1] ; Load data from memory address DATA1
ADD AX, [DATA2] ; Add data from memory address DATA2
MOV [RESULT], AX ; Store result in memory address RESULT

; Immediate addressing mode


MOV BX, 1000 ; Load immediate data
ADD BX, 2000 ; Add immediate data
MOV [RESULT2], BX ; Store result in memory address RESULT2

; Register addressing mode


MOV CX, 5000 ; Load data into register
ADD CX, 6000 ; Add data to register
MOV [RESULT3], CX ; Store result in memory address RESULT3

; Indirect addressing mode


MOV SI, OFFSET ARRAY1 ; Load offset of array
MOV AX, [SI] ; Load data from array
ADD AX, [SI + 2] ; Add data from next element in array
MOV [RESULT4], AX ; Store result in memory address RESULT4

; Indexed addressing mode


MOV DI, OFFSET ARRAY2 ; Load offset of another array
MOV BX, [DI + SI] ; Load data from indexed location
ADD BX, [DI + SI + 2] ; Add data from next indexed location
MOV [RESULT5], BX ; Store result in memory address RESULT5

DATA1 DW 1234H ; Example data definitions


DATA2 DW 5678H
RESULT DW ?
RESULT2 DW ?
RESULT3 DW ?
RESULT4 DW ?
RESULT5 DW ?
ARRAY1 DW 1000H, 2000H, 3000H ; Example array definitions
ARRAY2 DW 4000H, 5000H, 6000H

2. Subtraction, Multiplication, and Division Programs:


o Modify the above template to perform subtraction, multiplication, and division
using similar addressing modes.

; Subtraction program
SUB AX, BX ; Subtract BX from AX
MOV [RESULT_SUB], AX ; Store result in memory address RESULT_SUB

; Multiplication program
MOV AX, 1234H ; Load multiplicand
MOV BX, 5678H ; Load multiplier
MUL BX ; Multiply AX by BX
MOV [RESULT_MUL], AX ; Store result in memory address RESULT_MUL

; Division program
MOV AX, 5678H ; Load dividend (AX)
MOV BX, 1234H ; Load divisor (BX)
DIV BX ; Divide AX by BX
MOV [RESULT_DIV], AX ; Store quotient in memory address RESULT_DIV
MOV [RESULT_MOD], DX ; Store remainder in memory address RESULT_MOD

RESULT_SUB DW ?
RESULT_MUL DW ?
RESULT_DIV DW ?
RESULT_MOD DW ?

Step 3: Assembling and Debugging

1. Assemble the Programs:


o Use the assembler (e.g., TASM) to assemble the source code into machine code
(hexadecimal).
2. Debugging and Testing:
o Use the debugger (e.g., DEBUG) to load and execute the assembled programs.
o Step through the programs to verify the correct execution of each arithmetic
operation.
o Check the memory locations ([RESULT], [RESULT2], etc.) to confirm the
expected results of each operation.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code, including comments explaining each instruction and
addressing mode used.
o Record the results observed during debugging, noting any deviations or errors
encountered.
2. Conclusion:
o Summarize the experiment's findings regarding the implementation of 16-bit
arithmetic operations with various addressing modes on the 8086 microprocessor.
o Discuss the importance of understanding addressing modes in optimizing code
efficiency and flexibility.

Notes:

 Adjust memory addresses and data values according to your specific setup and
requirements.
 Ensure thorough testing and validation of each arithmetic operation to verify correctness.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in programming
16-bit arithmetic operations on the 8086 microprocessor, utilizing different addressing modes
effectively. This knowledge is essential for understanding microprocessor architecture and
developing skills in assembly language programming for embedded systems.

Experiment Title: Sorting an Array using Bubble Sort on 8086


Microprocessor

Objectives:

1. To implement the bubble sort algorithm for sorting an array on the 8086 microprocessor.
2. To understand the process of sorting and its implementation in assembly language.
3. To verify the correctness of the sorting algorithm through testing and debugging.

Equipment Needed:

 8086 microprocessor trainer kit or simulator software (e.g., DOSBox with TASM)
 Personal computer with assembler and debugger tools (e.g., TASM, DEBUG)
 Reference materials or datasheet for the 8086 microprocessor

Procedure:

Step 1: Setup and Initialization

1. Setup 8086 Trainer Kit or Simulator:


o Power on the 8086 trainer kit or launch the simulator software on the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Load the Assembler and Debugging Tools:
o Open the assembler tool (e.g., TASM) and debugger (e.g., DEBUG) on the
computer.
o Create a new assembly source file (.ASM) for writing the sorting program.

Step 2: Writing the Bubble Sort Program

1. Bubble Sort Algorithm:

; Program to sort an array using Bubble Sort algorithm

; Data segment
DATA_SEG SEGMENT
ARRAY DB 6, 2, 8, 1, 3, 9 ; Example array to be sorted
ARRAY_SIZE equ $ - ARRAY ; Calculate size of array
DATA_SEG ENDS
; Code segment
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG

START:
MOV AX, DATA_SEG
MOV DS, AX

; Outer loop for passes


MOV CX, ARRAY_SIZE - 1 ; Set CX to (n - 1)
MOV SI, 0 ; Initialize index SI to 0
OuterLoop:
MOV DI, SI ; Set DI to current index SI
INC DI ; Increment DI for comparison
InnerLoop:
MOV AL, ARRAY[DI] ; Load ARRAY[DI] into AL
CMP ARRAY[DI - 1], AL ; Compare ARRAY[DI - 1] with AL
JBE NoSwap ; Jump if not greater (no swap needed)

; Swap elements
MOV BL, ARRAY[DI] ; Load ARRAY[DI] into BL
MOV ARRAY[DI], ARRAY[DI - 1] ; Move ARRAY[DI - 1] to ARRAY[DI]
MOV ARRAY[DI - 1], BL ; Move BL to ARRAY[DI - 1]

NoSwap:
DEC DI ; Decrement DI for next comparison
LOOP InnerLoop ; Repeat inner loop until CX = 0

INC SI ; Increment SI for next pass


CMP CX, SI ; Compare SI with CX
JNZ OuterLoop ; Jump to outer loop if not zero

; Display sorted array


MOV AH, 09H ; Print string function
LEA DX, ARRAY ; Load array address into DX
INT 21H ; Call DOS interrupt to print array

; Terminate program
MOV AH, 4CH ; DOS function to terminate program
INT 21H ; Call DOS interrupt

CODE_SEG ENDS
END START

2. Explanation of the Bubble Sort Program:


o Data Segment: Defines an example array (ARRAY) that needs to be sorted and
calculates its size (ARRAY_SIZE).
o Code Segment: Implements the bubble sort algorithm using nested loops. Outer
loop (OuterLoop) controls the number of passes, while the inner loop (InnerLoop)
performs comparisons and swaps adjacent elements if necessary.
o Sorting Process: Compares adjacent elements and swaps them if they are out of
order, continuing until the array is sorted.
o Output: Uses DOS interrupt INT 21H to print the sorted array after sorting is
completed.

Step 3: Assembling and Debugging

1. Assemble the Program:


o Use the assembler (e.g., TASM) to assemble the source code into machine code
(hexadecimal).
2. Debugging and Testing:
o Use the debugger (e.g., DEBUG) to load and execute the assembled program.
o Step through the program to verify the correct execution of the bubble sort
algorithm.
o Verify the sorted array output displayed using DOS interrupts.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each instruction and the
overall flow of the bubble sort algorithm.
o Record the results observed during debugging, noting any deviations or errors
encountered.
2. Conclusion:
o Summarize the experiment's findings regarding the implementation of the bubble
sort algorithm on the 8086 microprocessor.
o Discuss the efficiency of bubble sort and considerations for sorting larger arrays
or optimizing sorting algorithms.

Notes:

 Adjust the ARRAY values and array size (ARRAY_SIZE) according to your specific
requirements and testing scenarios.
 Ensure thorough testing and validation of the sorting algorithm to verify correctness and
efficiency.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in programming
and understanding sorting algorithms on the 8086 microprocessor, using assembly language to
manipulate and sort data efficiently. This knowledge is crucial for understanding algorithmic
complexity and implementing efficient algorithms in low-level programming environments.

Experiment Title: Searching for a Number or Character in a String on 8086


Microprocessor

Objectives:

1. To implement a program that searches for a specific number or character in a string using
the 8086 microprocessor.
2. To understand the concept of string manipulation and searching techniques in assembly
language.
3. To verify the correctness of the search algorithm through testing and debugging.

Equipment Needed:

 8086 microprocessor trainer kit or simulator software (e.g., DOSBox with TASM)
 Personal computer with assembler and debugger tools (e.g., TASM, DEBUG)
 Reference materials or datasheet for the 8086 microprocessor

Procedure:

Step 1: Setup and Initialization

1. Setup 8086 Trainer Kit or Simulator:


o Power on the 8086 trainer kit or launch the simulator software on the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Load the Assembler and Debugging Tools:
o Open the assembler tool (e.g., TASM) and debugger (e.g., DEBUG) on the
computer.
o Create a new assembly source file (.ASM) for writing the search program.

Step 2: Writing the Search Program

1. Program to Search for a Character in a String:

; Program to search for a character in a string

; Data segment
DATA_SEG SEGMENT
STRING DB 'Hello, World!', '$' ; Example string to search (null-terminated)
SEARCH_CHAR DB 'o' ; Character to search for
FOUND DB 0 ; Flag to indicate if character is found (0 = not found, 1 =
found)
DATA_SEG ENDS

; Code segment
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG

START:
MOV AX, DATA_SEG
MOV DS, AX

MOV CX, 0 ; Initialize CX for loop counter


MOV SI, 0 ; Initialize SI for string index

SearchLoop:
MOV AL, STRING[SI] ; Load character from string into AL
CMP AL, '$' ; Check for end of string
JE EndSearch ; Exit loop if end of string ('$' found)

CMP AL, SEARCH_CHAR ; Compare character with SEARCH_CHAR


JNE NotFound ; Jump if not equal

; Character found
MOV FOUND, 1 ; Set FOUND flag to indicate character found
JMP EndSearch ; Exit loop

NotFound:
INC SI ; Increment SI to next character in string
LOOP SearchLoop ; Repeat loop until CX = 0

EndSearch:
; Check if character was found
CMP FOUND, 1
JE CharacterFound ; Jump if character was found
MOV AH, 09H ; Print string function
LEA DX, notFoundMsg ; Load address of message into DX
INT 21H ; Call DOS interrupt to print message
JMP EndProgram ; Jump to end program

CharacterFound:
MOV AH, 09H ; Print string function
LEA DX, foundMsg ; Load address of message into DX
INT 21H ; Call DOS interrupt to print message

EndProgram:
; Terminate program
MOV AH, 4CH ; DOS function to terminate program
INT 21H ; Call DOS interrupt

foundMsg DB 'Character found in string.', '$'


notFoundMsg DB 'Character not found in string.', '$'

CODE_SEG ENDS
END START

2. Explanation of the Search Program:


o Data Segment: Defines an example string (STRING) and the character to search
for (SEARCH_CHAR). Also defines a flag (FOUND) to indicate if the character
is found.
o Code Segment: Implements a search algorithm using a loop (SearchLoop) to
compare each character in the string with SEARCH_CHAR.
o Searching Process: Compares each character in the string until either the
character is found (CharacterFound) or the end of the string (EndSearch) is
reached.
o Output: Uses DOS interrupt INT 21H to print messages indicating whether the
character was found or not.

Step 3: Assembling and Debugging

1. Assemble the Program:


o Use the assembler (e.g., TASM) to assemble the source code into machine code
(hexadecimal).
2. Debugging and Testing:
o Use the debugger (e.g., DEBUG) to load and execute the assembled program.
o Step through the program to verify the correct execution of the search algorithm.
o Verify the output messages displayed using DOS interrupts.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each instruction and the
overall flow of the search algorithm.
o Record the results observed during debugging, noting any deviations or errors
encountered.
2. Conclusion:
o Summarize the experiment's findings regarding the implementation of the search
algorithm for finding a character in a string on the 8086 microprocessor.
o Discuss the efficiency of the algorithm and considerations for searching larger
strings or optimizing search algorithms.

Notes:
 Adjust the STRING and SEARCH_CHAR values according to your specific
requirements and testing scenarios.
 Ensure thorough testing and validation of the search algorithm to verify correctness and
efficiency.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in programming
and understanding string manipulation and searching algorithms on the 8086 microprocessor.
This knowledge is essential for understanding assembly language programming and its
applications in embedded systems and low-level programming environments.

Experiment Title: String Manipulations on 8086 Microprocessor

Objectives:

1. To implement programs for string length calculation, string comparison, string


concatenation, and string reversal on the 8086 microprocessor.
2. To understand the concept of string manipulations in assembly language.
3. To verify the correctness of each string manipulation operation through testing and
debugging.

Equipment Needed:

 8086 microprocessor trainer kit or simulator software (e.g., DOSBox with TASM)
 Personal computer with assembler and debugger tools (e.g., TASM, DEBUG)
 Reference materials or datasheet for the 8086 microprocessor

Procedure:

Step 1: Setup and Initialization

1. Setup 8086 Trainer Kit or Simulator:


o Power on the 8086 trainer kit or launch the simulator software on the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Load the Assembler and Debugging Tools:
o Open the assembler tool (e.g., TASM) and debugger (e.g., DEBUG) on the
computer.
o Create a new assembly source file (.ASM) for writing the string manipulation
programs.

Step 2: Writing the String Manipulation Programs

1. Program 1: String Length Calculation


; Program to calculate the length of a string

; Data segment
DATA_SEG SEGMENT
STRING DB 'Hello, World!', '$' ; Example string (null-terminated)
STR_LEN DW ? ; Variable to store string length
DATA_SEG ENDS

; Code segment
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG

START:
MOV AX, DATA_SEG
MOV DS, AX

; Calculate string length


MOV CX, 0 ; Initialize CX as counter
LoopStart:
MOV AL, STRING[CX] ; Load character from string
CMP AL, '$' ; Check for end of string
JE EndLoop ; Exit loop if end of string ('$' found)
INC CX ; Increment CX for next character
JMP LoopStart ; Repeat loop

EndLoop:
DEC CX ; Adjust CX to exclude '$' from count
MOV STR_LEN, CX ; Store string length in STR_LEN

; Display string length


MOV AH, 02H ; Set AH to print character function
MOV DL, ' ' ; Set DL to empty space
INT 21H ; DOS interrupt to print space
MOV AH, 02H ; Set AH to print character function
MOV DL, 'L' ; Set DL to print 'L'
INT 21H ; DOS interrupt to print L
MOV AH, he Displays
Experiment Title: Digital Clock Design using 8086 Microprocessor

Objectives:

1. To design a digital clock using the 8086 microprocessor.


2. To interface with a real-time clock (RTC) IC for timekeeping.
3. To display the current time on a digital display.
4. To understand the concept of timekeeping and interfacing with external devices in
assembly language.

Equipment Needed:

 8086 microprocessor trainer kit or simulator software (e.g., DOSBox with TASM)
 RTC IC (e.g., DS1307) and necessary interfacing components (crystal, capacitors, pull-
up resistors)
 Digital display unit (7-segment LED display)
 Personal computer with assembler and debugger tools (e.g., TASM, DEBUG)
 Reference materials or datasheets for the 8086 microprocessor and RTC IC

Procedure:

Step 1: Setup and Initialization

1. Setup 8086 Trainer Kit or Simulator:


o Power on the 8086 trainer kit or launch the simulator software on the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Interfacing with RTC IC:
o Connect the RTC IC (e.g., DS1307) to the 8086 microprocessor trainer kit or
simulator.
o Follow the datasheet guidelines to connect the necessary pins (SCL, SDA) for I2C
communication.
3. Digital Display Setup:
o Connect the digital display unit (7-segment LED display) to the 8086
microprocessor trainer kit or simulator.
o Ensure proper interfacing and wiring for displaying digits.

Step 2: Writing the Digital Clock Program

1. Program Structure:

; Program for Digital Clock Design using 8086

; Data segment
DATA_SEG SEGMENT
RTC_ADDRESS equ 070H ; RTC address (example for DS1307)
RTC_DATA equ 071H ; RTC data

HOUR DB ?
MINUTE DB ?
SECOND DB ?

DISPLAY DB 6 DUP(' ') ; Array to store 6 digits for HH:MM:SS format


SEPARATOR DB ':', '$' ; Separator for HH:MM:SS format
DATA_SEG ENDS

; Code segment
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG

START:
MOV AX, DATA_SEG
MOV DS, AX

; Initialize RTC (optional if RTC initialization is required)


CALL INIT_RTC

DisplayLoop:
; Read current time from RTC
CALL READ_RTC

; Convert BCD to decimal for display


MOV AH, 0 ; Clear AH register
MOV AL, HOUR ; Load HOUR
CALL BCD_TO_DEC ; Convert BCD to decimal
MOV DISPLAY[0], AL ; Store first digit of hour

MOV AL, HOUR + 1 ; Load next byte of HOUR (BCD format)


CALL BCD_TO_DEC ; Convert BCD to decimal
MOV DISPLAY[1], AL ; Store second digit of hour

MOV DISPLAY[2], SEPARATOR ; Store separator ':'

MOV AL, MINUTE ; Load MINUTE


CALL BCD_TO_DEC ; Convert BCD to decimal
MOV DISPLAY[3], AL ; Store first digit of minute

MOV AL, MINUTE + 1 ; Load next byte of MINUTE (BCD format)


CALL BCD_TO_DEC ; Convert BCD to decimal
MOV DISPLAY[4], AL ; Store second digit of minute

MOV DISPLAY[5], SEPARATOR ; Store separator ':'


MOV AL, SECOND ; Load SECOND
CALL BCD_TO_DEC ; Convert BCD to decimal
MOV DISPLAY[6], AL ; Store first digit of second

MOV AL, SECOND + 1 ; Load next byte of SECOND (BCD format)


CALL BCD_TO_DEC ; Convert BCD to decimal
MOV DISPLAY[7], AL ; Store second digit of second

; Display time on digital display


MOV AH, 09H ; Print string function
LEA DX, DISPLAY ; Load address of DISPLAY array
INT 21H ; Call DOS interrupt to print the time

; Delay for one second (optional for real-time clock display)


CALL DELAY_1S

JMP DisplayLoop ; Repeat display loop

; Subroutine to initialize RTC (example for DS1307)


INIT_RTC PROC
; Initialize RTC (write to RTC control registers if necessary)
; Example:
MOV AL, 00H ; Control register address
MOV AH, RTC_ADDRESS
OUT RTC_ADDRESS, AL

; Write initialization data (if required)


; Example:
MOV AL, 00H ; Initialization value
MOV AH, RTC_DATA
OUT RTC_DATA, AL

RET
INIT_RTC ENDP

; Subroutine to read current time from RTC (example for DS1307)


READ_RTC PROC
; Read hours from RTC
MOV AL, 02H ; Hours register address
MOV AH, RTC_ADDRESS
OUT RTC_ADDRESS, AL
IN AL, RTC_DATA
MOV HOUR, AL

; Read minutes from RTC


MOV AL, 01H ; Minutes register address
MOV AH, RTC_ADDRESS
OUT RTC_ADDRESS, AL
IN AL, RTC_DATA
MOV MINUTE, AL

; Read seconds from RTC


MOV AL, 00H ; Seconds register address
MOV AH, RTC_ADDRESS
OUT RTC_ADDRESS, AL
IN AL, RTC_DATA
MOV SECOND, AL

RET
READ_RTC ENDP

; Subroutine to convert BCD to decimal


BCD_TO_DEC PROC
MOV AH, AL ; Move AL to AH
AND AL, 0FH ; Clear upper nibble
CMP AH, 0AH ; Compare AH to 0AH
JB SkipAdd ; If lower, skip addition
ADD AL, 06 ; Add 06 to AL
SkipAdd:
ADD AL, 030H ; Add 30H to AL
RET
BCD_TO_DEC ENDP

; Subroutine for delay of one second (optional)


DELAY_1S PROC
; Implement delay loop for one second (timing may vary)
; Example:
MOV CX, 1000 ; Initialize loop counter
DelayLoop:
NOP ; NOP instruction for delay
LOOP DelayLoop ; Loop until CX = 0
RET
DELAY_1S ENDP

CODE_SEG ENDS
END START

2. Explanation of the Digital Clock Program:


o Data Segment: Defines variables for storing hours, minutes, and seconds
(HOUR, MINUTE, SECOND), display format (DISPLAY), RTC address
(RTC_ADDRESS), and data (RTC_DATA).
o Code Segment: Implements the main program loop (DisplayLoop) to
continuously read time from the RTC, convert BCD to decimal, format the time
for display, and output it to the digital display.
o Subroutines: Includes subroutines (INIT_RTC, READ_RTC, BCD_TO_DEC,
DELAY_1S) for initializing RTC, reading RTC time, converting BCD to decimal,
and implementing a delay for one second.
o Display: Uses DOS interrupt INT 21H to print the formatted time on the digital
display.

Step 3: Assembling and Debugging

1. Assemble the Program:


o Use the assembler (e.g., TASM) to assemble the source code into machine code
(hexadecimal).
2. Debugging and Testing:
o Use the debugger (e.g., DEBUG) to load and execute the assembled program.
o Step through the program to verify the correct operation of time reading,
conversion, and display.
o Ensure the digital clock updates correctly and displays accurate time.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each instruction and
subroutine used.
o Record the results observed during debugging, noting any deviations or errors
encountered.
2. Conclusion:
o Summarize the experiment's findings regarding the implementation of the digital
clock using the 8086 microprocessor.
o Discuss the challenges faced, optimizations made, and the overall functionality
and accuracy of the digital clock design.

Notes:

 Adjust the RTC interface code (INIT_RTC and READ_RTC procedures) according to
the RTC IC used (e.g., DS1307).
 Ensure proper connection and interfacing of the RTC IC and digital display unit with the
8086 microprocessor.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in programming
and interfacing with external devices (RTC and digital display) using the 8086 microprocessor.
This knowledge is crucial for understanding real-time applications and embedded systems
programming in assembly language.
Experiment Title: Interfacing ADC and DAC to 8086 Microprocessor

Objectives:

1. To interface an ADC (Analog-to-Digital Converter) with the 8086 microprocessor for


analog signal conversion to digital values.
2. To interface a DAC (Digital-to-Analog Converter) with the 8086 microprocessor for
digital value conversion to analog signals.
3. To demonstrate data transfer between the ADC and DAC via the 8086 microprocessor.
4. To understand the process of analog-to-digital and digital-to-analog conversion in
embedded systems.

Equipment Needed:

 8086 microprocessor trainer kit or simulator software (e.g., DOSBox with TASM)
 ADC IC (e.g., ADC0804) and necessary interfacing components (capacitors, resistors)
 DAC IC (e.g., DAC0800) and necessary interfacing components (op-amps, resistors)
 Oscilloscope (optional for signal observation)
 Personal computer with assembler and debugger tools (e.g., TASM, DEBUG)
 Reference materials or datasheets for the ADC, DAC, and 8086 microprocessor

Procedure:

Step 1: Setup and Initialization

1. Setup 8086 Trainer Kit or Simulator:


o Power on the 8086 trainer kit or launch the simulator software on the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Interfacing ADC (Analog-to-Digital Converter):
o Connect the ADC IC (e.g., ADC0804) to the 8086 microprocessor trainer kit or
simulator.
o Follow the datasheet guidelines to connect analog input signals, clock, and control
lines (e.g., Start conversion, End conversion).
3. Interfacing DAC (Digital-to-Analog Converter):
o Connect the DAC IC (e.g., DAC0800) to the 8086 microprocessor trainer kit or
simulator.
o Ensure proper connections for digital inputs (from 8086) and analog output (to
observe output signal).

Step 2: Writing the ADC and DAC Interface Program

1. Program Structure:

; Program for Interfacing ADC and DAC to 8086


; Data segment
DATA_SEG SEGMENT
ADC_ADDRESS equ 0200H ; ADC data port address
DAC_ADDRESS equ 0202H ; DAC data port address

ADC_DATA DW ? ; Variable to store ADC data (16-bit)


DAC_DATA DW ? ; Variable to store DAC data (16-bit)
DATA_SEG ENDS

; Code segment
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG

START:
MOV AX, DATA_SEG
MOV DS, AX

; Initialize ADC (optional if initialization is required)


CALL INIT_ADC

; Read from ADC and output to DAC continuously


Loop:
CALL READ_ADC
CALL WRITE_DAC

JMP Loop ; Repeat loop indefinitely

; Subroutine to initialize ADC (example for ADC0804)


INIT_ADC PROC
; Initialize ADC (set control lines if necessary)
; Example:
MOV DX, ADC_ADDRESS ; Set DX to ADC data port address
IN AX, DX ; Read ADC data
RET
INIT_ADC ENDP

; Subroutine to read from ADC (example for ADC0804)


READ_ADC PROC
; Start conversion (set control lines if necessary)
; Example:
MOV DX, ADC_ADDRESS ; Set DX to ADC data port address
IN AX, DX ; Read ADC data
MOV ADC_DATA, AX ; Store ADC data in variable
RET
READ_ADC ENDP
; Subroutine to write to DAC (example for DAC0800)
WRITE_DAC PROC
; Write data to DAC (output to DAC data port)
; Example:
MOV AX, DAC_DATA ; Load DAC data
MOV DX, DAC_ADDRESS ; Set DX to DAC data port address
OUT DX, AX ; Output data to DAC
RET
WRITE_DAC ENDP

CODE_SEG ENDS
END START

2. Explanation of the ADC and DAC Interface Program:


o Data Segment: Defines variables for ADC and DAC data (ADC_DATA,
DAC_DATA) and their respective data port addresses (ADC_ADDRESS,
DAC_ADDRESS).
o Code Segment: Implements the main program loop (Loop) to continuously read
analog input from ADC, convert it to digital using the 8086 microprocessor, and
output the digital value to DAC for analog output.
o Subroutines: Includes subroutines (INIT_ADC, READ_ADC, WRITE_DAC)
for initializing ADC, reading ADC data, and writing DAC data, respectively.
o Initialization and Control: Uses I/O instructions (IN and OUT) to communicate
with ADC and DAC through their data port addresses.

Step 3: Assembling and Debugging

1. Assemble the Program:


o Use the assembler (e.g., TASM) to assemble the source code into machine code
(hexadecimal).
2. Debugging and Testing:
o Use the debugger (e.g., DEBUG) to load and execute the assembled program.
o Monitor the ADC and DAC operations using oscilloscope or observation
methods.
o Verify the conversion accuracy and output signal stability.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each instruction and
subroutine used.
o Record the results observed during debugging, noting any deviations or errors
encountered.
2. Conclusion:
o Summarize the experiment's findings regarding the interfacing of ADC and DAC
to the 8086 microprocessor.
o Discuss the functionality, accuracy, and limitations observed during ADC to DAC
data transfer.

Notes:

 Adjust the ADC and DAC interface code (INIT_ADC, READ_ADC, WRITE_DAC
procedures) according to the specific ADC (e.g., ADC0804) and DAC (e.g., DAC0800)
ICs used.
 Ensure proper connection and interfacing of ADC and DAC with the 8086
microprocessor.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in programming
and interfacing analog-to-digital and digital-to-analog conversion circuits with the 8086
microprocessor. This knowledge is essential for understanding embedded systems and signal
processing applications using assembly language programming.

Experiment Title: Parallel Communication between Two Microprocessors


using 8255

Objectives:

1. To establish parallel communication between two microprocessors using the 8255


Programmable Peripheral Interface (PPI).
2. To configure the 8255 IC in mode 1 (bidirectional mode) for data transfer.
3. To understand the concept of parallel communication and data transfer between
microprocessors.
4. To verify the reliability and efficiency of parallel communication using the 8255 IC.

Equipment Needed:

 Two microprocessor trainer kits or simulator software (e.g., DOSBox with TASM)
 Two 8255 ICs (Programmable Peripheral Interface)
 Interconnecting wires and breadboard (if using physical trainer kits)
 Personal computer with assembler and debugger tools (e.g., TASM, DEBUG)
 Reference materials or datasheets for the 8255 IC and microprocessors

Procedure:

Step 1: Setup and Initialization


1. Setup Microprocessor Trainer Kits or Simulator:
o Power on both microprocessor trainer kits or launch the simulator software on the
computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Interfacing 8255 IC:
o Connect the 8255 ICs to the respective microprocessor trainer kits or simulators.
o Configure the 8255 ICs in mode 1 (bidirectional mode) for parallel
communication.

Step 2: Wiring and Pin Configuration

1. Connecting Microprocessors via 8255 ICs:


o Identify and connect the necessary control and data lines between the two 8255
ICs.
o Use the following pin connections as a reference (adjust according to specific
microprocessors and setups):
 Microprocessor 1 (MP1) <-> 8255 IC 1 <-> 8255 IC 2 <->
Microprocessor 2 (MP2)
 Data lines (D0-D7), Control lines (RD, WR), Address lines (A0-A2) as
needed.
o Ensure proper grounding and power connections for both 8255 ICs and
microprocessors.

Step 3: Writing the Parallel Communication Program

1. Program Structure:

; Program for Parallel Communication between Two Microprocessors using 8255

; Data segment
DATA_SEG SEGMENT
PORT_A equ 0200H ; Port A base address
PORT_B equ 0201H ; Port B base address
PORT_C equ 0202H ; Port C base address

; Define 8255 control word for mode 1 (bidirectional mode)


CW_MODE1 DB 80H ; Control word for mode 1 (B7 = 1)

BUFFER DB ? ; Buffer for data transfer


DATA_SEG ENDS

; Code segment
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG
START:
MOV AX, DATA_SEG
MOV DS, AX

; Initialize 8255 ICs


CALL INIT_8255

; Example: Microprocessor 1 sends data to Microprocessor 2


MOV BUFFER, 55H ; Example data to send

; Write data to Port A (8255 IC 1 connected to Microprocessor 2)


MOV DX, PORT_A
MOV AL, BUFFER
OUT DX, AL

; Read data from Port A (8255 IC 2 connected to Microprocessor 1)


MOV DX, PORT_A
IN AL, DX
MOV BUFFER, AL

; Example: Display received data (Microprocessor 1)


; Display or process received data as required
; Example:
MOV AH, 09H ; Print string function
MOV DX, OFFSET BUFFER ; Load address of BUFFER
INT 21H ; Call DOS interrupt to print data

; Repeat communication process as needed

; Subroutine to initialize 8255 ICs in mode 1


INIT_8255 PROC
; Initialize 8255 ICs in mode 1 (bidirectional mode)
MOV DX, PORT_C ; Port C is control register
MOV AL, CW_MODE1 ; Load control word for mode 1
OUT DX, AL ; Output control word to 8255
RET
INIT_8255 ENDP

CODE_SEG ENDS
END START

2. Explanation of the Parallel Communication Program:


o Data Segment: Defines port addresses (PORT_A, PORT_B, PORT_C) for 8255
ICs, control word (CW_MODE1) for mode 1 operation, and buffer (BUFFER) for
data storage.
o Code Segment: Implements the main program (START) to initialize the 8255
ICs, send data from Microprocessor 1 to Microprocessor 2 via 8255 ICs, and
receive data back.
o Subroutines: Includes a subroutine (INIT_8255) to initialize the 8255 ICs in
mode 1 (bidirectional mode).
o Data Transfer: Uses OUT and IN instructions to write and read data from the
specified ports (Port A in this example).
o Communication Flow: Demonstrates a basic communication flow where
Microprocessor 1 sends data (BUFFER) to Microprocessor 2 via Port A of 8255
ICs and receives data back from Microprocessor 2.

Step 4: Assembling and Debugging

1. Assemble the Program:


o Use the assembler (e.g., TASM) to assemble the source code into machine code
(hexadecimal).
2. Debugging and Testing:
o Use the debugger (e.g., DEBUG) to load and execute the assembled program on
both microprocessors.
o Monitor data transfer using appropriate debugging tools or oscilloscope if
available.
o Verify the reliability and efficiency of parallel communication between the two
microprocessors.

Step 5: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each instruction and
subroutine used.
o Record the results observed during debugging, noting any deviations or errors
encountered.
2. Conclusion:
o Summarize the experiment's findings regarding parallel communication between
two microprocessors using the 8255 IC.
o Discuss the functionality, reliability, and potential applications of parallel
communication in embedded systems.

Notes:

 Adjust the port addresses (PORT_A, PORT_B, PORT_C) and control word
(CW_MODE1) according to the specific configuration and connections of the 8255 ICs.
 Ensure proper connection and interfacing of 8255 ICs with the microprocessors.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.
By conducting this lab manual experiment, you will gain practical experience in configuring and
utilizing the 8255 IC for parallel communication between microprocessors, enhancing your
understanding of embedded systems and parallel data transfer techniques.

Experiment Title: Serial Communication between Two Microprocessor Kits


using 8251

Objectives:

1. To establish serial communication between two microprocessor kits using the 8251
USART.
2. To configure the 8251 IC in both transmitter and receiver modes for data transmission.
3. To understand the concept of serial communication protocols (asynchronous or
synchronous) and data framing.
4. To verify the reliability and efficiency of serial communication using the 8251 IC.

Equipment Needed:

 Two microprocessor trainer kits or simulator software (e.g., DOSBox with TASM)
 Two 8251 ICs (Universal Synchronous/Asynchronous Receiver Transmitter)
 MAX232 or equivalent IC for RS232 voltage level conversion (if using physical trainer
kits)
 Interconnecting wires and breadboard (if using physical trainer kits)
 Personal computer with assembler and debugger tools (e.g., TASM, DEBUG)
 Reference materials or datasheets for the 8251 IC and microprocessors

Procedure:

Step 1: Setup and Initialization

1. Setup Microprocessor Trainer Kits or Simulator:


o Power on both microprocessor trainer kits or launch the simulator software on the
computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Interfacing 8251 IC:
o Connect the 8251 ICs to the respective microprocessor trainer kits or simulators.
o Use appropriate voltage level converters (e.g., MAX232) for RS232
communication if needed.
o Connect transmit (Tx), receive (Rx), ground (GND), and other necessary lines
between the 8251 ICs.

Step 2: Wiring and Pin Configuration


1. Connecting Microprocessors via 8251 ICs:
o Identify and connect the necessary lines (Tx, Rx, GND) between the two 8251
ICs.
o Use the following pin connections as a reference (adjust according to specific
microprocessors and setups):
 Microprocessor 1 (MP1) <-> 8251 IC 1 <-> 8251 IC 2 <->
Microprocessor 2 (MP2)
 Tx (transmit data), Rx (receive data), GND (ground) connections.
o Ensure proper grounding and power connections for both 8251 ICs and
microprocessors.

Step 3: Writing the Serial Communication Program

1. Program Structure:

; Program for Serial Communication between Two Microprocessor Kits using 8251

; Data segment
DATA_SEG SEGMENT
PORT_A equ 0200H ; Base address for 8251 port A (data register)
PORT_B equ 0201H ; Base address for 8251 port B (control/status register)

; Define control word for 8251 initialization (8 data bits, 1 stop bit, no parity)
CW_INIT DB 98H ; 10011000 in binary (B7-B5 = 100 for 8 data bits, B2-B1 = 01
for 1 stop bit)

BUFFER DB ? ; Buffer for data transfer


DATA_SEG ENDS

; Code segment
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG

START:
MOV AX, DATA_SEG
MOV DS, AX

; Initialize 8251 ICs


CALL INIT_8251

; Example: Microprocessor 1 sends data to Microprocessor 2


MOV BUFFER, 'A' ; Example data to send (ASCII character)

; Wait until transmitter is ready


WaitForTxReady:
MOV DX, PORT_B
IN AL, DX
TEST AL, 20H ; Check if transmitter ready bit (B5) is set
JZ WaitForTxReady ; Loop until ready

; Transmit data (Port A, 8251 IC 1)


MOV DX, PORT_A
MOV AL, BUFFER
OUT DX, AL

; Receive data (Port A, 8251 IC 2)


; Wait until data received
WaitForRxReady:
MOV DX, PORT_B
IN AL, DX
TEST AL, 01H ; Check if receiver ready bit (B0) is set
JZ WaitForRxReady ; Loop until ready

; Read received data (Port A, 8251 IC 2)


MOV DX, PORT_A
IN AL, DX
MOV BUFFER, AL

; Display or process received data (Microprocessor 1)


; Example:
MOV AH, 02H ; Set cursor position
MOV BH, 00H ; Page number
MOV DH, 10 ; Row
MOV DL, 10 ; Column
INT 10H ; BIOS interrupt to set cursor position
MOV AH, 09H ; Print character function
MOV DL, BUFFER ; Display received character
INT 21H ; BIOS interrupt to print character

; Repeat communication process as needed

; Subroutine to initialize 8251 ICs


INIT_8251 PROC
; Initialize 8251 ICs for serial communication
; Example:
MOV DX, PORT_B ; Set DX to port B address
MOV AL, CW_INIT ; Load control word for initialization
OUT DX, AL ; Output control word to 8251
RET
INIT_8251 ENDP
CODE_SEG ENDS
END START

2. Explanation of the Serial Communication Program:


o Data Segment: Defines port addresses (PORT_A, PORT_B) for 8251 ICs,
control word (CW_INIT) for initialization, and buffer (BUFFER) for data storage.
o Code Segment: Implements the main program (START) to initialize the 8251
ICs, send data from Microprocessor 1 to Microprocessor 2 via 8251 ICs, and
receive data back.
o Subroutines: Includes a subroutine (INIT_8251) to initialize the 8251 ICs for
serial communication.
o Data Transfer: Uses OUT and IN instructions to write and read data from the
specified ports (Port A in this example).
o Communication Flow: Demonstrates a basic communication flow where
Microprocessor 1 sends data (BUFFER) to Microprocessor 2 via 8251 ICs and
receives data back.

Step 4: Assembling and Debugging

1. Assemble the Program:


o Use the assembler (e.g., TASM) to assemble the source code into machine code
(hexadecimal).
2. Debugging and Testing:
o Use the debugger (e.g., DEBUG) to load and execute the assembled program on
both microprocessors.
o Monitor data transfer using appropriate debugging tools or serial communication
monitoring tools.
o Verify the reliability and efficiency of serial communication between the two
microprocessors.

Step 5: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each instruction and
subroutine used.
o Record the results observed during debugging, noting any deviations or errors
encountered.
2. Conclusion:
o Summarize the experiment's findings regarding serial communication between
two microprocessors using the 8251 IC.
o Discuss the functionality, reliability, and potential applications of serial
communication in embedded systems.

Notes:
 Adjust the port addresses (PORT_A, PORT_B) and control word (CW_INIT) according
to the specific configuration and connections of the 8251 ICs.
 Ensure proper connection and interfacing of 8251 ICs with the microprocessors.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in configuring and
utilizing the 8251 USART for serial communication between microprocessor kits, enhancing
your understanding of communication protocols and data transfer techniques in embedded
systems.

Experiment Title: Interfacing and Programming to Control Stepper Motor


with 8086

Objectives:

1. To interface a stepper motor with the 8086 microprocessor.


2. To program the 8086 microprocessor to control the stepper motor's rotation and direction.
3. To understand the principles of stepper motor operation and driver circuit requirements.
4. To verify the functionality and accuracy of stepper motor control using the 8086
microprocessor.

Equipment Needed:

 8086 microprocessor trainer kit or simulator software (e.g., DOSBox with TASM)
 Stepper motor (e.g., 4-wire, 5-wire, or 6-wire stepper motor)
 Stepper motor driver circuit (e.g., ULN2003, L298N)
 Power supply suitable for stepper motor and driver circuit
 Personal computer with assembler and debugger tools (e.g., TASM, DEBUG)
 Breadboard and interconnecting wires
 Datasheets for stepper motor, driver circuit, and 8086 microprocessor

Procedure:

Step 1: Setup and Initialization

1. Setup Microprocessor Trainer Kit or Simulator:


o Power on the 8086 microprocessor trainer kit or launch the simulator software on
the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Interfacing Stepper Motor and Driver Circuit:
o Connect the stepper motor to the stepper motor driver circuit (e.g., ULN2003).
o Ensure correct wiring between the driver circuit and stepper motor coils (based on
the motor's specifications).
o Connect the driver circuit control lines (input signals for step and direction) to the
8086 microprocessor's output ports.

Step 2: Writing the Stepper Motor Control Program

1. Program Structure:

; Program for Controlling Stepper Motor with 8086

; Data segment
DATA_SEG SEGMENT
PORT_DATA EQU 0200H ; Base address for data port
PORT_CTRL EQU 0201H ; Base address for control port

; Define control signals for stepper motor driver


STEP_SIGNAL EQU 01H ; Step signal (connect to driver circuit)
DIRECTION_SIGNAL EQU 02H ; Direction signal (connect to driver circuit)

DELAY_COUNT DW 1000 ; Delay count for controlling motor speed


STEPS_PER_REV DW 200 ; Number of steps per revolution of the stepper motor
DATA_SEG ENDS

; Code segment
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG, DS:DATA_SEG

START:
MOV AX, DATA_SEG
MOV DS, AX

; Initialize stepper motor control ports


CALL INIT_PORTS

; Example: Rotate stepper motor clockwise for one revolution


MOV CX, STEPS_PER_REV ; Number of steps for one revolution
MOV DX, DELAY_COUNT ; Delay count for motor speed

MOV BX, CX ; Copy step count to BX

RotateCW:
; Send step signal
MOV AL, STEP_SIGNAL
OUT PORT_CTRL, AL
; Delay for motor step
CALL DELAY

; Clear step signal


XOR AL, AL
OUT PORT_CTRL, AL

; Decrement step count


DEC CX

; Check for end of rotation


JNZ RotateCW

; Toggle direction for next rotation


MOV AL, DIRECTION_SIGNAL
OUT PORT_CTRL, AL

; Delay before next rotation (optional)


CALL DELAY

; Repeat clockwise rotation loop


JMP RotateCW

; Subroutine to initialize ports


INIT_PORTS PROC
MOV DX, PORT_CTRL ; Set DX to control port address
MOV AL, 0 ; Clear control port
OUT DX, AL
RET
INIT_PORTS ENDP

; Subroutine for delay loop


DELAY PROC
MOV CX, DX ; Load delay count
DelayLoop:
NOP ; Adjust NOPs for desired delay
NOP
NOP
LOOP DelayLoop
RET
DELAY ENDP

CODE_SEG ENDS
END START
2. Explanation of the Stepper Motor Control Program:
o Data Segment: Defines port addresses (PORT_DATA, PORT_CTRL) for
stepper motor control, signals (STEP_SIGNAL, DIRECTION_SIGNAL) for
driver circuit, and variables (DELAY_COUNT, STEPS_PER_REV) for
controlling motor movement.
o Code Segment: Implements the main program (START) to initialize ports, rotate
the stepper motor clockwise (RotateCW loop), and toggle direction for continuous
rotation.
o Subroutines: Includes subroutines (INIT_PORTS for port initialization, DELAY
for delay loop) to manage stepper motor control and timing.
o Stepper Motor Control: Uses output instructions (OUT) to send step and
direction signals to the stepper motor driver circuit, controlling motor rotation.

Step 3: Assembling and Debugging

1. Assemble the Program:


o Use the assembler (e.g., TASM) to assemble the source code into machine code
(hexadecimal).
2. Debugging and Testing:
o Use the debugger (e.g., DEBUG) to load and execute the assembled program on
the 8086 microprocessor.
o Observe the stepper motor's rotation and verify the number of steps per revolution
and direction control.
o Adjust delay counts and step signals as necessary to optimize motor speed and
performance.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each instruction and
subroutine used.
o Record the results observed during testing, noting any deviations or errors
encountered.
2. Conclusion:
o Summarize the experiment's findings regarding interfacing and programming to
control a stepper motor with the 8086 microprocessor.
o Discuss the functionality, accuracy, and applications of stepper motor control in
embedded systems.

Notes:

 Adjust the port addresses (PORT_DATA, PORT_CTRL), delay counts


(DELAY_COUNT), and step signals (STEP_SIGNAL, DIRECTION_SIGNAL)
according to your specific setup and stepper motor driver requirements.
 Ensure proper wiring and connection of the stepper motor and driver circuit to the 8086
microprocessor.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in interfacing and
programming to control a stepper motor with the 8086 microprocessor, enhancing your
understanding of motor control techniques and embedded systems design.

Experiment Title: Programming Using Arithmetic, Logical, and Bit


Manipulation Instructions of 8051

Objectives:

1. To gain proficiency in using arithmetic instructions (addition, subtraction, multiplication,


division) of the 8051 microcontroller.
2. To understand and implement logical instructions (AND, OR, XOR, NOT) for data
manipulation.
3. To learn and apply bit manipulation instructions (SETB, CLR, CPL, MOV) for
controlling specific bits in registers.
4. To verify and validate the functionality of each instruction through practical
programming exercises.

Equipment Needed:

 8051 microcontroller trainer kit or simulator software (e.g., Keil uVision, Proteus)
 Personal computer with assembler and debugger tools (e.g., Keil C51, SDCC)
 Breadboard and interconnecting wires (if using physical trainer kit)
 Reference materials or datasheets for 8051 microcontroller

Experiment Procedure:

Step 1: Setup and Initialization

1. Setup Microcontroller Trainer Kit or Simulator:


o Power on the 8051 microcontroller trainer kit or launch the simulator software on
the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Initialize Development Environment:
o Create a new project or assembly file for writing and testing 8051 assembly
language programs.

Step 2: Programming Exercises

1. Arithmetic Instructions:

; Program to demonstrate arithmetic instructions of 8051


; Data segment
ORG 00H
MOV A, #10H ; Load accumulator with 10 (hex)
ADD A, #05H ; Add 5 to accumulator
MOV R0, A ; Store result in R0
; Example: Display or use result stored in R0
; Add more arithmetic instructions as needed

2. Logical Instructions:

; Program to demonstrate logical instructions of 8051

; Data segment
ORG 00H
MOV A, #0A5H ; Load accumulator with 0A5H (binary 10100101)
ANL A, #0F0H ; Perform bitwise AND with 0F0H (binary 11110000)
MOV R0, A ; Store result in R0
; Example: Display or use result stored in R0
; Add more logical instructions as needed

3. Bit Manipulation Instructions:

; Program to demonstrate bit manipulation instructions of 8051

; Data segment
ORG 00H
MOV A, #0FFH ; Load accumulator with all bits set (11111111)
CLR A.0 ; Clear bit 0
SETB A.1 ; Set bit 1
CPL A.2 ; Complement bit 2
MOV R0, A ; Store result in R0
; Example: Display or use result stored in R0
; Add more bit manipulation instructions as needed

Step 3: Assembling and Testing

1. Assemble the Programs:


o Use the assembler (e.g., Keil C51, SDCC) to assemble the assembly language
programs into machine code.
2. Testing and Debugging:
o Load and execute the assembled programs on the 8051 microcontroller trainer kit
or simulator.
o Use debugger tools to step through the program execution, observing the values in
registers and memory locations.
o Verify the correctness of arithmetic, logical, and bit manipulation operations.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each instruction and its
purpose.
o Record the results observed during testing, noting any deviations or errors
encountered.
2. Conclusion:
o Summarize the experiment's findings regarding programming with arithmetic,
logical, and bit manipulation instructions of the 8051 microcontroller.
o Discuss the importance of these instructions in microcontroller programming and
their applications in embedded systems.

Notes:

 Adjust the examples and specific instructions (ADD, ANL, CLR, SETB, etc.) based on
your learning objectives and curriculum requirements.
 Ensure familiarity with the 8051 microcontroller architecture and instruction set before
proceeding with programming exercises.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in programming
using arithmetic, logical, and bit manipulation instructions of the 8051 microcontroller,
enhancing your skills in microcontroller programming and embedded systems development.

Experiment Title: Program and Verify Timer/Counter in 8051


Objectives:

1. To understand the Timer/Counter functionality of the 8051 microcontroller.


2. To program Timer/Counter operations for generating delays and counting events.
3. To verify the accuracy and functionality of Timer/Counter through practical
experimentation.
4. To gain proficiency in using Timer/Counter interrupts for precise timing operations.

Equipment Needed:

 8051 microcontroller trainer kit or simulator software (e.g., Keil uVision, Proteus)
 Personal computer with assembler and debugger tools (e.g., Keil C51, SDCC)
 Breadboard and interconnecting wires (if using physical trainer kit)
 Oscilloscope (optional for advanced verification)
 Reference materials or datasheets for 8051 microcontroller

Experiment Procedure:

Step 1: Setup and Initialization

1. Setup Microcontroller Trainer Kit or Simulator:


o Power on the 8051 microcontroller trainer kit or launch the simulator software on
the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Initialize Development Environment:
o Create a new project or assembly file for writing and testing 8051 assembly
language programs.

Step 2: Programming Timer/Counter Operations

1. Generate Delay using Timer/Counter:

; Program to demonstrate delay generation using Timer/Counter in 8051

; Data segment
ORG 00H

MAIN:
MOV R0, #100 ; Load R0 with delay count (adjust for desired delay)
DelayLoop:
NOP ; Adjust NOPs for desired delay
NOP
NOP
DJNZ R0, DelayLoop ; Decrement R0 and loop until zero
; Example: Proceed with main program after delay
; Add more instructions as needed

2. Count Events using Timer/Counter:

; Program to demonstrate event counting using Timer/Counter in 8051

; Data segment
ORG 00H

MAIN:
MOV TMOD, #01H ; Set Timer 0 in mode 1 (16-bit timer)
MOV TH0, #0FFH ; Load initial value for Timer 0 (adjust as needed)
MOV TL0, #0FFH ; Load initial value for Timer 0 (adjust as needed)
SETB TR0 ; Start Timer 0

; Example: Count events or perform other operations


; Wait for Timer 0 overflow (TF0 flag)
WaitForOverflow:
JNB TF0, WaitForOverflow ; Loop until Timer 0 overflows

; Example: Handle Timer overflow event


CLR TF0 ; Clear Timer 0 overflow flag
; Perform actions on overflow

; Repeat counting or other operations as needed

Step 3: Assembling and Testing

1. Assemble the Programs:


o Use the assembler (e.g., Keil C51, SDCC) to assemble the assembly language
programs into machine code.
2. Testing and Verification:
o Load and execute the assembled programs on the 8051 microcontroller trainer kit
or simulator.
o Use debugger tools to monitor Timer/Counter registers (TH0, TL0 for Timer 0)
and flags (TF0 for Timer 0 overflow).
o Verify the generation of delays and counting of events as programmed.
3. Optional: Use Oscilloscope for Advanced Verification:
o Connect the oscilloscope to the Timer/Counter output pins (if available) to
measure and verify the generated delays or counting accuracy.

Step 4: Documentation and Conclusion

1. Record Observations:
Document the source code with comments explaining each Timer/Counter
o
operation and its purpose.
o Record the results observed during testing, including any delays generated or
events counted.
2. Conclusion:
o Summarize the experiment's findings regarding Timer/Counter operations in the
8051 microcontroller.
o Discuss the importance of precise timing in microcontroller applications and the
role of Timer/Counter in embedded systems.

Notes:

 Adjust the examples and specific Timer/Counter configurations (TMOD, TH0, TL0,
TR0, TF0) based on your learning objectives and curriculum requirements.
 Ensure familiarity with Timer/Counter modes and interrupts of the 8051 microcontroller
before proceeding with programming exercises.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in programming
and verifying Timer/Counter operations in the 8051 microcontroller, enhancing your skills in
embedded systems development and precise timing control.

Experiment Title: Program and Verify Interrupt Handling in 8051

Objectives:

1. To understand the concept of interrupts and interrupt handling in the 8051


microcontroller.
2. To program interrupt service routines (ISRs) for handling external and internal interrupts.
3. To verify the functionality and priority of interrupts through practical experimentation.
4. To gain proficiency in using interrupt-related registers and vectors of the 8051
microcontroller.

Equipment Needed:

 8051 microcontroller trainer kit or simulator software (e.g., Keil uVision, Proteus)
 Personal computer with assembler and debugger tools (e.g., Keil C51, SDCC)
 Breadboard and interconnecting wires (if using physical trainer kit)
 Oscilloscope (optional for advanced verification)
 Reference materials or datasheets for 8051 microcontroller

Experiment Procedure:
Step 1: Setup and Initialization

1. Setup Microcontroller Trainer Kit or Simulator:


o Power on the 8051 microcontroller trainer kit or launch the simulator software on
the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
2. Initialize Development Environment:
o Create a new project or assembly file for writing and testing 8051 assembly
language programs.
o Configure interrupt-related settings and registers as needed.

Step 2: Programming Interrupt Handling

1. External Interrupt Handling:

; Program to demonstrate external interrupt handling in 8051

; Data segment
ORG 00H

; Interrupt vector for external interrupt 0 (INT0)


ORG 0003H
LJMP External_ISR ; Jump to external interrupt service routine

; Code segment
External_ISR:
; Interrupt service routine for external interrupt 0 (INT0)
; Example: Toggle LED or perform actions upon INT0 interrupt
; Clear interrupt flag and exit ISR
RETI

2. Timer Interrupt Handling:

; Program to demonstrate timer interrupt handling in 8051

; Data segment
ORG 00H

; Interrupt vector for Timer 0 interrupt


ORG 000BH
LJMP Timer_ISR ; Jump to Timer 0 interrupt service routine

; Code segment
Timer_ISR:
; Interrupt service routine for Timer 0 interrupt
; Example: Generate periodic task or update variables on Timer 0 interrupt
; Clear interrupt flag and exit ISR
RETI

Step 3: Assembling and Testing

1. Assemble the Programs:


o Use the assembler (e.g., Keil C51, SDCC) to assemble the assembly language
programs into machine code.
2. Testing and Verification:
o Load and execute the assembled programs on the 8051 microcontroller trainer kit
or simulator.
o Use debugger tools to simulate or trigger external interrupts (e.g., INT0) and
Timer interrupts (e.g., Timer 0).
o Verify that the ISRs are executed correctly when interrupts occur.
o Ensure proper handling of interrupt flags (IE register) and vector addresses (IVT).
3. Optional: Use Oscilloscope for Advanced Verification:
o Connect the oscilloscope to relevant pins or indicators (e.g., LED toggling) to
visually confirm interrupt occurrences and ISR execution timings.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each interrupt handling
routine and its purpose.
o Record the results observed during testing, including ISR execution upon
interrupt events.
2. Conclusion:
o Summarize the experiment's findings regarding interrupt handling in the 8051
microcontroller.
o Discuss the significance of interrupt priority, vector addresses, and ISR execution
flow in embedded systems.

Notes:

 Adjust the examples and specific interrupt configurations (ORG addresses, LJMP to
ISRs) based on your learning objectives and curriculum requirements.
 Ensure familiarity with interrupt sources (INT0, Timer 0), interrupt enable (IE register),
and interrupt vector table (IVT) of the 8051 microcontroller.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in programming
and verifying interrupt handling in the 8051 microcontroller, enhancing your skills in real-time
event processing and embedded systems development.
Experiment Title: UART Operation in 8051

Objectives:

1. To understand the UART communication protocol and its implementation in the 8051
microcontroller.
2. To program UART transmit and receive operations for serial communication.
3. To verify the functionality of UART communication through practical experimentation.
4. To gain proficiency in using UART-related registers and settings of the 8051
microcontroller.

Equipment Needed:

 8051 microcontroller trainer kit or simulator software (e.g., Keil uVision, Proteus)
 Personal computer with UART terminal software (e.g., PuTTY, Tera Term)
 Breadboard and interconnecting wires (if using physical trainer kit)
 Oscilloscope (optional for advanced verification)
 Reference materials or datasheets for 8051 microcontroller and UART communication

Experiment Procedure:

Step 1: Setup and Initialization

1. Setup Microcontroller Trainer Kit or Simulator:


o Power on the 8051 microcontroller trainer kit or launch the simulator software on
the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
o Connect the UART pins (TXD, RXD) of the 8051 microcontroller to
corresponding pins on the UART terminal (or loopback for testing).
2. Initialize Development Environment:
o Create a new project or assembly file for writing and testing 8051 assembly
language programs.
o Configure UART-related settings and baud rate for communication.

Step 2: Programming UART Operations

1. UART Transmit Operation:

; Program to demonstrate UART transmit operation in 8051

; Define UART control registers


SCON EQU 98H ; Serial Control Register
SBUF EQU 99H ; Serial Buffer Register

; Data segment
ORG 00H

; Initialize UART settings


MOV SCON, #50H ; Mode 1, 8-bit UART, enable receiver

MAIN:
MOV A, #'A' ; Load character to transmit
MOV SBUF, A ; Send character via UART

; Example: Wait for transmission to complete (optional)


; Add more instructions as needed

2. UART Receive Operation:

; Program to demonstrate UART receive operation in 8051

; Define UART control registers


SCON EQU 98H ; Serial Control Register
SBUF EQU 99H ; Serial Buffer Register

; Data segment
ORG 00H

; Initialize UART settings


MOV SCON, #50H ; Mode 1, 8-bit UART, enable receiver

; Interrupt service routine for UART receive


ORG 0023H
LJMP UART_ISR ; Jump to UART receive interrupt service routine

; UART receive interrupt service routine


UART_ISR:
MOV A, SBUF ; Read received character from SBUF
; Example: Process received character (e.g., display or store)

; Clear RI (Receive Interrupt flag) and exit ISR


CLR RI
RETI

Step 3: Assembling and Testing

1. Assemble the Programs:


o Use the assembler (e.g., Keil C51, SDCC) to assemble the assembly language
programs into machine code.
2. Testing and Verification:
Load and execute the assembled programs on the 8051 microcontroller trainer kit
o
or simulator.
o Open the UART terminal software (PuTTY, Tera Term) on the computer and
configure it to match the baud rate and settings used in the 8051 program.
o Transmit characters from the microcontroller and verify reception on the UART
terminal.
o Transmit characters from the UART terminal and verify reception by the
microcontroller.
3. Optional: Use Oscilloscope for Advanced Verification:
o Connect the oscilloscope to UART transmit (TXD) and receive (RXD) pins to
monitor waveform signals and verify data transmission and reception timings.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each UART operation and
its purpose.
o Record the results observed during testing, including successful transmission and
reception of data.
2. Conclusion:
o Summarize the experiment's findings regarding UART operation in the 8051
microcontroller.
o Discuss the importance of UART communication in embedded systems and
applications.

Notes:

 Adjust the examples and specific UART configurations (SCON, SBUF, baud rate) based
on your learning objectives and curriculum requirements.
 Ensure proper UART pin connections and settings (baud rate, data bits, parity, stop bits)
between the 8051 microcontroller and UART terminal.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in programming
and verifying UART operation in the 8051 microcontroller, enhancing your skills in serial
communication and embedded systems development.
Experiment Title: Interfacing LCD to 8051

Objectives:

1. To understand the principles of interfacing an LCD with the 8051 microcontroller.


2. To learn the hardware connections and initialization sequence required for interfacing.
3. To program basic functions to display text and control the LCD from the 8051
microcontroller.
4. To verify the functionality of the LCD display through practical experimentation.

Equipment Needed:

 8051 microcontroller trainer kit or simulator software (e.g., Keil uVision, Proteus)
 Personal computer with assembler and debugger tools (e.g., Keil C51, SDCC)
 LCD module (16x2 or as per specification)
 Potentiometer (for contrast adjustment, if required)
 Breadboard and interconnecting wires (if using physical trainer kit)
 Reference materials or datasheets for 8051 microcontroller and LCD module

Experiment Procedure:

Step 1: Setup and Initialization

1. Setup Microcontroller Trainer Kit or Simulator:


o Power on the 8051 microcontroller trainer kit or launch the simulator software on
the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
o Connect the necessary pins of the LCD module to the 8051 microcontroller
according to the datasheet.
2. Hardware Connections:
o Connect the control pins (RS, RW, EN) and data pins (D0-D7) of the LCD
module to the corresponding port pins of the 8051 microcontroller.
o Optionally, connect a potentiometer to adjust the contrast of the LCD (if required
by the LCD module).

Step 2: Programming LCD Interfacing

1. Initialization Sequence:

; Program to initialize and interface LCD with 8051

; Define LCD control pins


RS EQU P1.0 ; Register Select pin
RW EQU P1.1 ; Read/Write pin
EN EQU P1.2 ; Enable pin
; Define LCD data pins
DATA_PORT EQU P2 ; Data port connected to D0-D7

; LCD commands
CLR_DISP EQU 01H ; Clear display command
HOME_DISP EQU 02H ; Return home command

; Data segment
ORG 00H

; Initialize LCD function


INIT_LCD:
MOV A, #38H ; 2-line display, 8-bit mode
ACALL LCD_CMD ; Send command to initialize LCD
MOV A, #0EH ; Display ON, cursor ON
ACALL LCD_CMD ; Send command to initialize LCD
MOV A, #06H ; Increment cursor, no display shift
ACALL LCD_CMD ; Send command to initialize LCD
MOV A, #01H ; Clear display command
ACALL LCD_CMD ; Send command to initialize LCD
MOV A, #80H ; Move cursor to line 1, position 1
ACALL LCD_CMD ; Send command to initialize LCD
RET

LCD_CMD:
MOV RS, #0 ; RS = 0 for command register
MOV RW, #0 ; RW = 0 for write operation
MOV DATA_PORT, A ; Send command to data port
SETB EN ; Enable pulse
CLR EN
ACALL DELAY ; Adjust delay for LCD response time
RET

DELAY:
; Adjust delay for LCD initialization
MOV R1, #30
DLY_LOOP:
DJNZ R1, DLY_LOOP
RET

; Main program
MAIN:
ACALL INIT_LCD ; Initialize LCD
; Example: Display text on LCD
MOV A, #'H'
ACALL LCD_DATA ; Display 'H' on LCD
MOV A, #'E'
ACALL LCD_DATA ; Display 'E' on LCD
MOV A, #'L'
ACALL LCD_DATA ; Display 'L' on LCD
MOV A, #'L'
ACALL LCD_DATA ; Display 'L' on LCD
MOV A, #'O'
ACALL LCD_DATA ; Display 'O' on LCD
END

LCD_DATA:
MOV RS, #1 ; RS = 1 for data register
MOV RW, #0 ; RW = 0 for write operation
MOV DATA_PORT, A ; Send data to data port
SETB EN ; Enable pulse
CLR EN
ACALL DELAY ; Adjust delay for LCD response time
RET

Step 3: Assembling and Testing

1. Assemble the Program:


o Use the assembler (e.g., Keil C51, SDCC) to assemble the assembly language
program into machine code.
2. Testing and Verification:
o Load and execute the assembled program on the 8051 microcontroller trainer kit
or simulator.
o Observe the initialization sequence on the LCD display (e.g., initialization
message or cursor position).
o Verify the display of characters ('HELLO' in this example) on the LCD screen.
3. Adjustments and Troubleshooting:
o If the display is not clear or characters are not displayed correctly, adjust the
contrast using the potentiometer or check the connections and program logic.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each LCD interfacing
function and its purpose.
o Record the results observed during testing, including successful initialization and
character display on the LCD.
2. Conclusion:
o Summarize the experiment's findings regarding LCD interfacing with the 8051
microcontroller.
o Discuss the importance of proper initialization sequence, hardware connections,
and software configuration for successful LCD interfacing.

Notes:

 Adjust the examples and specific LCD module configurations (INIT_LCD, LCD_CMD,
LCD_DATA, DELAY) based on your LCD module specifications and interface
requirements.
 Ensure proper wiring and connections between the 8051 microcontroller and the LCD
module to avoid hardware issues.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in interfacing an
LCD with the 8051 microcontroller, enhancing your skills in display technology and embedded
systems development.
Experiment Title: Interfacing Matrix Keyboard to 8051

Objectives:

1. To understand the principles of interfacing a matrix keyboard with the 8051


microcontroller.
2. To learn the hardware connections and scanning technique required for interfacing.
3. To program functions to scan and read key presses from the matrix keyboard.
4. To verify the functionality of the matrix keyboard interface through practical
experimentation.

Equipment Needed:

 8051 microcontroller trainer kit or simulator software (e.g., Keil uVision, Proteus)
 Personal computer with assembler and debugger tools (e.g., Keil C51, SDCC)
 Matrix keyboard (e.g., 4x4 or 4x3 key configuration)
 Pull-up resistors (typically 10kΩ)
 Breadboard and interconnecting wires (if using physical trainer kit)
 Reference materials or datasheets for 8051 microcontroller and matrix keyboard

Experiment Procedure:

Step 1: Setup and Initialization

1. Setup Microcontroller Trainer Kit or Simulator:


o Power on the 8051 microcontroller trainer kit or launch the simulator software on
the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
o Connect the necessary pins of the matrix keyboard to the 8051 microcontroller
according to the datasheet.
2. Hardware Connections:
o Connect the rows and columns of the matrix keyboard to the port pins of the 8051
microcontroller.
o Use pull-up resistors (typically 10kΩ) for the column lines to keep them high
when no key is pressed.
o Configure row lines as outputs and column lines as inputs.

Step 2: Programming Matrix Keyboard Interfacing

1. Matrix Keyboard Scanning:

; Program to interface matrix keyboard with 8051

; Define matrix keyboard pins


ROWS EQU P1 ; Connect to row lines of matrix keyboard
COLS EQU P2 ; Connect to column lines of matrix keyboard

; Data segment
ORG 00H

; Initialize matrix keyboard function


INIT_KEYBOARD:
MOV ROWS, #0FFH ; Set rows as inputs with pull-ups
MOV COLS, #0FH ; Set columns as outputs

; Main program
MAIN:
ACALL SCAN_KEYBOARD ; Scan matrix keyboard for key press
; Example: Process key press and perform actions based on the key

; Loop indefinitely
SJMP MAIN

; Function to scan matrix keyboard


SCAN_KEYBOARD:
MOV A, #0FH ; Initial column mask
SCAN_LOOP:
MOV COLS, A ; Output column mask
MOV A, ROWS ; Read row lines
CJNE A, #0FH, KEY_FOUND ; Check if any key is pressed
INC A ; Shift column mask
JNZ SCAN_LOOP ; Loop until all columns scanned
RET

KEY_FOUND:
; Determine which key is pressed based on column and row
; Example: Use lookup table or switch-case to identify key press
; Example: Store or display the pressed key

; Optional: Wait for key release or debounce (if required)


ACALL DELAY_MS ; Adjust delay function for debounce or key release
RET

; Delay function (example)


DELAY_MS:
; Delay for a specified time (in milliseconds)
; Adjust based on specific timing requirements
MOV R1, #10 ; Adjust for desired delay
DELAY_LOOP:
NOP
DJNZ R1, DELAY_LOOP
RET

Step 3: Assembling and Testing

1. Assemble the Program:


o Use the assembler (e.g., Keil C51, SDCC) to assemble the assembly language
program into machine code.
2. Testing and Verification:
o Load and execute the assembled program on the 8051 microcontroller trainer kit
or simulator.
o Press keys on the matrix keyboard and observe the output (e.g., display key codes
or actions) on the debug console or LCD (if interfaced).
o Verify the correct detection of key presses and functionality of the scanning
routine.
3. Adjustments and Troubleshooting:
o If certain keys are not detected or if there are debounce issues, adjust the delay
function or debounce logic in the program.
o Check hardware connections and ensure pull-up resistors are correctly placed.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each part of the matrix
keyboard interfacing program and its purpose.
o Record the results observed during testing, including successful detection of key
presses.
2. Conclusion:
o Summarize the experiment's findings regarding matrix keyboard interfacing with
the 8051 microcontroller.
o Discuss the importance of scanning techniques, hardware configuration, and
software implementation in keyboard interfacing.

Notes:

 Adjust the examples and specific matrix keyboard configurations (INIT_KEYBOARD,


SCAN_KEYBOARD, DELAY_MS) based on your matrix keyboard layout and interface
requirements.
 Ensure proper wiring and connections between the 8051 microcontroller and the matrix
keyboard to avoid hardware issues.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in interfacing a
matrix keyboard with the 8051 microcontroller, enhancing your skills in input device integration
and embedded systems development.
Experiment Title: Data Transfer from Peripheral to Memory using DMA
Controller 8237/8257

Objectives:

1. To understand the concept of DMA (Direct Memory Access) and its role in data transfer.
2. To interface and configure a DMA controller (8237 or 8257) with the 8051
microcontroller.
3. To program and initiate data transfer from a peripheral device (e.g., ADC, UART) to
memory using DMA.
4. To verify the successful transfer of data through practical experimentation.

Equipment Needed:

 8051 microcontroller trainer kit or simulator software (e.g., Keil uVision, Proteus)
 DMA controller IC (8237 or 8257)
 Peripheral device (e.g., ADC, UART) for data source
 Memory for data destination (RAM or other memory devices)
 Breadboard and interconnecting wires (if using physical trainer kit)
 Reference materials or datasheets for DMA controller and 8051 microcontroller

Experiment Procedure:

Step 1: Setup and Initialization

1. Setup Microcontroller Trainer Kit or Simulator:


o Power on the 8051 microcontroller trainer kit or launch the simulator software on
the computer.
o Ensure the assembler and debugger tools are installed and configured correctly.
o Connect the DMA controller (8237 or 8257) and configure its control and data
lines with the 8051 microcontroller.
2. Hardware Connections:
o Connect the address and data lines of the DMA controller to the 8051
microcontroller.
o Connect the DMA controller to the memory module (RAM) where data will be
transferred.
o Ensure proper grounding and power connections for stable operation.

Step 2: Programming DMA Controller

1. Initialize DMA Controller:

; Program to initialize DMA controller for data transfer

; Define DMA controller control and status ports


DREQ EQU P1.0 ; DMA request pin
DACK EQU P1.1 ; DMA acknowledge pin
DMA_PORT EQU P2 ; DMA data port

; Data segment
ORG 00H

; Initialize DMA function


INIT_DMA:
MOV DREQ, #0 ; Clear DMA request pin
MOV DACK, #0 ; Clear DMA acknowledge pin
; Configure DMA controller registers (8237/8257) as needed
; Example: Set DMA mode, transfer count, memory address, etc.
; Initialize peripheral device (e.g., ADC or UART) for DMA operation
; Start DMA transfer
ACALL START_DMA
RET

; Function to start DMA transfer


START_DMA:
; Set up DMA controller for transfer
; Example: Enable DMA channel, initiate data transfer from peripheral to memory
; Wait for DMA transfer completion (optional)
ACALL WAIT_DMA_COMPLETE
RET

; Function to wait for DMA transfer completion


WAIT_DMA_COMPLETE:
; Check DMA controller status or wait for interrupt (if used)
; Example: Poll DMA status register or wait for interrupt flag
; Optionally handle errors or abort conditions
RET

2. Configure DMA Transfer Parameters:


o Configure the DMA controller registers (mode, transfer count, memory address)
according to the peripheral data source and memory destination.
o Initialize the peripheral device (e.g., ADC or UART) for DMA operation and
ensure it generates DMA requests.

Step 3: Assembling and Testing

1. Assemble the Program:


o Use the assembler (e.g., Keil C51, SDCC) to assemble the assembly language
program into machine code.
2. Testing and Verification:
o Load and execute the assembled program on the 8051 microcontroller trainer kit
or simulator.
o Verify the DMA controller initialization and start of data transfer.
o Monitor the memory location where data is transferred to ensure correct data
transfer operation.
o Use debug tools to check DMA controller status registers or interrupt flags (if
applicable) for successful completion.

Step 4: Documentation and Conclusion

1. Record Observations:
o Document the source code with comments explaining each DMA controller
function and its purpose.
o Record the results observed during testing, including successful data transfer and
any issues encountered.
2. Conclusion:
o Summarize the experiment's findings regarding DMA data transfer from
peripheral to memory using the 8051 microcontroller.
o Discuss the advantages of using DMA for efficient data transfer and its impact on
system performance.

Notes:

 Adjust the examples and specific DMA controller configurations (INIT_DMA,


START_DMA, WAIT_DMA_COMPLETE) based on your DMA controller (8237 or
8257) and interface requirements.
 Ensure proper synchronization between the peripheral device generating DMA requests
and the DMA controller operation.
 Collaborate with peers or instructors to discuss and validate your observations for better
understanding.

By conducting this lab manual experiment, you will gain practical experience in configuring and
programming DMA data transfer operations with the 8051 microcontroller, enhancing your skills
in embedded systems and real-time data handling.

You might also like