How to capture Power failure/restore time on T41

paulfer

Member
Here is a curved ball question:

On my old projects, I use an MCP79410 RTC chip. One of the nice things it has is two registers to capture the time of power failure and restore. (Provided you have the VBAT active)

I was just wondering, is there a neat way to do it on the Teensy or should I simply stick to adding the RTC chip?

What would you chaps do?
 
You could try periodically writing the time to EEPROM.
Then when you power up, read the time. That will be the last time the Teensy was alive.
 
You could try periodically writing the time to EEPROM.
Then when you power up, read the time. That will be the last time the Teensy was alive.
Excellent suggestion. I only need a minute or so resolution so writing once a minute would be quite fine for me!
 
You don't specify which Teensy, but these days I assume 4.x, and therefore I would continue to use the RTC, for a couple of reasons. One is that the RTC built into T4.x has much higher backup current requirements than an external RTC. The second is that EEPROM is emulated in the main program flash, and that turns out to have some drawbacks. First, writing to flash disables interrupts, and second, you won't know in advance when a write will trigger an erase, which can result in interrupts being disabled for quite a few milliseconds. If those matter, then I would use an external RTC and also an external EEPROM, if you need it for other reasons.
 
You don't specify which Teensy, but these days I assume 4.x, and therefore I would continue to use the RTC, for a couple of reasons. One is that the RTC built into T4.x has much higher backup current requirements than an external RTC. The second is that EEPROM is emulated in the main program flash, and that turns out to have some drawbacks. First, writing to flash disables interrupts, and second, you won't know in advance when a write will trigger an erase, which can result in interrupts being disabled for quite a few milliseconds. If those matter, then I would use an external RTC and also an external EEPROM, if you need it for other reasons.
Yes Thanks Joe, I mentioned the T41 in the heading. But I hear you on the power requirements. I did read in another thread on this forum about the power consumption on VBAT and if I recall correctly in was in the region of 40 days. Which then makes sense to use an external RTC if power is going to be off for long.
 
Back
Top