Calling setEpoch causes serial data to be lost. This is because the CLOCK register is altered bit by bit sequentially without the SYNCBUSY bit being checked with each update.
This causes a bus stall and serial interrupts to be lost. As per the datasheet - section 19.6.8 (Synchronization):
"When executing an operation that requires synchronization, the Synchronization Busy bit in the Status register (STATUS.SYNCBUSY) will be set immediately, and cleared when synchronization is complete....
If an operation that requires synchronization is executed while STATUS.SYNCBUSY is one, the bus will be stalled...
Clock Value register (CLOCK)"
These changes fix this by changing all the single bit change updates into one register change followed by a SYNCBUSY check.
Calling setEpoch causes serial data to be lost. This is because the CLOCK register is altered bit by bit sequentially without the SYNCBUSY bit being checked with each update.
This causes a bus stall and serial interrupts to be lost. As per the datasheet - section 19.6.8 (Synchronization):
"When executing an operation that requires synchronization, the Synchronization Busy bit in the Status register (STATUS.SYNCBUSY) will be set immediately, and cleared when synchronization is complete.... If an operation that requires synchronization is executed while STATUS.SYNCBUSY is one, the bus will be stalled... Clock Value register (CLOCK)"
These changes fix this by changing all the single bit change updates into one register change followed by a SYNCBUSY check.