LCD驅動HT1621的PIC單片機源代碼
STATUS EQU 3H
FSR EQU 4H
RB EQU 6H
RC EQU 7H
OPTIONA EQU 81H
TRISB EQU 86H
TRISC EQU 87H
GENR0 EQU 053H
GENR1 EQU 054H
WD_RG EQU 055H
DA_AG0 EQU 056H ;SEG0 SEG1
DA_AG8 EQU 05EH ;SEG16 SEG17
;.............................
C EQU 0
Z EQU 2
RP0 EQU 5
RP1 EQU 6
CS EQU 2
WDA EQU 5 ;RC,5數(shù)據(jù)線
WCLK EQU 1 ;RB,1寫時鐘線
RCLK EQU 4 ;RB,4讀時鐘線
;..............................
ORG 0H
GOTO START
;...............................
START BSF STATUS,RP0
MOVLW 00H
MOVWF TRISB
MOVLW 81H
MOVWF TRISC
BCF STATUS,RP0
MOVLW 12H
MOVWF RB
BSF RC,2
BSF RC,5
MOVLW 4
MOVWF OPTIONA
LOOP NOP
CALL X_QUAN
NOP
GOTO LOOP
;............................
X_QUAN
MOVLW 8H
CALL ON_LCD ;TRANSMIT TH1621 WORK MODE VALUE
MOVLW 9H ;顯示9位LCD
CALL DIS_DATA
RETURN
;............................
ON_LCD MOVWFGENR1
BCF RC,2
MOVLW80H ;HI_W3 BITS:100
MOVWFWD_RG
MOVLW3 ;3位命令100
CALLTRAM_DATA
ON_LCD0MOVFGENR1,0
CALLON_VALUE ;查表初始化LCD
MOVWFWD_RG
MOVLW8 ;送8位查表值
CALLTRAM_DATA
BCF RC,WDA
NOP
NOP
BCF RB,1
NOP
NOP
BSF RB,1
BSF RC,2
DECFSZGENR1,1
GOTOON_LCD+1
RETURN
;........................
ON_VALUE
ADDWF2
NOP
RETLW03H;LCD ON
RETLW01H;SYS ON
RETLW08H;TONE OFF
RETLW29H;BISA1/3 4 COM
RETLW18H;256K
RETLW05H;WDT DISABLE
RETLW80H;/IRQ DISABLE *
RETLW0E3H;NORMAL MODE *
;................................
;TRANSMIT BITS SUBROUTINE
TRAM_DATA
BCF STATUS,0
MOVWFGENR0
BCFRB,1
RLFWD_RG
BTFSS3,0
GOTO$+3
BSFRC,WDA
GOTO$+2
BCFRC,WDA
BSFRB,1
DECFSZGENR0,1
GOTOTRAM_DATA+2
RETURN
;.......................
DIS_DATA
MOVWFGENR1 ;9位LCD
BCF RC,2
MOVLW0A0H
MOVWFWD_RG;WRITE CONTROL
MOVLW3H ;3位寫命令101
CALLTRAM_DATA
MOVLW00
MOVWFWD_RG;WRITE ADDRESS
MOVLW6H ;6位地址
CALLTRAM_DATA ;
DIS_DATA0
MOVLW0FFH
MOVWFWD_RG;DISPLAY CODE
MOVLW8 ;8段數(shù)據(jù)
CALLTRAM_DATA
DECFSZGENR1,1
GOTODIS_DATA0
BSF RC,2
RETLW0
END
評論