Issue 164 in jallib: Problem with DS1307 library

20 views
Skip to first unread message

jal...@googlecode.com

unread,
Jul 20, 2011, 1:44:07 AM7/20/11
to jal...@googlegroups.com
Status: Assigned
Owner: ----
Labels: Type-Defect Priority-Medium

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

jal...@googlecode.com

unread,
Apr 24, 2013, 2:53:26 PM4/24/13
to jal...@googlegroups.com
Updates:
Status: Fixed
Labels: Component-External

Comment #1 on issue 164 by robhamerling: Problem with DS1307 library
http://code.google.com/p/jallib/issues/detail?id=164

Fixed the initialization routine according to datasheet.

This library will be subject of revision with issue 185 (and 186).

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

jal...@googlecode.com

unread,
Apr 25, 2013, 4:13:55 AM4/25/13
to jal...@googlegroups.com
Updates:
Status: Started

Comment #2 on issue 164 by robhamerling: Problem with DS1307 library
http://code.google.com/p/jallib/issues/detail?id=164

This issue was prematurely marked as fixed. The switch in rtc_init() from
12- to 24-hour mode is incorrect in more than one way.
Temporary fix: when the ds1307 is in 12-hour mode it is switched to 24-hour
mode, but the hour value is left unchanged. So when the switch happens
after midday the clock will be 12 hours off. When the clock is set right
after the _rtc_init() it will remain to work correctly (provided it is not
switched back to 12-hour mode!).
Reply all
Reply to author
Forward
0 new messages