HT1380实时时钟程序
扫描二维码
随时随地手机看文章
HT1380EQU0X06
COUNT0EQU0X10
TXBUFEQU0X11
RXBUFEQU0X12
DATABUFEQU0X13
ADDRPOINTEQU0X14
HT_SDA_INEQU0B01001000
HD_SDA_OUTEQU0B00001000
HT_SCLEQU0
HT_RSTEQU1
Ht_SDAEQU2
;
TX_1380: MOV A,@HT_SDA_OUT
IOWHT1380
BCHT1380,HT_SCL
MOV A,@8
MOV COUNT0,A
TX_1380_LP:
BCHT1380,HT_SDA
JBCTXBUF,0
BSHT1380,HT_SDA
BSHT1380,HT_SCL
RRCTXBUF
BCHT1380,HT_SCL
DJZCOUNT0
JMPTX_1380_LP
RET
;读HT1380子程序
READ_HT:
MOV TXBUF,A
BCHT1380,HT_SCL
BSHT1380,HT_RST
MOV A,@HT_SDA_OUT
IOWHT1380
MOV A,@8
MOV COUNT0,A
TX_1_LP:
BCHT1380,HT_SDA
JBCTXBUF,0
BSHT1380,HT_SDA
BSHT1380,HT_SCL
RRCTXBUF
BCHT1380,HT_SCL
DJZCOUNT0
JMPTX_1_LP
MOV A,@HT_SDA_IN
IOWHT1380
MOV A,@8
MOV COUNT0,A
RX_1380_LP:
RRCRXBUF
BCRXBUF,7
JBCHT1380,HT_SDA
BSRXBUF,7
BSHT1380,HT_SCL
BCHT1380,HT_SCL
DJZCOUNT0
JMPRX_1380_LP
BCHT1380,HT_RST
RET
;写HT1380子程序
WRITE_HT:
MOV ADDRPOINT,A
BCHT1380,HT_SCL
BSHT1380,HT_RST
MOV A,@0B1000110
MOV TXBUF,A
CALLTX_1380
CLRTXBUF
CALLTX_1380
BCHT1380,HT_RST
NOP
BSHT1380,HT_RST
MOV A,ADDRPOINT
MOV TXBUF,A
CALLTX_1380
MOV A,DATABUF
MOV TXBUF,A
CALLTX_1380
BCHT1380,HT_RST
NOP
BSHT1380,HT_RST
MOV A,@0B10001110
MOV TXBUF,A
CALLTX_1380
MOV A,@0B10000000
MOV TXBUF,A
CALLTX_1380
BCHT1380,HT_RST
MOV A,HT_SDA_IN
IOWHT1380
RET
END