#include <sfr51.inc>
; pin p0.0 is mode button
; pin p0.1 is exit button
; pin p1 -> data
; pin p2.0 -> rs pin
; pin p2.1 -> r/w pin
; pin p2.2 > enable pin-
Flag BIT PSW.1 ; genearl purpose bit ..
ORG 0000H
Main: clr Flag
Test_But:
jnb p0.0, Test_But
acall Delay_20
jnb p0.0, Test_But
jb Flag, Next1
acall Display1
setb Flag ; next time - goto display2 ..
sjmp But_Rel
Next1:
acall Display2
clr Flag
But_Rel:
jb p0.0, But_Rel; check if button is released ..
sjmp Test_But
; = = s u b s = = = =
send: MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
CLR P2.2
RET
; = = = = = =
display: MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
CLR P2.2
RET
; = = = = = =
initlcd: mov a,#38h
acall send
acall delay
mov a,#0Eh
acall send
acall delay
mov a,#01h
acall send
acall delay
ret
; = = = = = =
display1: acall initlcd
mov a,#'M'
acall display
acall delay
mov a,#'O'
acall display
acall delay
mov a,#'D'
acall display
acall delay
mov a,#'E'
acall display
acall delay
mov a,#'2'
acall display
acall delay
ret
; = = = = = =
display2: acall initlcd
mov a,#'M'
acall display
acall delay
mov a,#'O'
acall display
acall delay
mov a,#'D'
acall display
acall delay
mov a,#'E'
acall display
acall delay
mov a,#'1'
acall display
acall delay
ret
; = = = = = =
delay: MOV R3,#100
HERE1: MOV R4,#255
HERE2: DJNZ R4,HERE2
DJNZ R3,HERE1
RET
;----------------------20ms delay---------------------------------------
Delay_20: PUSH 00h
PUSH 01h
MOV R0, #30
Delay_20_Loop1: MOV R1, #255
Delay_20_Loop2: DJNZ R1, Delay_20_Loop2
DJNZ R0, Delay_20_Loop1
POP 01h
POP 00h
RET
END