Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/13/99 10:30
Read: times


 
#1053 - ds1302 program please help
hello!


how are you . Do you have code for the 8031 to access a DS1302 real time chip?

I write a program but it work not ok. please help me .

thanks


;
; cpu -8031 ds1302 pin1-+5 pin2-3 32768hz 4 -GND 8 - bettery



RST BIT P1.5
IO BIT P1.6
SCLK BIT P1.7


ORG 0000H
LJMP MAIN

MAIN: MOV SP,#30H
MOV P1,#0 ;P1.5-P1.7 OUTPUT LOW
CCC: MOV R6,#10001110B
MOV R7,#0
LCALL WRTCLK
MOV R6,#10000000B
MOV R7,#02
LCALL WRTCLK
MOV R6,#0C0H
MOV R7,#00
LCALL WRTCLK
MOV R7,#10000011B
DDD: LCALL READCLK
LJMP DDD
NOP
NOP
MOV R6,#11000000B
MOV R7,#01
LCALL WRTCLK
MOV R6,#10001110B
MOV R7,#0
LCALL WRTCLK
AAA: MOV R6,#11000000B
MOV R7,#55H
LCALL WRTCLK
MOV R7,#11000001B
LCALL READCLK
MOV R6,#80H
MOV R7,#01H
LCALL WRTCLK
BBB: MOV R7,#81H
LCALL READCLK
LJMP BBB
MOV R7,#83H
LCALL READCLK


;-------RST IO SCLK =0
RESET: CLR SCLK
CLR IO
CLR RST
RET

;-------SEND COMMAND BYTE TO DS1302
SENDCLK:MOV R2,#8
MOV A,R7
CLR C
LO1: RLC A
NOP
NOP
NOP
NOP
JC SEND1
CLR IO
LJMP LO2
SEND1: SETB IO
LO2: LCALL DELAY1
CLR SCLK
LCALL DELAY1
SETB SCLK
LCALL DELAY1
DJNZ R2,LO1
RET

;WRITE CLOCK SUB
WRTCLK: LCALL RESET
SETB RST
MOV B,R7
MOV A,R6
MOV R7,A
LCALL SENDCLK
MOV R7,B
LCALL SENDCLK
CLR RST
LCALL RESET
RET
;-------READ CLOKC
READCLK:LCALL RESET
SETB RST
NOP
NOP
LCALL SENDCLK
MOV R2,#8
SETB IO
REIN1: SETB SCLK
LCALL DELAY1
CLR SCLK
LCALL DELAY1
MOV C,IO
RLC A
DJNZ R2,REIN1
MOV R7,A
CLR RST
LCALL RESET
RET

DELAY1: RET
NOP
NOP
RET


END


List of 4 messages in thread
TopicAuthorDate
ds1302 program please help            01/01/70 00:00      
RE: ds1302 program please help            01/01/70 00:00      
RE: ds1302 program please help            01/01/70 00:00      
RE: ds1302 program please help            01/01/70 00:00      

Back to Subject List