New issue 164 by felixls....@gmail.com: Problem with DS1307 library
http://code.google.com/p/jallib/issues/detail?id=164
What steps will reproduce the problem?
1. I wrote the attached code
2. worked well the first time
3. but, the next run, the clock loses the hour and seconds
What is the expected output? What do you see instead?
In the library code is wrong
procedure ds1307_init() is
ds1307_write( 0x00 , 0 ) -- Clk halt bit(7):0=ON 1=OFF
ds1307_write( 0x07 , 0b_10010000 ) -- OSC ON
ds1307_write( 0x02 , 0 ) -- 24H mode
end procedure
It should be something like this:
procedure ds1307_init() is
var byte value
ds1307_read( 0x00, value)
ds1307_write( 0x00 , value & 0x7F) -- Clk halt bit(7):0=ON 1=OFF
ds1307_read( 0x02, value)
ds1307_write( 0x02 , value & 0xCF) -- 24H mode bit(6)
ds1307_write( 0x07 , 0b_00000000 ) -- OUT bit(7), SQWE bit(4), RS0=RS1=0
->Freq
end procedure
Attachments:
sample-code-ds1307.jal 2.3 KB