Using RTC DS3231
Hi, guys. i need your help. i'm using a RTC DS3231 and i have this problem:
I'm having this problem because of the least significant bit overflow?
what kind of function could I apply to fix this problem?
(00h address of seconds)
I would like to ream from 0-59s in integer. Thank you for your supp!
'\t' is the same code as '\x09', see https://theasciicode.com.ar/ascii-control-characters/horizontal-tab-ascii-code-9.html
robert-hh last edited by
@Lucas_Vieira @Eric73 Actually it should (could) be:
sec = (segundos >> 4) * 10 + (segundos & 0x0f)
sec = (segundos // 16) * 10 + (segundos & 0x0f)
The conversion to seg is not needed, since array access to a single bytearray element returns an integer.
So, your trouble is second RTC register is in BCD format.
Something like this in line 18
will give you the correct int value