MCP7940.adjust() function reset the PWRFAIL and VBATEN
Closed this issue · 2 comments
HHH-01 commented
The adjust() function resets the RTCWDAY, PWRFAIL bit and VBATEN bit somehow; this function should only affect the WDAY2-WDAY0 bits?
So if you use a backup battery and multiple adjust() functions in the main loop, the battery will be disabled whenever you call the adjust() function moving forward.
SV-Zanshin commented
Looking into the possible causes of this problem
SV-Zanshin commented
When the library sets the weekday, it cleared the OSCRUN, VBATEN and PWRFAIL register bits which caused the error. The fix is to only set the 3 relevant bits for the DOW and leave the rest of the register unchanged. Good catch!