Laboratory Manual Lab: Subject Code: Semester:: Hardware Programme & Interfaceing
Laboratory Manual Lab: Subject Code: Semester:: Hardware Programme & Interfaceing
Laboratory Manual Lab: Subject Code: Semester:: Hardware Programme & Interfaceing
DO’s DON’T’S
1. NEVER experiment on your own.
1. Know the location of all safety and
emergency equipment used in the lab.
2. Do not eat or drink in the lab room at
any time (other than permitted by
2. Know fire drill procedures and
instructor).
lcoations of all exits.
3. Do not chew gum or eat candy during
3. Know the location of the closest
lab exercises.
telephone.
4. NEVER add water to an acid.
4. Familiarize yourself with all lab
procedures before doing the lab
5. Do not wear contacts in the lab
exercise.
without proper eye protection.
5. Report ALL accidents, hazards or
6. NEVER smell, taste or touch
chemical spills to the instructor (no
chemicals.
matter how small).
7. NEVER work in the lab alone.
6. Keep you work area clean and clutter
free.
8. NEVER use electrical equipment
around water.
7. Tie back all long hair and remove
dangling jewelry during lab.
9. NEVER mix chemicals before
asking the instructor.
8. Always be sure that electrical
equipment is turned in the "off"
10. NEVER return unused chemicals to
position before plugging it into a
the original container.
socket.
11. Absolutely NO HORSEPLAY is
9. Handle all animals with care
allowed in the lab area!
.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
Internal Marks: 30 L T P
External Marks: 20 0 0 2
Total Marks: 50
LIST OF EXPERIMENTS
Note: Any Eight Experiments each from Part A and Part-B
Part-A: List of Experiments using 8085/8086:
1. Study of 8085 and 8086 Microprocessor Kits.
2. Write a program to add two 8-bit number using 8085.
3. Write a program to add two 16-bit number using 8085.
4. Write a program to subtract two 8-bit number using 8085.
5. Write a program to subtract two 16-bit number using 8085.
6. Write a program to multiply two 8 bit numbers by repetitive addition
methodusing 8085.
7. Write a program to sort series using bubble sort algorithm using 8085.
8. Write a program to copy 12 bytes of data from source to destination using
8086.
9. Write a program to find maximum and minimum from series using 8086.
10. Write a program to control the operation of stepper motor using
8085/8086 microprocessors and 8255 PPI.
11. Write a program to control speed of DC motor using 8085/8086
microprocessors and 8255 PPI.
Part-B: List of Experiments using 8051:
1. Study of 8051/8031 Micro controller kits.
2. Write a program to add two numbers lying at two memory locations and
display
the result.
3. Write a program for multiplication of two numbers lying at memory
location and display the result.
4. Write a Program to arrange 10 numbers stored in memory location in
Ascending and Descending order.
5. Write a program to show the use of INT0 and INT1.
6. Write a program of Flashing LED connected to port 1 of the Micro
Controller
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
Hexpad/Display interface
8279 keyboard display controller is used for Hexpad keys & displays (8nos.
of 7 segment displays)
Interrupt Controller:
The 8259 interrupt controller provides 8 prioritized interrupt levels. IRQ5 to
IRQ7 are brought out on 50 pin FRC connector and can be used by the user.
IRQ3 is connected to “INT” key of Hex keypad. 8259 is programmed for
edge trigger. Except IRQ3 all other interrupts are masked.
connectors. The PIO cards from Dynalog supported on DYNA-86 are listed
in Appendix B, and can be interfaced on connector J2. The connector J1 is
used for printer interface in serial mode.
System Software
The DYNA-86 Microprocessor kit has vast software features. It supports
two different modes of operation:
1. HEX KEYPAD mode
2. SERIAL mode
POWER SUPPLY
The kit is normally used with the Dynalog’s SMPS 04 Model Power Supply.
The 6 pin female connector can be plugged in 6 pin Male Connector
soldered on board
+5 V 3 Amps
+12V 250 mA
-12V 250mA
CONNECTORS ON BOARD
SERIAL CONNECTOR
All the signals for the RS 232C compatible serial interface are brought out
on the 9-pin D type Male (DTM) connector onboard. The serial cables can
be directly connected to this connector.
Two 26 pin FRC male connectors are provided onboard for 8255’s I/O
interface. The 3 ports, 8 bit each, 24 lines of each, 8255 are provided on this
connector. Connector J2 is used for interfacing DYNA-PIO cards whereas J1
is used to connect printer in serial mode.
A 50 pin FRC male connector provided is for Bus expansion purpose. All
the address, Data and control lines along with the DRQ & interrupts are
terminated on this connector (J7). The same connector is used to interface
DYNA-86 with DYNA-series study cards.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
EXPERIMENT NO.: -2
Procedure: -
Step 4 : Verification
1. Press ‘Reset’.
2. Press ‘Exmem’.
3. Enter the memory address where result is stored.
ADDRESS OPCODE LABEL MNEMONIC OPERAND COMMENTS
2000 21,01,25 LXI H, 2501 H Get address of 1st
no. in H-L pair
2003 7E MOV A, M 1st no. in
accumulator
2004 23 INX H Increment
content of H-L
pair
2005 86 ADD M 1st no. + 2nd no.,
result in
accumulator
2006 23 INX H Increment
content of H-L
pair
2007 77 MOV M, A Store result in
2503 H
2008 76 HLT Halt
4. Press ‘Next’
5. See the contents of that address that is result.
Program:
Result: - Check the result on the memory location defined in the program
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
EXPERIMENT NO.: -3
Program:
ADDRESS OPCODE LABEL MNEMONIC OPERAND COMMENTS
2006 2A,02,20,EB START LHLD 2002 H load HL pair with
l(2002);h(2003)
2009 EB XCHG Exchange HL pair
with DE pair
200A 2A,00,20 LHLD 2000 H load HL pair with
L-(2000);H(2001)
200D 7D MOV A,L AL
200E 93 ADD E AA+E
200F 6F MOV L,A Restore the result and
LSB in Reg L.
2010 7C MOV A,H AH
2011 9A ADDC D AA+D with carry
Result: -Check the result on the memory location defined in the program.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
EXPERIMENT NO.: -4
AIM: - Write a program to subtract the two 8-bit numbers using 8085.
PROGRAM:- Write a program for the subtract two 8-bit numbers using
Result: - Check the result on the memory location defined in the program.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
EXPERIMENT NO.: -5
Result: -Check the result on the memory location defined in the program
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
EXPERIMENT NO.: -6
Procedure: -
Result: - Check the result on the memory location defined in the program.
EXPERIMENT NO.: -7
AIM: - Write a program to sort series using bubble sort algorithm using
8085.
Procedure: -
5. Fill the machine code on next address location by pressing the NEXT
key on keyboard and check the previous code by pressing PRE key.
6. After entering the whole program, verify it by execution.
PROGRAM:
ADDRESS OPCODE LABEL MNEMONIC OPERAND COMMENTS
2000 2A,01,25 LHLD 2501 H Get data in H-
L pair.
2003 29 DAD H Shift it left by
one bit
2004 32,03,25 STA 2503 H Store result in
2503 and 2504
H
2007 76 HLT Halt
Result: - Check the result on the memory location defined in the program.
EXPERIMENT NO.: -8
Procedure: -
Switch ON the microprocessor training kit and SMPS.
When the kits is ON then check, “FRIEND” displays on the display.
Now press the SET key on the key board and check that “.” (Dot) is
displayed.
MEMORY MACHINE LABEL MNEMONIC OPERAND COMMENTS
ADDRESS CODE
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
PROGRAM:-
Result: - Check the result on the memory location defined in the program
EXPERIMENT NO.: -9
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
Procedure: -
PROGRAM:-
NUMBER
Result: - Check the result on the memory location defined in the program.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME BTEC -508 5th
& INTERFACEING
PART -B
EXPERIMENT NO. : -1
Local Mode:
This mode supports following commands:
2.Serial Mode:
This mode supports following commands
EXPERIMENT NO. : -2
AIM:-Write a program to add two numbers lying at two memory locations and
display the result in accumulator.
PROGRAM:-
MOV 32H,#02H
MOV 35H,#03H
MOV A,32H
MOV R0,35H
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
ADD A,R0
THEORY:-
1. MOV 32,#02H:- This instruction is used to move the hex value ‘02’ in the memory
location 32H.
MOV 35,#03H:- This instruction is used to move the hex value ‘03’ in the memory
location 35H.
3. MOV A,32H:- This instruction is used to move the contents of memory location
32H in register A.
5. ADD A,R0
This instruction is used to add the contents of the accumlator and temporary register
bank and stored the result in accumlator.
[A][A]+[R0]
BRC
BR=960A
GO 9600
Data: [A] 02H
[R0] 03H
Result: [A] 05H
EXPERIMENT NO. : -3
AIM:-Write a program to multiply two numbers lying at two memory location and
display the result.
PROGRAM:-
MOV 32H,#02H
MOV 35H,#03H
MOV A,32H
MOV 0F0H,35H
MUL AB
THEORY:-
1. MOV 32H, #02H:- This instruction is used to move the hex value ‘02’ in to memory
location 32H.
2. MOV 35H, #03H:- This instruction is used to move the hex value ‘03’ in to memory
location 35H.
3. MOV A,32H:- This instruction is used to move the value of memory location 32H in
to the accumulator.
4. MOV 0F0H ,35H:- This instruction is used to move the value of memory location
35H in to the accumulator.
5. MUL AB:- This instruction is used to multiply the contents of the accumlator and
register B and store the result in accumlator.
[A][A].[B]
8. GO ‘Starting address’
This instruction is used to execute the stored program at memory location 9600.
PROCEDURE:-
Turn on the 8051 microcontroller kit.
Press enter .
Write A for assemble mode & select memory location.
Now enter the program.
Finally ,the program is executed using GO instruction
ASSEMBLY LANGUAGE SHEET
BRC
BR=960B
GO 9600
Data: [A] 02H
[B] 03H
Result: [A] 06H
EXPERIMENT NO 4
PROGRAM:-
PROCEDURE:-
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
accumulator
9714 MOVX @DPTR, A and store it in the first number's
place
9715 INC DPTR Move to the next memory
location
9716 Conti2 DJNZ R1,LOOP2
9718 Conti1 DJNZ R0, LOOP1 Move on to the next pass
971A Here SJMP Here
END End of program
BRC
BR=971C
GO 9700
DATA :-
9600 - 05
9601 - 03
9602 - 01
9603 - 08
9604 - 07
9605 - 06
9606 - 02
9607 - 09
9608 - 0A
9609 - 13
CONCLUSION:- Given 10 numbers are arranged in ascending order and are stored on
the given memory location.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
EXPERIMENT NO 4 (b)
PROGRAM:-
PROCEDURE:-
Turn on the 8051 microcontroller kit.
Press enter .
Write A for assemble mode & select memory location to enter the data.
Now enter the program.
Finally ,the program is executed using GO instruction
memory location
9713 MOV A, R2 Copy the second number to the
accumulator
9714 MOVX @DPTR, A and store it in the first number's
place
9715 INC DPTR Move to the next memory
location
9716 Conti2 DJNZ R1,LOOP2
9718 Conti1 DJNZ R0, LOOP1 Move on to the next pass
971A Here SJMP Here
END End of program
BRC
BR=971C
GO 9700
DATA :-
9600 - 05
9601 - 03
9602 - 01
9603 - 08
9604 - 07
9605 - 06
9606 - 02
9607 - 09
9608 - 0A
9609 - 13
CONCLUSION:- Given 10 numbers are arranged in ascending order and are stored on
the given memory location
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
EXPERIMENT NO.: 5
PROGRAM:
ORG 001BH
LJMP ISR_T1
ORG 0030H
MAIN: MOV TMOD, #10H
MOV P0, #FFH
MOV TL1, #018H
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
ISR_T1:CLR TR1
CLR P2.1
MOV R2, #4
HERE: DJNZ R2, HERE
MOV TL1, #18H
MOV TH1, #0FCH
SETB TR1
SETB P2.1
RETI
END
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
EXPERIMENT NO.: 6
PROGRAM:
delay:mov tmod,#10h
mov r6,#5h
again1:mov r3,#0ffh
again:mov tl1,#08h
mov th1,#01h
setb tr1
back: jnb tf1,back
clr tr1
clr tf1
djnz r3,again
djnz r6,again1
ret
end
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
EXPERIMENT NO. 7
AIM:- Write a program to generate a Ramp waveform using DAC with micro
controller
THEORY:-
DAC mean digital to analog converter which take digital signal and gives analog signal
as output. Here we use DAC to generate analog signal of ramp wave by microcontroller
8051 kit which will done by using DAC . we will give the input to microcontroller by
writing the program then DAC will be given the digital signal by microcontroller at its
input and it will convert it in the ramp wave which can be observed o CRO screen.
BLOCK DIAGRAM:-
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
PROCEDURE:-
Connect the DAC study card with the 8051 MC kit by 26 pin connecter as shown in
figure.
Connect the CRO at the output of DAC .
Turn on the 8051 microcontroller kit.
Now enter the program.
Give the command PIO 5 the program is executed and observe waveform will display
on kit screen and the waveform will be shown on CRO.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
EXPERIMENT NO. 8
THEORY:-
Analog-to-digital converters are among the most widely used devices for data
acquisition. Digital computers use binary (discrete) values, but in the physical world
everything is analog (continuous). ADC mean analog to digital converter which take
analog signal and gives digital signal as output. we will give the input to ADC from a
source of analog signal and write a program for microcontroller according to that the
ADC will give the digital signal at its output.
BLOCK DIAGRAM:-
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
PROCEDURE:-
Connect the ADC study card with the 8051 MC kit by 26 pin connecter as shown in
figure.
Connect the Analog Signal source at the input of ADC .
Turn on the 8051 microcontroller kit.
Now enter the program.
Give the command PIO 1 the program is executed and the digital equivalent of signal
display on kit screen.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
Experiment N0.9
AIM:- Write a program to control a stepper motor in direction, speed and number
of steps.
THEORY:-
Stepper motor rotates in the form of steps ,and the stepping action is caused
by sequential switching supply to the two phases of motor .the stepper motor is of bifilar
type with 6 leads. Each of the two phases of motor has double winding with a centre tap.
Switching the supply from one side to another of the windings can cause reversal of
magnetic polarity without actually reversing the polarity of supply.
BLOCK DIAGRAM:-
PROCEDURE:-
Connect the components as shown in figure.
Turn on the 8051 microcontroller kit.
Give the command PIO 4 the demonstration program will be executed follow the steps
which appear on screen of microcontroller kit to control the speed , direction & steps of
stepper motor.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
Experiment N0.10
THEORY:-
DC motor is used in tape recorders,VCR’s. Speed of Dc motor is directly
proportional to the DC voltage applied across it. By switching voltage applied the motor
can be turned ON/OFF. The wave form is shown here.
The motor will rotate during the ON time and will remain ideal during OFF time. By
varying the pulse width of rectangular waveform we can vary the speed of DC motor.
The direction of motor can only be change by changing the polarity of applied voltage.
PROCEDURE:-
Connect the DC motor study card with the 8051 MC kit by 50 pin connecter.
Turn on the 8051 microcontroller kit.
Enter the program and execute the program by GO command.
Now enter the direction and speed number.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
The data format is divided in two parts. First digit shows the direction of rotation
second part f data show the speed number which is directly proportional to duty cycle of
the applied voltage waveform.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
EXPERIMENT NO.: 11
Program:
(i) Interfacing with LED
ORG 0000H
LJMP MAIN
ORG 0013H
SETB P1.3
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
ORG 30H
MAIN: MOV IE, #10000100B
HERE: SJMP HERE
END
mov a,#38h
acall com
acall DELAY
mov a,#0eh
acall com
acall DELAY
mov a,#01h
acall com
acall DELAY
mov a,#06h
acall com
acall DELAY
mov a,#84h
acall com
acall DELAY
mov a,#'S'
acall dwrt
acall DELAY
mov a,#'A'
acall dwrt
acall DELAY
mov a,#'T'
acall dwrt
acall DELAY
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
mov a,#'W'
acall dwrt
acall DELAY
mov a,#'I'
acall dwrt
acall DELAY
mov a,#'N'
acall dwrt
acall DELAY
mov a,#'D'
acall dwrt
acall DELAY
again: ljmp again
Experiment No. 12
Aim: To transmit the message ‘YES’ serially at a baud rate of 9600 bps.
Apparatus: 8051 Microcontroller Kit, Serial Cable, a PC with DB-9 Port and Hyper-
terminal software installed in it.
Theory:
In serial communication, the data is sent one bit at a time and uses only two wire setup
in order to achieve a full duplex communication. Serial Communication is by far most
used way of communication and almost all the devices practically communicate serially.
8051 has got one full duplex UART (Universal Asynchronous Receiver Transmitter). It
uses TTL standard, so we need a TTL to RS232 converter. MAX232 is one such IC. It
converts TTL standard signal i.e. 0V and 5V mapped to binary 0 and binary 1,
respectively, to RS232 standard which generally use +12V and -12V to map binary 0
and binary 1, respectively.
In order to use 8051’s built in UART; we need to know a little bit about setting it up and
controlling the flow of communication.
SCON Register: SCON (Serial Control) register is use to control the UART so as to
communicate serially with other devices. It is an 8 bit register and is bit addressable.
The bits are as follow:
SM0 and SM1 are use to setup mode of the serial communication. Only mode 1 is used
these days. So, we will not consider any other mode.
SM2 is used in multiprocessor environment and is not required here, so make it 0.
REN is the receive enable bit and is used in full duplex mode. Since we are just
transmitting the data, we will clear this bit.
TB8 and RB8 are not used in mode 1, so we will make them 0 too.
TI is the transmit interrupt bit and is set by hardware thus, we will not need to set it but
we will be reading this bit to know when our data is sent successfully.
RI is Receive Interrupt. Since, we are not using receiving part, so we need not to
consider this bit. Again, this bit is set by hardware, when a byte of data is received.
SBUF Register: SBUF register is an 8 bit register and is known as serial buffer. Any
data to be transmitted serially need to be present in this register. Similarly, when a data
byte is received, it is initially present in SBUF and need to be moved to somewhere else
before the next byte overwrites it.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
Setting up BAUD Rate: The BAUD rate is known as the number of bits transferred per
second. Generally, the BAUD rate can be set arbitrarily, but, for the purpose of
standardization between different vendors manufacturing same device, a standard value
is listed. We will be using a very common value, 9600bps. In 8051, baud rate is set by
timer 1. In mode 2 of timer 1, we will initialize the value 0FDH in TH1 in order to setup
the BAUD rate equal to 9600. This is calculated as follow:
TH1 = 256 - ((Crystal / 384) / Baud), when PCON.7 bit is clear
TH1 = 256 - ((Crystal / 192) / Baud), when PCON.7 bit is set
Procedure:
Connect the PC with 8051 kit using a serial cable.
Setup Hyper-terminal to listen to the COM port on which the kit is connected. If PC has
only one port, the possible com port is COM1.
Setup the BAUD rate to 9600 and parity bit to none in Hyper-terminal.
Now enter the program in 8051 kit by pressing “A 9600” and then the assembly code.
Insert the data to the data area 9800 and so on.
Now run the program by first pressing “BRC” and then creating break point at address
of the last instruction, “BR <address>” and then pressing “GO 9600”.
On successful execution, “YES” will be displayed on the terminal window of the
Hyper-terminal program.
Precautions:
Make the connection securely and correctly.
Result: The UART of 8051 is studied and message “YES” is transmitted serially at a
baud rate of 9600 and is displayed.
Data:
Address Character ASCII Value (Hex)
9800 Y 59H
9801 E 45H
9802 S 53H
9803 0 00H
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
Program:
Address Label Mnemonic Comments
9600 MOV DPTR, #9800 DPTR pointing to first
data address
9603 Loop MOVX A, @DPTR Move the content at
address pointed by
DPTR to Accumulator
9604 JZ Done Jump if we have no
more letters left
9606 ACALL SerTx Run the subroutine to
send a byte of data
serially
9608 INC DPTR Get the address of next
data byte
9609 SJMP Loop Go back to the label
loop to transmit next
data
960B Done SJMP Done Loop here endlessly
960C SerTx MOV TMOD, #20H Set Timer 1 to Mode 2
960E MOV TH1, #0FDH Set TH1 = FDH so as to
set BAUD rate of
9600bps
9610 MOV SCON, #40H Set UART to Serial
mode 1 in transmit only
mode.
9612 SETB TR1 Start the Timer 1
9613 MOV SBUF, A Put the data to be
transmitted in the Serial
Buffer
9614 Here JNB TI, Here Loop here until the
Transmit Interrupt bit is
raised
9616 CLR TR1 Stop the Timer 1
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
TFx bit is Timer X overflow bit, so, when timer rolls from FFFFH (16 bit) or 7FFFH
(13 bit) or FFH (8 bit), to 0000H, this bit is set by hardware.
TRx bit is the Timer X run bit. It is set by program when timer needs to start. When
cleared, the timer X stops.
IEx bit is used to setup external interrupt to be addressed when a high to low edge signal
is applied at INTx Pin. This bit is not related to timer.
THx and TLx Registers: Since, 8051 has 16 bit timer, we need two 8 bit registers to
store complete 16 bit value since 8051 itself is an 8 bit microcontroller. The THx and
TLx registers are filled with some initial value and then timer is started. The timer
counts from that initial value stored in THx and TLx and counts up to 0FFFFH.
Therefore, higher the value in the THx-TLx register pair, lesser will be the time taken
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
by timer to count thus less will be the delay generated. In 8-bit auto reload mode, THx
contain the initial value and each timer the timer is overflowed, it is reloaded by this
initial value. Thus, THx work as a parallel load for TLx register as TLx register actually
counts in this mode.
Timing and Delay Calculations: 8051 takes 12 cycles to complete one machine cycle,
thus, assuming the crystal XTAL = 11.0592 MHz,
Frequency of the Timer = 11.0592 x 106 / 12 = 921.16 KHz
Delay generated in 1 Cycle = 1 / 921.16 x 103 = 1.085 μs
To find the value to be loaded in THx and TLx register:
Divide the desired time delay by 1.085 μs. Let it be n.
Perform 65536 – n. Let it be m.
Now, convert m into hexadecimal equivalent as yyxxH or 0xYYXX.
Now, TLx = xxH and THx = yyH.
Our aim is to generate 66% duty cycle. Let us take 1ms of total period. Then,
n = 1 x 10-3 / 1.085 x 10-6 = 921.16 = Round off = 922
Procedure:
Connect P3.0 Pin of the Kit with CRO.
Assemble the Program by Pressing “A 9600” and then entering the program.
SRI SUKHMANI INSTITUTE OF ENGINEERING & TECHNOLOGY DERA BASSI
DEPARTMENT: ELECTRICTRONICS AND COMMUNICATION ENGINEERING
LABORATORY MANUAL
LAB: SUBJECT CODE: SEMESTER:
HARDWARE PROGRAMME & BTEC -508 5th
INTERFACEING
Execute the program by, first clearing the break points “BRC” and then creating a
breakpoint at the address of last instruction. i.e. “BR <address>” and then pressing “GO
9600”.
See the square wave on the CRO display with a 66% of duty cycle.
Program:
Result: The timer in 8051 is studied and a square-wave signal having 66% duty cycle is
obtained and displayed on CRO.