Hi.. I have some trouble with DS1307.. I built a clock and I write software to read from DS1307 about every second... I found that time is not correct when operate about one day.. time will slower about 1 minute.. I think because I read from DS1307 every second.. IF I read it every hour it works better.. But I need to display clock every second.. Any sugest for algorithym or any way to make it more precise
; Delay = 2 seconds
; Clock frequency = 40 MHz
; Actual delay = 2 seconds = 20000000 cycles
; Error = 0 %
cblock
d1
d2
d3
endc
;19999999 cycles
movlw 0xB6
movwf d1
movlw 0x99
movwf d2
movlw 0x2C
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;1 cycle
nop
//configure I2C
OpenI2C(MASTER, SLEW_OFF);
SSPADD = 9; //400kHz Baud clock(9) @16MHz
//100kHz Baud clock(39) @16MHz
"Note 1: The I2C interface does not conform to the 400 kHz I2C specification (which applies to rates greater than100 kHz) in all details, but may be used with care where higher rates are required by the application."
"SSPADD register holds the slave device address
when the SSP is configured in I2C Slave mode. When
the SSP is configured in Master mode, the lower
seven bits of SSPADD act as the baud rate generator
reload value."
cblock
d1
d2
d3
endc
;1999996 cycles
movlw 0x11
movwf d1
movlw 0x5D
movwf d2
movlw 0x05
movwf d3
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay_0
;4 cycles
goto $+1
goto $+1
----------------------
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?