1602 LCD screen driver source program 2

Publisher:BlissfulSpiritLatest update time:2011-02-27 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere



;lcd display program
RS BIT P2.6
R_W BIT P2.5
ENABLE BIT P2.7
LCDDATA DATA P1


;******************************************

ORG 0000H
AJMP MAIN
;ORG 000BH
;AJMP INSERS

ORG 0050H
MAIN:
;MOV TMOD,#00H
;MOV TL0,#00H
;MOV TH0,#00H
;SETB EA
;SETB ET0
;SETB TR0
;MOV R5,#50
;CLR P3.2
;SETB P3.1


MOV SP,#60H
START:
LCALL INITIAL
MOV A,#10000000B
LCALL WRITE_INSTRUCTION
MOV DPTR,#TAB
LCALL KEY
MOVC A,@A+DPTR
LCALL WRITELCDDATA
AJMP START

;INSERS:
;MOV TL0,#00H
;MOV TH0,#00H
;DJNZ R5,L0
;MOV R5,#50
;CPL P3.2
;CPL P3.1
;L0:
;RETI

INITIAL:
MOV A,#00111000B
LCALL WRITE_INSTRUCTION
MOV A,#00001110B
LCALL WRITE_INSTRUCTION
MOV A,#00000110B
LCALL WRITE_INSTRUCTION
RET

CHECKBUSY:
PUSH ACC
CHECKBUSYLOOP:
CLR ENABLE
SETB R_W
CLR RS
SETB ENABLE
MOV A,LCDDATA
CLR ENABLE
JB ACC.7,CHECKBUSYLOOP
POP ACC
LCALL DELAY1
RET

WRITE_INSTRUCTION:
LCALL CHECKBUSY
CLR ENABLE
CLR R_W
CLR RS
SETB ENABLE
MOV LCDDATA,A
CLR ENABLE
RET

WRITELCDDATA:
LCALL CHECKBUSY
CLR ENABLE
CLR R_W
SETB RS
SETB ENABLE
MOV LCDDATA,A
CLR ENABLE
RET




DELAY1:
MOV R5,#05H
L4:
MOV R6,#0F8H
L5:
DJNZ R6,L5
DJNZ R5,L4
RET

KEY: LCALL KS
JNZ K1
LCALL DELAY2
AJMP KEY
K1: LCALL DELAY2
LCALL DELAY2
LCALL KS
JNZ K2
AJMP KEY
K2: MOV R2,#0DFH
MOV R4,#00H
K3: MOV P3,R2
L6: JB P3.0,L1
MOV A,#00H
AJMP LK
L1: JB P3.1,L2
MOV A,#03H
AJMP LK
L2: JB P3.2,L3
MOV A,#06H
AJMP LK
L3: JB P3.3,NEXT
MOV A,#09H
LK: ADD A,R4
PUSH ACC
K4: LCALL DELAY2
LCALL KS
JNZ K4
POP ACC
RET

NEXT:
INC R4
MOV A,R2
JNB ACC.7,KEY
RL A
MOV R2,A
AJMP K3
KS: MOV P3,#0FH
MOV A,P3
XRL A,#0FH
RET
DELAY2:
MOV R5,#4AH
L7: MOV R6,#0FAH
L8: DJNZ R6,L8
DJNZ R5,L7
RET
TAB:DB 31H,32H,33H,34H,35H,36H,37H,38H,39H
DB 41H,30H,42H
END

Reference address:1602 LCD screen driver source program 2

Previous article:1602 LCD screen driver source program 1
Next article:Design of low-cost data acquisition device based on C8051F340

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号