What is the function of "#0ch" command of jhd802a LCD
Author:dvcam Time:2021-07-21 08:01 Browse(49)
Take your time!!!! You study by yourself********************************* Device description*********************************
Take your time!!!! You study by yourself********************************* Device description; Use PIC16F877A to drive LCD module.
; LCD module.

What is the function of

model: jhd802a (compatible with 1602).
; The results are as follows: abcdefgh --> bcdefgha --> cdefghab -->... --> abcdefgh.
; LCD module initialization.
according to the data provided by the manufacturer, the initialization process is as follows:
; 1 --- delay 15ms (generated by timer 0 interrupt 15 times).
; 2 --- write instruction 38h (do not detect busy signal before writing).
; 3 --- delay 5ms (generated by timer 0 interrupt 5 times).
; 4 --- write 38h instruction again (do not detect busy signal before writing).
as for why to write repeatedly, it is not clear, and it will be written again..
; 5 --- delay 5ms.
; 4 --- write 38h instruction again (do not detect busy signal before writing).
; 5 --- detect busy signal
; 6 --- write instruction 38h.
this instruction is to set the LCD display module as 8-bit data line, double line, 5x7 dot matrix display.
; 7 --- detect busy signal
; 8 --- write instruction 08h.
close the display.
; 9 --- detect busy signal
; 10 --- write instruction 01h.
display clear screen.
; Later write the control command of cursor, etc.
List P=PIC16F877.
title="LCD display"
__ CONFIG B'000010010101' ; Code protection on; WRT_ ENABLE; CPD_ ENABLE; LVP_ DISABLE; BODEN_ ENABLE.
; PWRTE_ ENABLE; WDT_ ENABLE; OSC_ XT.
#INCLUDE.
#DEFINE RS PORTE.
0.
#DEFINE RW PORTE.
1.
#DEFINE E PORTE.
2.
#DEFINE DAT PORTD CBLOCK 20H.
W_ TEMP.
STATUS_ TEMP.
FLAG.
COUNT_ 5MS ;.
COUNT_ 15MS ;.
DIS_ DELAY1.
DIS_ DELAY2.
TEMP.
COUNT.
ENDC.
FLAG_ 5MS EQU 0 ; 5ms to the flag.
flag_ 15MS EQU 1 ; 15 ms to the flag position.
when the time is less than 15 ms, the system will be set to the flag positionFLAG_ 1S EQU 2.
TMR0_ VALUE EQU 0AH ; The initial value of the register is 6.
the prescaler ratio is 1:4, and the interrupt time is 4 * (256-6)=1000US.
count_ 5MS_ VALUE EQU 5H ; Timing 5ms needs 1ms to interrupt 5 times.
count_ 15MS_ VALUE EQU 15H ; 15 interruptions in 1ms for 15ms.
dis_ DELAY_ VALUE1 EQU 0FAH.
DIS_ DELAY_ VALUE2 EQU 4HREAD_ STATE MACRO.
BCF RS.
BSF RW.
BSF E.
ENDMWRITE_ COMMAND MACRO.
BCF RS.
BCF RW.
BCF E.
ENDMWRITE_ DATA MACRO.
BSF RS.
BCF RW.
BCF E.
ENDM ORG 00H.
NOP .
GOTO MAIN.
ORG 04H.
GOTO TMRO_ INT.
TMRO_ INT.
BCF INTCON.
GIE.
MOVWF W_ TEMP.
MOVFW STATUS.
CLRF STATUS.
MOVWF STATUS_ TEMP BTFSS INTCON.
T0IE.
GOTO INT_ POP.
BTFSS INTCON.
T0IF.
GOTO INT_ POP.
MOVLW TMR0_ VALUE.
MOVWF TMR0.
.
BCF INTCON.
T0IF.
DECF COUNT_ 5MS.
1.
BTFSS STATUS.
Z.
GOTO TMR0_ INT_ 1.
BSF FLAG.
FLAG_ 5MS ; Set 5ms flag.
movlw count_ 5MS_ VALUE.
MOVWF COUNT_ 5MS.
TMR0_ INT_ 1.
DECF COUNT_ 15MS.
1.
BTFSS STATUS.
Z.
GOTO INT_ POP.
BSF FLAG.
FLAG_ 15MS ; Set the 15ms flag.
movlw count_ 15MS_ VALUE.
MOVWF COUNT_ 15MS.
.
DECF DIS_ DELAY1.
1.
BTFSS STATUS.
Z.
GOTO INT_ POP.
MOVLW DIS_ DELAY_ VALUE1.
MOVWF DIS_ DELAY1.
DECFSZ DIS_ DELAY2.
GOTO INT_ POP.
BSF FLAG.
FLAG_ 1S.
MOVLW DIS_ DELAY_ VALUE2.
MOVWF DIS_ DELAY2.
INT_ POP.
BSF INTCON.
GIE.
MOVFW STATUS_ TEMP.
MOVWF STATUS.
SWAPF W_ TEMP.
1.
SWAPF W_ TEMP.
0.
RETFIEMAIN.
CLRF PORTD.
CLRF PORTE.
BANKSEL TRISE.
CLRF TRISE.
CLRF TRISD.
MOVLW 01H.
MOVWF OPTION_ REG ; The frequency division ratio is 1:4.
movlw 06h.
movwf ADCON 1.
BCF status.
RP0.
movlw 0ah.
movwf intcon.
movlw TMR0_ VALUE.
MOVWF TMR0 ; Turn on the timer.
.
clrf flag.
movlw count_ 5MS_ VALUE.
MOVWF COUNT_ 5MS.
MOVLW COUNT_ 15MS_ VALUE.
MOVWF COUNT_ 15MS MOVLW 30H ; Display buffer: 30h-37h.
movwf FSR.
movwf 'a'
movwf indf.
incf FSR.
movlw 'B'
movwf indf.
movwf indfINCF FSR.
MOVLW 'C'.
MOVWF INDF.
INCF FSR.
MOVLW 'D'.
MOVWF INDF.
INCF FSR.
MOVLW 'E'.
MOVWF INDF.
INCF FSR.
MOVLW 'F'.
MOVWF INDF.
INCF FSR.
MOVLW 'G'.
MOVWF INDF.
INCF FSR.
MOVLW 'H'.
MOVWF INDF ; Define the table to be displayed.
NOP.
btfss flag.
flag_ 15MS.
GOTO $-1.
BCF FLAG.
FLAG_ 5MS.
MOVLW COUNT_ 5MS_ VALUE.
MOVWF COUNT_ 5MS.
WRITE_ COMMAND.
MOVLW 38H.
MOVWF DAT.
BSF E.
NOP.
BCF E.
BTFSS FLAG.
FLAG_ 5MS.
GOTO $-1.
BCF FLAG.
FLAG_ 5MS.
MOVLW COUNT_ 5MS_ VALUE.
MOVWF COUNT_ 5MS.
WRITE_ COMMAND.
MOVLW 38H.
MOVWF DAT.
BSF E.
NOP.
BCF E.
BTFSS FLAG.
FLAG_ 5MS.
GOTO $-1.
BCF FLAG.
FLAG_ 5MS.
MOVLW COUNT_ 5MS_ VALUE.
MOVWF COUNT_ 5MS .
WRITE_ COMMAND.
MOVLW 38H.
MOVWF DAT.
BSF E .
NOP.
BCF E ; Call bus corresponding to steps 1-4 of initialization; Check if the bus is busy.
check if the bus is busy.
MOVLW 38H.
CALL COMMAND_ WRITE ; Display mode setting: 16 * 2 display.
5 * 7 dot matrix, 8-bit digital interface.
movlw 08h.
call command_ WRITE ; The display is off.
the cursor is not displayed.
movlw 01h.
call command_ WRITE ; The screen is clear.
movlw 06h.
call command_ WRITE ; Move the cursor to the right.
the whole screen will not move.
movlw 0ch.
call command_ WRITE ; Display on and cursor setting.
do not display cursor.
display0.
movlw 0c0h.
call command_ WRITE ; Set the display position.
call bus.
.
movlw 8h.
movwf count.
movlw 2fH.
movwf FSR.
display1.
incf FSR.
1.
movfw indf.
1CALL DATA_ WRITE.
DECFSZ COUNT.
1.
GOTO DISPLAY1 ; Fetch data from buffer and send it to display.
BCF flag.
flag_ 1S.
MOVLW DIS_ DELAY_ VALUE1.
MOVWF DIS_ DELAY1.
MOVLW DIS_ DELAY_ VALUE2.
MOVWF DIS_ DELAY2.
BTFSS FLAG.
FLAG_ 1S ; After displaying 8 bits, delay 1 s.
goto $- 1 movlw 07h.
movwf count.
movlw 30h.
movwf FSR.
movfw indf.
movwf temp.
Display2; The display data is shifted to the left.
31h unit sends 30h, 32H unit sends 31h, 30h unit sends 37h.
incf FSR.
1.
movfw indf.
decf FSR.
1.
movwf indf.
2INCF FSR.
1.
DECFSZ COUNT.
1.
GOTO DISPLAY2.
MOVFW TEMP.
MOVWF INDF.
GOTO DISPLAY0COMMAND_ WRITE .
WRITE_ COMMAND.
MOVWF DAT.
BSF E.
NOP.
BCF E.
CALL BUSY.
RETURN.
.
BUSY .
BSF STATUS.
RP0.
MOVLW 80H.
MOVWF TRISD.
BCF STATUS.
RP0.
READ_ STATE.
NOP.
BCF E.
BTFSC DAT.
7.
GOTO BUSY.
BANKSEL TRISD.
CLRF TRISD.
BCF STATUS.
RP0.
RETURNDATA_ WRITE.
WRITE_ DATA.
MOVWF DAT.
BSF E.
NOP.
BCF E.
CALL BUSY.
RETURN.
END.
.
.
Related topics