3. LCD 2 X16 (Features)
Y
.
C
.
C
.
E
.
N
A
G
P
U
R
(
M
.
S
.
)
LCD Display RAM
With address
80H
81H
82H
83H
84H
85H
86H
87H
88H
89H
8AH
8BH
8CH
8DH
8EH
8FH
C0H
C1H
C2H
C3H
C4H
C5H
86H
C7H
C8H
C9H
CAH
CBH
CCH
CDH
CEH
CFH
4-Apr-20
4. LCD 2 X16 (Features)
5 x 7 dots plus cursor, 5 x 10 dots per
character 4 or 8 bit interface with MPU is
possible
Display Data RAM (DR) : 80 x 8 bit, Max 80 characters
Character Generator (CG) ROM : 160, 5 x 7 Character fonts
32, 5 x 10 Character fonts
Custom ROM codes
available
Character Generator RAM : Program write (64 x 8 bits)
8, 5 x 7 Character fonts
4, 5 x 10 Character fonts
Both Display Data RAM & CG RAM can be read by
MPU Wide variety of operating instructions :
Display Clear, Cursor
Home, Display ON / OFF, Display Cursor Blink,
Cursor shift, display shift etc.
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
4-Apr-20
5. LCD 2 X16 (Pin Description)
4-Apr-20
Signal In/Out Function
D7 – D0 I / O
8 bit data bus used for bi-directional
data
transfer between µC & LCD module
D7 – D4 I / O
These lines are used as data bus in 4
bit operation.
D7 O Can be used as Busy Flag
RS I
Register Select
0 = Instruction Register (IR)
1 = Data Register (DR)
R / W I
Signal to select Read or Write
0 = Write, 1 = Read
EN I
Enable signal to start read / write
operation
6. LCD 2 X16 (Registers)
RS R / W Operation
0 0
IR write, internal operation (Display clear,
cursor position, function set etc.)
0 1 Busy Flag (D7) & address counter (D6-D0) read
1 0 DR write, internal operation (DD RAM or CG RAM)
1 1 DR read, internal operation (DD RAM or CG RAM)
Controller for LCD has two 8 bit registers, the instruction
register (IR) and data register (DR)
IR is write only register used to store only instruction codes like
display Clear, cursor shift or address of DD RAM etc.
DR is read / write register used to store temporary data into DD
RAM or CG RAM by an internal operation of the display controller.
If BF=1, then module is performing internal operation
and next instruction will not be accepted
4-Apr-20
11. LCD instructions (8 bit instr.
code)
1. Function Set:
DL = Data Length (If DL=1, 8 bit & If DL=0, 4 bit)
N = No. of display lines (If N=0, 1 Line & If N=1, 2 Line)
F = Character Font (If F=0, 5x7 dot character font & F=1,
5x10
2. Display ON/OFF Control:
D = 0 ; Display OFF & D = 1 ; Display ON
C = 0 ; Cursor OFF & C = 1 ; Cursor ON
B = 0 ; Blink OFF & B = 1 ;
Blink ON
3. Clear Display
4. Entry Mode Set:
I/D = 1 ; Increment Mode ( Increment DD RAM address
by 1) S = 0 ; No display shift operation
5. Set DD RAM address:
Sets the address counter to the DD RAM address
AAAAAAA. Data is then written / read to from the DD
RAM.
For 2 line display module
AAAAAAA = 00H to 27H for the first line &
40H to 67H for the second line.
4-Apr-20
12. LCD instructions…
1. Function
Set
D7
0 0 1 DL N F X X
4-Apr-20
D6 D5 D4 D3 D2 D1 D0
DL: Sets interface data length
If DL = 1, data is sent or received in 8 bit length (D7 – D0).
if DL = 0, data is sent or received in 4 bit length (D7 – D4).
When 4 bit length is selected data must be sent or received
twice.
N: Sets the number of
lines If N = 0 ; 1 line
display If N = 1 ; 2 line
display
F: Sets character font
If F = 1 ; 5 x 10
dots
If F = 0 ; 5 x 7 dots
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
⯀⯀⯀⯀⯀
e.g. For 8 bit data length, 2
line display, 5 x 7 dots.
Function Set = 0011 1000 = 38H
13. LCD instructions…
2. Display ON/OFF
Control
D7
D6
D5
0 0 0 0 1 D C B
D0
D1
D2
D3
D4
D : If D = 1, display is ON. If D = 0, display is OFF
C : If C = 1, cursor is displayed. If C = 0, cursor is not
displayed. B : If B = 1, Cursor blink is ON, If B = 0, Cursor
blink is OFF.
e.g. For Display ON, Cursor display &
blinking.
Display ON = 0000 1111 = 0FH
3. Clear
Display
D7
0 0 0 0 0 0 0 1
4-Apr-20
D0
D1
D2
D3
D4
D5
D6
= 01H
Writes the space code “20H” into all addresses of DD RAM.
14. LCD instructions…
4. Entry Mode
Set
D7
0 0 0 0 0 1 I/D S
4-Apr-20
D6 D5 D4 D3 D2 D1 D0
Sets the increment / decrement and shift modes to the desired
settings.
I/D : Increments (I/D = 1) or decrements (I/D = 0) the DD RAM
address by 1 when a character code is written or read
from the DD RAM. The cursor moves to the right when
incremented by +1
S : Shift the entire display either to the right or to the left when S =
1.
If I/D = 1, shift to the right. If I/D = 0, shift to the left.
e.g. DD RAM address should be incremented, No display
shift.
Entry Mode Set = 0000 0110 = 06H
15. LCD instructions…
5. Set DD RAM Address
D7
D6
1 A A A A A A A
4-Apr-20
D5 D4 D3 D2 D1 D0
Sets the address counter to the DD RAM address AAAAAAA. Data is
then written / read to from the DD RAM.
For 2 line display module AAAAAAA = 00H to 27H for the first line &
40H to 67H for the second line.
e.g. To display characters in the first line
Set DD RAM address = 1000 0000 = 80H
e.g. To display characters in the second
line
Set DD RAM address = 1100 0000 = C0H
16. Summary of LCD instructions
Instruction RS R/W D7 D6 D5 D4 D3 D2 D1 D0
Function Set 0 0 0 0 1 DL N F X X
Display ON/OFF 0 0 0 0 0 0 1 D C B
Clear Display 0 0 0 0 0 0 0 0 0 1
Entry Mode Set 0 0 0 0 0 0 0 1 I/D S
Set DD RAM
address
0 0 1 A A A A A A A
Write data to
DD RAM
1 0 Write data
Read data
from DD RAM
1 1 Read data
4-Apr-20
18. Initialization Flowchart
Send Function Set to IR ; Initialize LCD
; Send Function
Set
; instruction 3
times
; wait for 5 msec
;Send Function Set
instruction
; wait for 5 msec
Wait for more than 4.1
msec
Send Function Set to IR
Send Function Set to IR ;Send Function Set
Instruction
; Read & Check Busy Flag
Wait for 100 usec
D7 1
4-Apr-20
19. Initialization Flowchart …
Send Function Set to IR
D7 1
Send Display OFF to IR
; ;Send Function Set
Instruction
; Check busy flag (D7=0)
; Display OFF
instruction
; Check busy flag
(D7=0)
; Clear Display
Instruction
; Check busy flag (D7=0)
D7 1
Send Clear Display to IR
D7 1
4-Apr-20
20. Initialization Flowchart …
Send Entry Mode to IR
D7 1
Send Display ON to
IR
; ;Send Entry Mode
Instruction
; Check busy flag (D7=0)
; Display ON instruction
; Check busy flag
(D7=0)
; Initialization Done
; Send Display RAM
Address
; and data
D7 1
Initialization is
Complete Display
is Ready
4-Apr-20
21. Check Busy Flag OR Delay
D7 1
Send Instruction to IR
;Before sending instruction /
Command you can check
Busy Flag Status (D7=0)
Send Instruction to IR
4-Apr-20
;Before sending instruction /
Command you can give delay
of 5 msec
OR
Delay of 5 msec
23. LCD Program #1
Interface 2X16 LCD with 8051.Use 8 bit data length and write
program to display “Y” in first line. Use P2 for data pins and P0
for control pins
P2.7
P2.6
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
P0.5
P0.6
P0.7
8051
15(BL)
14(D7)
13(D6)
12(D5)
11(D4)
10(D3)
9(D2)
8(D1)
7(D0)
6(EN)
5(R/W)
4(RS)
3(CONT)
2(VCC)
1(GND)
+ 5V
+ 5V
1K
IR
DR
LCD
4-Apr-20
24. LCD instructions Setting
1. Function
Set
D7
0 0 1 DL N F X X
D6 D5 D4 D3 D2 D1 D0
DL = 1
N = 1
F = 0
; data is sent or received in 8 bit length (D7 –
D0).
; 2 line display
; 5 x 7 dots
Function Set = 38H
0 0 1 1 1 0 0 0
4-Apr-20
25. LCD instructions Setting
2. Display ON/OFF
Control
D7
D6
D5
D0
D1
D2
D3
D4
0 0 0 0 1 D C B
D = 1 ;display is ON
C = 1 ;cursor is
displayed B = 1 ;Cursor
blink
Display ON Control = 0FH
3. Clear
Display
D7
0 0 0 0 0 0 0 1
D0
D1
D2
D3
D4
D5
D6
= 01H
0 0 0 0 1 1 1 1
Display OFF Control = 08H
0 0 0 0 1 0 0 0
4-Apr-20
26. LCD instructions Setting
4. Entry Mode
Set
D7
0 0 0 0 0 1 I/D S
D6 D5 D4 D3 D2 D1 D0
I/D =
1
;Increments the DD RAM address by 1 when a character
code is
;written or read from the DD RAM.
;The cursor moves to the right when incremented by +1
S = 0 ; No display shift
Entry Mode Set = 06H
0 0 0 0 0 1 1 0
4-Apr-20
27. LCD instructions Setting
4-Apr-20
80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
5. DD RAM Address
DD
RAM
Addr
ess
Y
LCD
displa
y
e.g. To display characters in the first line, first
position
Set DD RAM address = 1000 0000 = 80H
28. Flowchart
Send 38H to IR ; Initialize LCD
; Send Function
Set
; instruction 3
times
; wait for 5 msec
;Send Function Set
instruction
; wait for 5 msec
Wait for more than 4.1
msec
Send 38H to IR
Send 38H to IR ;Send Function Set
Instruction
; Read & Check Busy Flag
Wait for 100 usec
D7 1
4-Apr-20
29. Flowchart …
Send 38H to IR
D7 1
Send 08H to
IR
; ;Send Function Set
Instruction
; Check busy flag
(D7=0)
; Display OFF
instruction
; Check busy flag
(D7=0)
; Clear Display
Instruction
; Check busy flag
(D7=0)
D7 1
Send 01H to IR
D7 1
4-Apr-20
30. Flowchart …
Send 06 H to IR
D7 1
Send 0FH to IR
; ;Send Entry Mode
Instruction
; Check busy flag (D7=0)
; Display ON instruction
; Check busy flag
(D7=0)
; Initialization Done
; Send Display RAM
Address
; and data
D7 1
Initialization is
Complete Display
is Ready
4-Apr-20
31. Flowchart…
D7
; Check busy flag
(D7=0)
1
Send 80H to IR
; DD RAM Address
: First Line, first
position
D7
; Check busy flag
(D7=0)
1
Send „Y” to DR ; ASCII CODE OF „Y‟
STOP
4-Apr-20
32. Program #1
4-Apr-20
MOV A, #38H
ACALL COMM
ACALL delay_5ms
MOV A, #38H
ACALL COMM
ACALL delay_5ms
MOV A, #38H
ACALL COMM
ACALL delay_5ms
ACALL CHK_BUSY
MOV A, #38H
ACALL COMM
ACALL CHK_BUSY
MOV A, #08H
ACALL COMM
ACALL CHK_BUSY
MOV A, #01H
ACALL COMM
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Check Busy Flag (D7 =0) then send
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Display OFF (0000 1 D C B)
; Clear
Display
33. Program #1 …
4-Apr-20
ACALL CHK_BUSY
MOV A, #06H
ACALL COMM
ACALL CHK_BUSY
MOV A, #0FH
ACALL COMM
ACALL CHK_BUSY
MOV A, #80H
ACALL COMM
ACALL CHK_BUSY
MOV A, #’Y’
ACALL DISP
L1: SJMP L1
; Entry mode: increment (0000 01 I/D
S)
; Display ON (0000 1 D C B), CURSOR BLINK
; DD RAM Address (First Line, first
position)
; ASCII CODE OF „Y‟
; Subroutine to send data to
DR
; Terminate Program
34. Sub Programs #1
4-Apr-20
; Subroutine to check Busy Flag
CHK_BUSY: CLR P0.7 ; RS= 0, Register select (Instruction
Register) SETB P0.6 ; RW=1, READ IR
MOV A, P2 ; Read Data from IR
(D7=Busy Flag) (D7=1, Busy)
BUSY: JB ACC.7, BUSY
RET
; Check Busy Flag
status
; Busy Flag = 0
; Subroutine to send data to IR (Instruction Register)
; EN=0
; RS= 0, Register select (IR)
; RW=0, WRITE
; Send Data to IR
; EN=1
COMM: CLR P0.5
CLR P0.7
CLR P0.6
MOV P2, A
SETB P0.5
NOP
NOP
NOP
CLR
P0.5 RET
; EN=0
35. Sub Programs #1…
4-Apr-20
; Subroutine to send data to DR (Data Register)
DISP: ; EN=0
; RS= 1, Register select (DR)
; RW=0, WRITE
; Send Data to DR
; EN=1
CLR P0.5
SETB P0.7
CLR P0.6
MOV P2, A
SETB P0.5
NOP
NOP
NOP
CLR P0.5
RET
; EN=0
; Subroutine for Delay of 5 msec
delay_5ms: MOV R0, #0AH
L2: MOV R1, #0FEH
L3: DJNZ R1, L3
DJNZ R0, L2
RET
; N = 10
; N = 254
; Decrement R1& JNZ
; Decrement R0& JNZ
36. LCD Program #2
Interface 2X16 LCD with 8051.Use 8 bit data length and write
program to display “HELLO” in first line. Use P2 for data pins
and P0 for control pins
P2.7
P2.6
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
P0.5
P0.6
P0.7
8051
15(BL)
14(D7)
13(D6)
12(D5)
11(D4)
10(D3)
9(D2)
8(D1)
7(D0)
6(EN)
5(R/W)
4(RS)
3(CONT)
2(VCC)
1(GND)
+ 5V
+ 5V
1K
IR
DR
LCD
4-Apr-20
37. LCD instructions Setting
4-Apr-20
80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
DD RAM Address
DD
RAM
Addr
ess
H E L L O
LCD
displa
y
e.g. To display characters in the first line, first
position
Set DD RAM address = 1000 0000 = 80H
38. Flowchart
Send 38H to IR ; Initialize LCD
; Send Function
Set
; instruction 3
times
; wait for 5 msec
;Send Function Set
instruction
; wait for 5 msec
Wait for more than 4.1
msec
Send 38H to IR
Send 38H to IR ;Send Function Set
Instruction
; Read & Check Busy Flag
Wait for 100 usec
D7 1
4-Apr-20
39. Flowchart …
Send 38H to IR
D7 1
Send 08H to
IR
; ;Send Function Set
Instruction
; Check busy flag
(D7=0)
; Display OFF
instruction
; Check busy flag
(D7=0)
; Clear Display
Instruction
; Check busy flag
(D7=0)
D7 1
Send 01H to IR
D7 1
4-Apr-20
40. Flowchart …
Send 06 H to IR
D7 1
Send 0FH to IR
; ;Send Entry Mode
Instruction
; Check busy flag (D7=0)
; Display ON instruction
; Check busy flag
(D7=0)
; Initialization Done
; Send Display RAM
Address
; and data
D7 1
Initialization is
Complete Display
is Ready
4-Apr-20
41. Flowchart…
D7
; Check busy flag
(D7=0)
1
Send 80H to IR
; DD RAM Address
: First Line, first
position
D7
; Check busy flag
(D7=0)
1
Send „H” to DR ; ASCII CODE OF „H‟
Send „E” to DR ; ASCII CODE OF „E‟
4-Apr-20
42. Flowchart…
Send „L” to DR ; ASCII CODE OF „L‟
Send „O” to DR ; ASCII CODE OF „O‟
Send „L” to DR ; ASCII CODE OF „L‟
STOP
4-Apr-20
43. Program #2
4-Apr-20
MOV A, #38H
ACALL COMM
ACALL delay_5ms
MOV A, #38H
ACALL COMM
ACALL delay_5ms
MOV A, #38H
ACALL COMM
ACALL delay_5ms
ACALL CHK_BUSY
MOV A, #38H
ACALL COMM
ACALL CHK_BUSY
MOV A, #08H
ACALL COMM
ACALL CHK_BUSY
MOV A, #01H
ACALL COMM
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Check Busy Flag (D7 =0) then send
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Display OFF (0000 1 D C B)
; Clear
Display
44. Program #2
4-Apr-20
ACALL CHK_BUSY
MOV A, #06H
ACALL COMM
ACALL CHK_BUSY
MOV A, #0FH
ACALL COMM
ACALL CHK_BUSY
MOV A, #80H
ACALL COMM
; Entry mode: increment (0000 01 I/D
S)
; Display ON (0000 1 D C B), CURSOR BLINK
; DD RAM Address (First Line, first
position)
ACALL CHK_BUSY
MOV A, #’H’
ACALL DISP
MOV A, #’E’
ACALL DISP
MOV A, #’L’
ACALL DISP
MOV A, #’L’
ACALL DISP
MOV A, #’O‟
ACALL DISP
L1: SJMP L1
; ASCII CODE OF „H‟
; Subroutine to send data to
DR
; ASCII CODE OF „E‟
; Subroutine to send data to
DR
; ASCII CODE OF „L‟
; Subroutine to send data to
DR
; ASCII CODE OF „L‟
; Subroutine to send data to
DR
; ASCII CODE OF „O‟
45. Sub Programs #2
4-Apr-20
; Subroutine to check Busy Flag
CHK_BUSY: CLR P0.7 ; RS= 0, Register select (Instruction
Register) SETB P0.6 ; RW=1, READ IR
MOV A, P2 ; Read Data from IR
(D7=Busy Flag) (D7=1, Busy)
BUSY: JB ACC.7, BUSY
RET
; Check Busy Flag
status
; Busy Flag = 0
; Subroutine to send data to IR (Instruction Register)
; EN=0
; RS= 0, Register select (IR)
; RW=0, WRITE
; Send Data to IR
; EN=1
COMM: CLR P0.5
CLR P0.7
CLR P0.6
MOV P2, A
SETB P0.5
NOP
NOP
NOP
CLR
P0.5 RET
; EN=0
46. Sub Programs #2
4-Apr-20
; Subroutine to send data to DR (Data Register)
DISP: ; EN=0
; RS= 1, Register select (DR)
; RW=0, WRITE
; Send Data to DR
; EN=1
CLR P0.5
SETB P0.7
CLR P0.6
MOV P2, A
SETB P0.5
NOP
NOP
NOP
CLR P0.5
RET
; EN=0
; Subroutine for Delay of 5 msec
delay_5ms: MOV R0, #0AH
L2: MOV R1, #0FEH
L3: DJNZ R1, L3
DJNZ R0, L2
RET
; N = 10
; N = 254
; Decrement R1& JNZ
; Decrement R0& JNZ
47. LCD Program #3
Interface 2X16 LCD with 8051.Use 8 bit data length and write
program to display “WELCOME” in first line. Use P2 for data pins and P0
for control pins
P2.7
P2.6
P2.5
P2.4
P2.3
P2.2
P2.1
P2.0
P0.5
P0.6
P0.7
8051
15(BL)
14(D7)
13(D6)
12(D5)
11(D4)
10(D3)
9(D2)
8(D1)
7(D0)
6(EN)
5(R/W)
4(RS)
3(CONT)
2(VCC)
1(GND)
+ 5V
+ 5V
1K
IR
DR
LCD
4-Apr-20
48. LCD display
4-Apr-20
80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
DD RAM Address
DD
RAM
Addr
ess
W E L C O M E
LCD
displa
y
e.g. To display characters in the first line, first
position
Set DD RAM address = 1000 0000 = 80H
50. LCD Program #3 …
Data Transfer Logic
; Initialise Base Address,
; Index, Counter
; Transfer index to ACC
; Use MOVC to read data
; Send data to Display RAM
; Increment index for nest Char
;Decrement the Counter and
;repeat till Counter is 0
DPTR = 0200H Base address
R5 = 00 index, R6 = 7 counter,
MOV A, R5
MOVC A, @A + DPTR
Send Data of A to DR
INC R5
DEC R6 & Repeat if R6 not
0
4-Apr-20
51. Program #3
4-Apr-20
MOV A, #38H
ACALL COMM
ACALL delay_5ms
MOV A, #38H
ACALL COMM
ACALL delay_5ms
MOV A, #38H
ACALL COMM
ACALL delay_5ms
ACALL CHK_BUSY
MOV A, #38H
ACALL COMM
ACALL CHK_BUSY
MOV A, #08H
ACALL COMM
ACALL CHK_BUSY
MOV A, #01H
ACALL COMM
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Check Busy Flag (D7 =0) then send
; Function Set : 0011 NFXX, N=1: 2Line, F=0: 5x7
font
; Display OFF (0000 1 D C B)
; Clear
Display
52. Program #3
4-Apr-20
ACALL CHK_BUSY
MOV DPTR, #0200H ; Base address of Look up table
MOV R5, #00H ; Index first element of message string
MOV R6, #07H ; R6 is counter for 7 characters to
display
L4: MOV A, R5 ; Index
MOVC A, @A+DPTR ; Get ASCII code of character in ACC
ACALL DISP ; Subroutine to send data to DR
INC R5 ; Increment Index
DJNZ R6, L4 ; Decrement Counter
L5: SJMP L5 ; Terminate the Program
ORG 0200H
DB „WELCOME‟
ACALL CHK_BUSY
MOV A, #06H
ACALL COMM
ACALL CHK_BUSY
MOV A, #0FH
ACALL COMM
ACALL CHK_BUSY
MOV A, #80H
ACALL COMM
; Entry mode: increment (0000 01 I/D
S)
; Display ON (0000 1 D C B), CURSOR BLINK
; DD RAM Address (First Line, first
position)
53. Sub Programs #3
4-Apr-20
; Subroutine to check Busy Flag
CHK_BUSY: CLR P0.7 ; RS= 0, Register select (Instruction
Register) SETB P0.6 ; RW=1, READ IR
MOV A, P2 ; Read Data from IR
(D7=Busy Flag) (D7=1, Busy)
BUSY: JB ACC.7, BUSY
RET
; Check Busy Flag
status
; Busy Flag = 0
; Subroutine to send data to IR (Instruction Register)
; EN=0
; RS= 0, Register select (IR)
; RW=0, WRITE
; Send Data to IR
; EN=1
COMM: CLR P0.5
CLR P0.7
CLR P0.6
MOV P2, A
SETB P0.5
NOP
NOP
NOP
CLR
P0.5 RET
; EN=0
54. Sub Programs #3
4-Apr-20 ptkarule@ycce.edu
; Subroutine to send data to DR (Data Register)
DISP: ; EN=0
; RS= 1, Register select (DR)
; RW=0, WRITE
; Send Data to DR
; EN=1
CLR P0.5
SETB P0.7
CLR P0.6
MOV P2, A
SETB P0.5
NOP
NOP
NOP
CLR P0.5
RET
; EN=0
; Subroutine for Delay of 5 msec
delay_5ms: MOV R0, #0AH
L2: MOV R1, #0FEH
L3: DJNZ R1, L3
DJNZ R0, L2
RET
; N = 10
; N = 254
; Decrement R1& JNZ
; Decrement R0& JNZ