LCD驱动HT1621的PIC单片机源代码
STATUSEQU 3HFSR 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_AG0EQU 056H ;SEG0 SEG1
DA_AG8EQU 05EH ;SEG16 SEG17
;.............................
C EQU 0
Z EQU 2
RP0 EQU 5
RP1 EQU 6
CS EQU 2
WDA EQU 5 ;RC,5数据线
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
CALLX_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_LCDMOVWF GENR1
BCF RC,2
MOVLW 80H;HI_W3 BITS:100
MOVWF WD_RG
MOVLW 3 ;3位命令100
CALL TRAM_DATA
ON_LCD0 MOVF GENR1,0
CALL ON_VALUE ;查表初始化LCD
MOVWF WD_RG
MOVLW 8 ;送8位查表值
CALL TRAM_DATA
BCF RC,WDA
NOP
NOP
BCF RB,1
NOP
NOP
BSF RB,1
BSF RC,2
DECFSZ GENR1,1
GOTO ON_LCD+1
RETURN
;........................
ON_VALUE
ADDWF 2
NOP
RETLW 03H ;LCD ON
RETLW 01H ;SYS ON
RETLW 08H ;TONE OFF
RETLW 29H ;BISA1/34 COM
RETLW 18H ;256K
RETLW 05H ;WDT DISABLE
RETLW 80H ;/IRQ DISABLE*
RETLW 0E3H ;NORMAL MODE *
;................................
;TRANSMIT BITS SUBROUTINE
TRAM_DATA
BCF STATUS,0
MOVWF GENR0
BCF RB,1
RLF WD_RG
BTFSS 3,0
GOTO $+3
BSF RC,WDA
GOTO $+2
BCF RC,WDA
BSF RB,1
DECFSZ GENR0,1
GOTO TRAM_DATA+2
RETURN
;.......................
DIS_DATA
MOVWF GENR1 ;9位LCD
BCF RC,2
MOVLW 0A0H
MOVWF WD_RG ;WRITE CONTROL
MOVLW 3H ;3位写命令101
CALL TRAM_DATA
MOVLW 00
MOVWF WD_RG ;WRITE ADDRESS
MOVLW 6H ;6位地址
CALL TRAM_DATA ;
DIS_DATA0
MOVLW 0FFH
MOVWF WD_RG ;DISPLAY CODE
MOVLW 8 ;8段数据
CALL TRAM_DATA
DECFSZ GENR1,1
GOTO DIS_DATA0
BSF RC,2
RETLW 0
END
页:
[1]