Вы находитесь на странице: 1из 11

MICROPROCESSOR INTERFACING &

PROGRAMMING
(EL-303)

LABORATORY MANUAL

Lab # 09: To Illustrate the Commands and Data Mode of


an LCD Interfaced with a Microcontroller
Student Name: Ammar khalid , umar shahfique

Roll No: 17f8413 ,17f8373 Group No:11_ Section: B

Date performed: 31,oct, 2019

CLO MARKS OBTAINED


1
3

Lab Engineer Signature:_________________

_________________________________________________________________________________________________________________________________________________________

NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES, CHINIOT- FAISALABAD


MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

EVALUATION RUBRIC:
EL303 – MICROPROCESSOR INTERFACING AND PROGRAMMING LAB
To enable the students to write effective assembly language programs using various addressing modes,
jumps, timers, counters, and interrupts. Also enabling them to interface any external hardware using
serial programming and verifying the results either through simulators or through actual hardware.

CLO Statement ↓ Exemplary (5) Proficient (4) Developing (3) Beginning (2) Novice
Score → (1)

Behaves
responsibly within Takes ownership Actively works Partially work Needs help from Does not
and Works and participates and participate in others group to work
team, and perform
actively in group group complete
1 the experiment throughout the discussions. discussions assigned task
safely. lab

Design and
development of a
microcontroller- Correctly With minor With major Partially Does not
based system to develops the mistakes mistakes develops the work
3 solve an microcontroller- develops the develops the microcontroller-
based system microcontroller- microcontroller- based system
engineering
based system based system
problem.

___________________________________________________________________________________________
Page 2 of 11
MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

Lab #09: To Illustrate the Commands and Data Mode of an LCD


Interfaced with a Microcontroller
PURPOSE:

 To be able to interface a 2-Lines 16-Characters LCD with 89C52

EQUIPMENT REQUIRED:

1. KeilμVision IDE
2. ATMEL ®89C52 Microcontroller Kit
3. XELTEX Universal Burner
4. LCD

9.1 BACKGROUND:

The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or
other which are compatible with HD44580. In this experiment, we will discuss about character
based LCDs, their interfacing with 8051 microcontrollers. The most commonly used LCDs found
in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support
at most of 80 characters, whereas LCDs supporting more than 80 characters make use of 2
HD44780 controllers. Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has
16 Pins (two pins are extra in both for back-light LED connections). Pin description is shown in
the table below.
Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its
extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM (DDRAM) that
is not used for display can be used as general data RAM. So whatever you send on the DDRAM
is actually displayed on the LCD. For LCDs like 1x16, only 16 characters are visible, so whatever
you write after 16 characters is written in DDRAM but is not visible to the user.

___________________________________________________________________________________________
Page 3 of 11
MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

___________________________________________________________________________________________
Page 4 of 11
MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

9.2 EXERCISES:

Task1:

Write a program that counts how many times a character has occurred in a string. The user will mention
ASCII code of the character in R0 and your program should display the count on 2-Lines 16-Characters
LCD.
Example#1:
If the user has mentioned ASCII code for an alphabet ‘a’ and the string is:

“A sentence is a group of words that makes complete sense, contains a main verb, and begins
with a capital letter.”

The 2-Lines X 16 Characters LCD display will be:

ORG 0H
MOV R7,#0H
MOV A,#38H
ACALL COMNWRT ;call command subroutine
ACALL DELAY ;give LCD some time
MOV A,#0EH
ACALL COMNWRT
ACALL DELAY
MOV A,#01H
ACALL COMNWRT
ACALL DELAY
MOV DPTR,#MYDATA
UP: CLR A
MOVC A,@A+DPTR
ACALL DAT
ACALL DELAY
INC DPTR
JZ NEXT
SJMP UP
NEXT:
MOV P1,#01H
ACALL COMNWRT
ACALL DELAY
MOV P2,#1H

___________________________________________________________________________________________
Page 5 of 11
MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

MOV DPTR,#MYDATA2
CLR A
AGAIN: MOVC A,@A+DPTR
INC DPTR
JZ N2
CJNE A,#61H,N2
INC R7
N2:
INC DPTR
JZ DO
SJMP UP
DO:
MOV A,#0C0H
ACALL COMNWRT
ACALL DELAY
MOV A ,R7
MOV B,#10H
MOV R6,30H
DIV AB
ORL A,R6
MOV R1,A
MOV A,B
ORL A,R6
MOV R2,A
MOV A,R7
MOV A,R1
MOV P1,A
ACALL DAT
ACALL DELAY
SJMP $
COMNWRT:
MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
DAT:
MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY

___________________________________________________________________________________________
Page 6 of 11
MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

CLR P2.2
RET
DELAY:
MOV R3,#50
HERE2:MOV R4,#255
HERE:DJNZ R4,HERE
DJNZ R3 , HERE2
RET
MYDATA:
DB "COUNT IS ", 0
ACALL DELAY
ORG 100H
MYDATA2:
DB "A sentence is a group of words that makes complete sense, contains a
main verb, and begins with a capital letter",0
END

LCD1
LM016L

U1
19 39
XTAL1 P0.0/AD0
38
P0.1/AD1
37
P0.2/AD2
18 36
XTAL2 P0.3/AD3
35
P0.4/AD4
VDD
VSS

VEE

34
RW
RS

D0
D1
D2
D3
D4
D5
D6
D7

P0.5/AD5
E

33
P0.6/AD6
9 32
RST P0.7/AD7
1
2
3

4
5
6

7
8
9
10
11
12
13
14

21
P2.0/A8
22
P2.1/A9
23
P2.2/A10
29 24
PSEN P2.3/A11
30 25
ALE P2.4/A12
31 26
EA P2.5/A13
27
P2.6/A14
28
P2.7/A15
1 10
P1.0 P3.0/RXD
2 11
P1.1 P3.1/TXD
3 12
P1.2 P3.2/INT0
4 13
P1.3 P3.3/INT1
5 14
P1.4 P3.4/T0
6 15
P1.5 P3.5/T1
7 16
P1.6 P3.6/WR
8 17
P1.7 P3.7/RD
AT89C51

Attach the code in the manual

___________________________________________________________________________________________
Page 7 of 11
MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

9.3 POST LAB:

Modify code written for in-lab task such that it checks whether the mentioned ASCII is for an alphabet
(upper case or lower case) or not.
Example:
If the user has mentioned ASCII code for ‘.’ and the string is:

“Examples in the section above all show well-formed sentences. The examples in the section
above all show well-formed sentences.”

The 2-Lines 16-Characters LCD display will be:

Attach the code in the manual

ORG 0H
MOV R7 ,#68
MOV R5,#0H
MOV A,#38H
ACALL COMMANDWRT
ACALL DELAY
MOV A,#0FH
ACALL COMMANDWRT
ACALL DELAY
MOV A,#01H
ACALL COMMANDWRT
ACALL DELAY
MOV A,#80H
ACALL COMMANDWRT
ACALL DELAY
ACALL DISPLAY
ACALL DELAY
NO:SJMP $
// FOR LOWERCASE
DISPLAY:
MOV B,R7
MOV 30H,#25
MOV A,#97
OVER:CJNE A,B,JUMP

___________________________________________________________________________________________
Page 8 of 11
MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

ACALL DISP2
SJMP NO
JUMP:INC A
DJNZ 30H,OVER
;FOR LOWERCASE
MOV B,R7
MOV 30H,#25
MOV A,#61H
OVERR:CJNE A,B,JUMPP
ACALL DISP2
SJMP NO
JUMPP:INC A
DJNZ 30H,OVERR
//FOR UPPERCASE
MOV B,R7
MOV 30H,#25
MOV A,#65
OVER1:CJNE A,B,JUP
ACALL DISP1
SJMP NO
JUP:INC A
DJNZ 30H,OVER1
//FOR UPPERCASE
MOV B,R7
MOV 30H,#25
MOV A,#41H
OVER11:CJNE A,B,JUMPPP
ACALL DISP1
SJMP NO
JUMPPP:INC A
DJNZ 30H,OVER11
ACALL DISP3
SJMP NO
RET
DISP1:
MOV DPTR,#MYDATA1
UP:CLR A
MOVC A,@A+DPTR
ACALL DATAWRT
ACALL DELAY
INC DPTR
JZ DO_NOTHING1

DO_NOTHING1:

___________________________________________________________________________________________
Page 9 of 11
MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

RET
DISP2:
MOV DPTR,#MYDATA2
UP2:CLR A
MOVC A,@A+DPTR
ACALL DATAWRT
ACALL DELAY
INC DPTR
JZ DO_NOTHING2
SJMP UP2
DO_NOTHING2:
RET
DISP3:
MOV DPTR,#MYDATA3
UP3:CLR A
MOVC A,@A+DPTR
ACALL DATAWRT
ACALL DELAY
INC DPTR
JZ DO_NOTHING3aa
SJMP UP3
DO_NOTHING3:
RET
COMMANDWRT:
MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
DATAWRT:
MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
DELAY:
MOV R3,#50
HERE2:MOV R4,#255
HERE: DJNZ R4,HERE
DJNZ R3,HERE2

___________________________________________________________________________________________
Page 10 of 11
MIP Lab National University Roll No: __________

Lab #
(EL303)
of Computer and Emerging Sciences
Chiniot-Faisalabad Fall 2019
09
_________________________________________________________________________________

RET
MYDATA1:DB"IT IS UPPERCASE",0
MYDATA2:DB"IT IS LOWERCASE",0
MYDATA3:DB"IT IS NOT ALPHABET",0
DB "A sentence is a group of words that makes complete sense,
contains a main verb, and begins with a capital letter",0
END

LCD1
LM016L

U1
19 39
XTAL1 P0.0/AD0
38
P0.1/AD1
37
P0.2/AD2
18 36
XTAL2 P0.3/AD3
35
P0.4/AD4
VDD
VSS

VEE

34
RW
RS

D0
D1
D2
D3
D4
D5
D6
D7

P0.5/AD5
E

33
P0.6/AD6
9 32
RST P0.7/AD7
1
2
3

4
5
6

7
8
9
10
11
12
13
14

21
P2.0/A8
22
P2.1/A9
23
P2.2/A10
29 24
PSEN P2.3/A11
30 25
ALE P2.4/A12
31 26
EA P2.5/A13
27
P2.6/A14
28
P2.7/A15
1 10
P1.0 P3.0/RXD
2 11
P1.1 P3.1/TXD
3 12
P1.2 P3.2/INT0
4 13
P1.3 P3.3/INT1
5 14
P1.4 P3.4/T0
6 15
P1.5 P3.5/T1
7 16
P1.6 P3.6/WR
8 17
P1.7 P3.7/RD
AT89C51

___________________________________________________________________________________________
Page 11 of 11

Вам также может понравиться