I'm working on a STM32F101CBT6.
My HW has a Dallas Tamper chip with RTC (connected to external Xtal), connected to the ST via i2c.
On power loss (battery extraction, for example) - the Dallas chip signals the ST, generating an interrupt.
Within the interrupt, I toggled a pin, to see (via logic analyzer) how long the ST 'lives'. The pin was toggled ~2.2ms.
During that time, still within the interrupt, I read the RTC timestamp from the Dallas and saved it in the backup registers of the internal RTC of the ST. This operation takes ~0.4ms.
When running it 'live', I read zeros, due to a TIMEOUT on the i2c.
Q 1: Does the i2c controller/peripheral die much quicker than the ST? Will my design work?
So I enabled the internal RTC, and now I'm updating it for the Dallas RTC on each boot.
Within the power-loss interrupt I save the internal RTC timestamp, and this works.
My problem is that the internal RTC drifts, a few seconds per minute!!!
Q 2: Why is the drift so big?