- Back to Home »
- RS232 , Serial Communication »
- Serial communication software
Pc to lcd communication:
ORG 00H
RS EQU P3.4
RW EQU P3.5
EN EQU P3.7
DATAPORT EQU P1
MAIN:
MOV TMOD,#20H
MOV TH1,#0FDH
MOV SCON,#50H
ACALL LCD_INIT
SETB TR1 ;start timer1
ACALL SERIAL
SERIAL:
HERE2: JNB RI,HERE2 ;Wait for character to come in
MOV A,SBUF ; move recevied data into a
CLR RI
ACALL DATA_WRT
ACALL DELAY
SJMP SERIAL
LCD_INIT:
MOV A,#38H
LCALL COMND_WRT
ACALL DELAY
MOV A,#0EH
LCALL COMND_WRT
ACALL DELAY
MOV A,#01H
LCALL COMND_WRT
ACALL DELAY
MOV A,#06H
LCALL COMND_WRT
ACALL DELAY
MOV A,#80H
LCALL COMND_WRT
ACALL DELAY
;CJNE A,#8FH,AA
;;AA: MOV A,#0C0H
; LCALL COMND_WRT
; ACALL DELAY
RET
COMND_WRT:
MOV DATAPORT,A
CLR RS
CLR RW
SETB EN
ACALL DELAY
CLR EN
RET
DATA_WRT:
MOV DATAPORT,A
SETB RS
CLR RW
SETB EN
ACALL DELAY
CLR EN
RET
LCD_CLEAR:
MOV DATAPORT,#01H
ACALL COMND_WRT
RET
DELAY:
MOV R0,#0FFH
HERE1: MOV R1,#0FFH
HERE: DJNZ R1,HERE
DJNZ R0,HERE1
RET