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

ds1307: wrong squarewave frequency returned #110

Closed
2 of 8 tasks
ansemjo opened this issue Aug 26, 2020 · 1 comment
Closed
2 of 8 tasks

ds1307: wrong squarewave frequency returned #110

ansemjo opened this issue Aug 26, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@ansemjo
Copy link

ansemjo commented Aug 26, 2020

Device type

  • ESP32
  • ESP8226

Framework version

  • ESP-IDF latest master
  • ESP-IDF 4.0.1 (via PlatformIO)
  • ESP-IDF 3.2.x
  • ESP-IDF 3.3.x
  • ESP8266 RTOS SDK latest master
  • ESP8266 RTOS SDK 3.2

Describe the bug

When checking if RTC configuration was applied correctly, I am checking the squarewave frequency output with ds1307_get_squarewave_freq and comparing it against DS1307_32768HZ.

That check returns false and the returned value is 176 or 0b1011000.

Checking against the datasheet, this is the supposed content of the control register with the rate select bits RS0/RS1 masked out.

In line 191 of ds1307.c the returned register is &-ed with SQWEF_MASK, when it should be the inverse of that mask.

#define SQWEF_MASK   0xfc

Changing the line to the following fixes the issue for me:

*sqw_freq = val & ~SQWEF_MASK;

Another sidenote: when using this API, I am expecting to receive true from ds1307_is_running when ... well, the clock is running. However, what I am getting is the contents of the CH bit which stands for "clock halt". So a value of 0 actually indicates that the clock is running, which is confusing ..

@UncleRus
Copy link
Owner

Thank you!

@UncleRus UncleRus added the bug Something isn't working label Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants