- This topic has 0 replies, 1 voice, and was last updated 12 years, 9 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
|
Microcontroller › 8051 › JHD162A-LCD_4BitDriver-v1
EN EQU P0.3
RW EQU P0.2
RS EQU P0.1
ORG 0000H
CLR RW
SETB RW
CLR RW
CLR RS
SETB RS
CLR RS
CLR EN
SETB EN
CLR EN
MOV DPTR,#INITIALIZE_CONFIG_4bit
LCALL WRITE_COMMAND
MAIN_PROGRAM:
MOV DPTR,#DISPLAYDATA
LCALL WRITE_DATA
MOV DPTR,#CURSOR_POSITION
LCALL WRITE_COMMAND
LJMP MAIN_PROGRAM
WRITE_DATA:
SETB RS
LCALL ACCESS_DATA
MOV DPTR,#CLEAR_CODE
LCALL WRITE_COMMAND
RET
WRITE_COMMAND:
CLR RS
LCALL ACCESS_DATA
RET
ACCESS_DATA:
CLR A
MOVC A,@A+DPTR
CJNE A,#0FFH,SKIPRESET
LCALL DELAY2
RET
SKIPRESET:
LCALL WRITE_TEXT
INC DPTR
LJMP ACCESS_DATA
WRITE_TEXT: ;4BIT NIBBLE LATCHING [twice]
MOV R7,A
LCALL HIGH4BITS
LCALL LATCH_DATA
LCALL DELAY1
MOV A,R7
LCALL LOW4BITS
LCALL LATCH_DATA
LCALL DELAY1
CLR A
RET
LATCH_DATA:
SETB EN
CLR EN
RET
LOW4BITS: ;BIT BANG LSB
MOV C,ACC.3
MOV P0.7,C
MOV C,ACC.2
MOV P0.6,C
MOV C,ACC.1
MOV P0.5,C
MOV C,ACC.0
MOV P0.4,C
RET
HIGH4BITS: ;BIT BANG MSB
MOV C,ACC.7
MOV P0.7,C
MOV C,ACC.6
MOV P0.6,C
MOV C,ACC.5
MOV P0.5,C
MOV C,ACC.4
MOV P0.4,C
RET
DELAY1:
MOV R3,#01H
Divisioned_loop1:
Mov R4 , #15H
Mini_wait1:
djnz r4,Mini_wait1
djnz r3,Divisioned_loop1
RET
DELAY2:
MOV R3,#010H
Divisioned_loop2:
Mov R4 , #0FFH
Mini_wait2:
djnz r4,Mini_wait2
djnz r3,Divisioned_loop2
RET
LCD_POWERLOAD_DELAY:
MOV R3,#0FFH
Divisioned_loop3:
Mov R4 , #0FFH
Mini_wait3:
djnz r4,Mini_wait3
djnz r3,Divisioned_loop3
RET
INITIALIZE_CONFIG_4bit:
DB 028H,0CH,06H
DB 0FFH
INITIALIZE_CONFIG_8bit:
DB 038H,0CH,06H
DB 0FFH
CLEAR_CODE:
DB 01H
DB 0FFH
shift_disp_right_code:
DB 04H
DB 0FFH
shift_disp_left_code:
DB 07H
DB 0FFH
CURSOR_POSITION:
DB 080H
DB 0FFH
DISPLAYDATA:
DB ‘BLUETOOTH SCAN #’
DB 0FFH
END