Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with DS1307 library #164

Open
GoogleCodeExporter opened this issue Mar 3, 2016 · 2 comments
Open

Problem with DS1307 library #164

GoogleCodeExporter opened this issue Mar 3, 2016 · 2 comments

Comments

@GoogleCodeExporter
Copy link

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

Original issue reported on code.google.com by felixls....@gmail.com on 20 Jul 2011 at 5:43

@GoogleCodeExporter
Copy link
Author

Fixed the initialization routine according to datasheet.

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

Original comment by robhamerling on 24 Apr 2013 at 6:53

  • Changed state: Fixed
  • Added labels: Component-External

@GoogleCodeExporter
Copy link
Author

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!).

Original comment by robhamerling on 25 Apr 2013 at 8:13

  • Changed state: Started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant