T
Toyib
Guest
HAI ALLE ....
Jeg ønsker at vise VAERDIEN AF ANDET VAERDI AF DS1307 til havnen 0 med denne kodeks (. ASM) ....
Code:SCL BIT P1.0
SDA BIT P1.1
DS1307W DATA 0D0H
DS1307R DATA 0D1H
FLAG DATA 20H
LASTREAD BIT FLAGS.0
ACK BIT FLAGS.5
BUS_FLT BIT FLAGS.6
_2W_BUSY BIT FLAGS.7
BITCNT DATA 21H; ************************************************* *********
; START PROGRAM
; ************************************************* *********
LOOP:
ACALL READ_CLOCK
MOV P0, A
SJMP LOOP
; ************************************************* *********
SEND_START:
SETB _2W_BUSY
CLR ACK
CLR BUS_FLT
JNB SCL, FAULT
JNB SDA, FAULT
SETB SDA
LCALL SCL_HIGH
CLR SDA
ACALL DELAY
CLR SCL
RET
Fejl:
SETB BUS_FLT
RET
; ************************************************* *********
SEND_STOP:
CLR SDA
LCALL SCL_HIGH
SETB SDA
CLR _2W_BUSY
RET
; ************************************************* *********
DELAY: NOP
RET
; ************************************************* *********
SCL_HIGH:
SETB SCL
JNB SCL, $
RET
; ************************************************* *********
SEND_BYTE:
MOV BITCNT, # 08H
SB_LOOP:
JNB ACC.7, NOTONE
SETB SDA
JMP ONE
NOTONE:
CLR SDA
ONE:
LCALL SCL_HIGH
RL A
CLR SCL
DJNZ BITCNT, SB_LOOP
SETB SDA
LCALL SCL_HIGH
CLR ACK
JNB SDA, SB_EX
SETB ACK
SB_EX:
ACALL DELAY
CLR SCL
ACALL DELAY
RET
; ************************************************* *********
READ_BYTE:
MOV BITCNT, # 08H
MOV A, # 00H
SETB SDA
READ_BITS:
LCALL SCL_HIGH
MOV C, SDA
RLC A
CLR SCL
DJNZ BITCNT, READ_BITS
JB LASTREAD, ACKN
CLR SDA
ACKN:
LCALL SCL_HIGH
CLR SCL
RET
; ************************************************* *********
READ_CLOCK:
CLR LASTREAD
ACALL SEND_START
MOV A, # DS1307W
ACALL SEND_BYTE
MOV A, # 00H
ACALL SEND_BYTE
ACALL SEND_STOP
ACALL SEND_START
MOV A, # DS1307R
ACALL SEND_BYTE
ACALL READ_BYTE
ACALL SEND_STOP
RET
SLUT
Jeg ønsker at vise VAERDIEN AF ANDET VAERDI AF DS1307 til havnen 0 med denne kodeks (. ASM) ....
Code:SCL BIT P1.0
SDA BIT P1.1
DS1307W DATA 0D0H
DS1307R DATA 0D1H
FLAG DATA 20H
LASTREAD BIT FLAGS.0
ACK BIT FLAGS.5
BUS_FLT BIT FLAGS.6
_2W_BUSY BIT FLAGS.7
BITCNT DATA 21H; ************************************************* *********
; START PROGRAM
; ************************************************* *********
LOOP:
ACALL READ_CLOCK
MOV P0, A
SJMP LOOP
; ************************************************* *********
SEND_START:
SETB _2W_BUSY
CLR ACK
CLR BUS_FLT
JNB SCL, FAULT
JNB SDA, FAULT
SETB SDA
LCALL SCL_HIGH
CLR SDA
ACALL DELAY
CLR SCL
RET
Fejl:
SETB BUS_FLT
RET
; ************************************************* *********
SEND_STOP:
CLR SDA
LCALL SCL_HIGH
SETB SDA
CLR _2W_BUSY
RET
; ************************************************* *********
DELAY: NOP
RET
; ************************************************* *********
SCL_HIGH:
SETB SCL
JNB SCL, $
RET
; ************************************************* *********
SEND_BYTE:
MOV BITCNT, # 08H
SB_LOOP:
JNB ACC.7, NOTONE
SETB SDA
JMP ONE
NOTONE:
CLR SDA
ONE:
LCALL SCL_HIGH
RL A
CLR SCL
DJNZ BITCNT, SB_LOOP
SETB SDA
LCALL SCL_HIGH
CLR ACK
JNB SDA, SB_EX
SETB ACK
SB_EX:
ACALL DELAY
CLR SCL
ACALL DELAY
RET
; ************************************************* *********
READ_BYTE:
MOV BITCNT, # 08H
MOV A, # 00H
SETB SDA
READ_BITS:
LCALL SCL_HIGH
MOV C, SDA
RLC A
CLR SCL
DJNZ BITCNT, READ_BITS
JB LASTREAD, ACKN
CLR SDA
ACKN:
LCALL SCL_HIGH
CLR SCL
RET
; ************************************************* *********
READ_CLOCK:
CLR LASTREAD
ACALL SEND_START
MOV A, # DS1307W
ACALL SEND_BYTE
MOV A, # 00H
ACALL SEND_BYTE
ACALL SEND_STOP
ACALL SEND_START
MOV A, # DS1307R
ACALL SEND_BYTE
ACALL READ_BYTE
ACALL SEND_STOP
RET
SLUT