Expose VL bit flag for RTC

  • This came up on a facebook group discussion on the RTC in the Core2 and Core3

    There is a bit in the "seconds" register in the RTC's BM8563 chip that indicates that the chip has had low voltage at some point and that the internal timestamp information may be corrupted.

    However, it looks like the m5stack library (on github) for this RTC chip specifically masks out this bit when reading the timestamp information. This is sensible for getting the correct number of seconds, but it means this status bit is not visible to users.

    If the library could provide a way to read this status, and even provide it via UIFlow2, then users could check the integrity of the timestamp info of the RTC.

    Maybe a "Get System Time Integrity Flag" or "Get RTC Low Voltage Flag" or something? Then if this flag is set, the user could refresh the RTC's time to maintain accuracy.

    Just an idea.

  • It's more than just an idea, it's a good idea. They already have it in the M5 Unified library, they just need to backport it to Core2. I filed a pull request. I hope they accept it:
    I thought that you could use the RTC::ReadReg method directly to read the bit, something like return Rtc.ReadReg(0x02) & 0x80;, but unfortunately the method is private.
    Hope this helps