pic单片机控制HT1621 LCD程序

【pic单片机控制HT1621 LCD程序】pIC单片机控制HT1621LCD程序
;THISPROGRAMISHT1621LCDDISPLAY
;VDD=5.0VIFVDD<5.0VPLEASETODELAY
;RECEIVEANDTRANSMITBYTR’TIM
;
FSREQU4H
RBEQU6H
GENR0EQU09H
GENR1EQU0AH
WD_RGEQU0BH

;theregistersofLCDDISPLAYDATA
DA_AG0EQU10H;SEG0SEG1
DA_AGFEQU1FH;SEG30SEG31
;
;RBBITS
CSEQU0;ABLEBIT
WDAEQU1;DATAPORT
WCLKEQU2;WRITECOLK
RCLKEQU3;READCOLK
;
;theVALUEofLCDworkmode
BISAEQU52H;1/3bisa4COM
;
;----------------
;thetableofHT1621WORKMODEVALUE
ON_VALUE
ADDWF2
RETLW06H;LCDON
RETLW02H;SYSON

RETLW10H;TONEOFF
RETLWBISA;BISA1/34COM
RETLW28H;32KXTAL
RETLW0AH;WDTDISABLE

RETLW00;/IRQDISABLE*
RETLW0C6H;NORMALMODE*

;-------
;TRANSMITBITSSUBROUTINE
;fristlytransmithighbitofbyte
TRAM_DATA
MOVWFGENR0

BCFRB,WCLK
RLFWD_RG
BTFSS3,0
GOTO$+3

BSFRB,WDA
GOTO$+2

BCFRB,WDA

NOP
NOP
BSFRB,WCLK

NOP
NOP
NOP
NOP
NOP
BCFRB,WCLK
DECFSZGENR0
GOTOTRAM_DATA+1
RETLW0
;-------
;RECEIVINGBITSSUBROUTINE
;fristlyreceivehighbitofbyte
RCIV_DATA
BCFRB,RCLK

NOP
NOP
NOP
NOP
BSFRB,RCLK
NOP
NOP

BTFSSRB,WDA
GOTO$+3
BSF3,0
GOTO$+2

BCF3,0
RLF0H
DECFSZGENR0
GOTORCIV_DATA
RETLW0
;
;-------
;TRANSMITCONTROLCODESOFLCDDISPLAYSUBROUTINE
ON_LCD
MOVWFGENR1

MOVLW80H;HI_W3BITS:100
MOVWFWD_RG

MOVLW3
CALLTRAM_DATA
ON_LCD0
MOVLW7H
SUBWFGENR1,W
MOVLW00H;HI_W1BIT:0
BTFSC3,0
MOVLW10H;HI_W1BIT:1
MOVWFWD_RG

MOVLW1H
CALLTRAM_DATA

MOVFWGENR1
CALLON_VALUE;LO_8BITS
MOVWFWD_RG

MOVLW8
CALLTRAM_DATA

DECFSZGENR1
GOTOON_LCD0
RETLW0
;
;TRANSMITDISPLAYDATAESSUBROUTINE
DIS_DATA
MOVWFGENR1
MOVLW0A0H
MOVWFWD_RG;WRITECONTROL

MOVLW3H
CALLTRAM_DATA

MOVLW00
MOVWFWD_RG;WRITEADDRESS
MOVLW6H
CALLTRAM_DATA

;MOVLWDA_AG0-1
;MOVWFFSR
DIS_DATA0
INCFFSR
MOVFW0H
MOVWFWD_RG;DISPLAYCODE

MOVLW8
CALLTRAM_DATA

DECFSZGENR1;DISPLAYWHICHSEGMENTREGSTER
GOTODIS_DATA0
RETLW0H
;==========================
;
;becauseintheHT1621commandcode’highbitandmemory
;addresscode’high-bitisfristlytransmitted,and
;data’low-bitisfristlytransmittedandreceived,but
;thisprogramfristlytransmitandreceivhigh-bit.
;pleasetoattenatedisplaydataesassemble’modle.
;
;INTITIALIZEPORT_B
MOVLW0F0H
TRISRB
MOVLW0FH
MOVWFRB

MOVLW4;CPUOSC=4MHz
OPTION
;
;SETHT1621WORKMODE
BCFRB,CS;CS=0
MOVLW8H
CALLON_LCD;TRANSMITHT1621WORKMODEVALUE
MOVLW0FH
IORWFRB;CS=1
NOP
;
;==========================
;WRITEOPERATION
;DISPLAYDATAPUTINDA_AG0(10H)REGSTERTODA_AGF(1FH)REGISTER
BCFRB,CS;CS=0

MOVLWDA_AG0-1;DISPLAYSEGMENTREGSTER
MOVWFFSR
MOVLW10H;32SEGMENTS
callDIS_DATA

MOVLW0FH;CS=1
IORWFRB
;
;==========================
;READOPERATION
MOVLW0C0H
MOVWFWD_RG;WRITECONTROL

BCFRB,CS
MOVLW3H
CALLTRAM_DATA

MOVLW00
MOVWFWD_RG;WRITEADDRESS
MOVLW6H
CALLTRAM_DATA
;
;READOUTDATAESPUTINDA_AG0(10H)TODA_AGF(1FH)REGSTER
BSFRB,WCLK

MOVLW10H;32SEGMENTS
MOVWFGENR1
MOVLWDA_AG0
MOVWFFSR

BCFRB,RCLK;RCLK=0
AG_RD
BSFGENR0,3;READBYTES
CALLRCIV_DATA
;
INCFFSR
DECFSZGENR1
GOTOAG_RD
;
MOVLW0FH
IORWFRB
;
;

    推荐阅读