I am designing a datalogger, and want to use an STM32L4R5VGT6 MCU. I know that this microcontroller has an internal RTC, so to avoid buying an external RTC I want to use the one that comes built into the MCU but I don't know if I will have problems later. Are the internal RTCs of the MCUs reliable or should I use an external RTC for better security?
-
5\$\begingroup\$ I'm not sure how an external RTC gives "better security", but if the internal RTC isn't accurate enough or doesn't have the features you want, then an external RTC would be indicated. \$\endgroup\$– virCommented Feb 21, 2023 at 21:28
-
\$\begingroup\$ If you run an external RTC on a separate long-lasting battery, you won't need to reset the time when the main battery goes dead. \$\endgroup\$– Mattman944Commented Feb 21, 2023 at 22:59
-
\$\begingroup\$ I would check the errata in case they messed up the built in rtc, but otherwise you’re good to go. \$\endgroup\$– BryanCommented Feb 22, 2023 at 4:42
3 Answers
From what I see, you should be fine using the internal RTC, but you may want to think about what else is going on in your circuit.
Taking a look at the datasheet for your microcontroller, it looks like the RTC is certainly reliable, or at least as reliable as any other RTC of similar cost. It has error correction, and allows for calibration against inaccuracy in the oscillator.
I'm going to assume you mean "secure" as in "resistant to issues in the circuit" rather than any informational security. If anything, an external RTC would be less informationally secure, as the signal from it could be more easily faked than the internal RTC signals.
The internal RTC on the STM32L4R5VGT6 is usable in both normal operation and in low power mode using the internal oscillator. However, if you want it to use a separate low-power battery (referred to in the datasheet as using it in "VBAT" mode), you'll need to use an external oscillator or low-speed crystal. If you're using a development board, there's likely already an external crystal, however if you're trying to really cut down on part count, you could get away with using the RTC in only low-power mode. I'm willing to bet an external crystal is cheaper than getting an external RTC.
The internal RTC is reliable. The low speed internal (LSI) oscillator not as stable as the low speed external (LSE) oscillator. The LSE is actually in the chip but uses an external resonator. Using the external resonator provides long term stability. An external RTC is not necessary unless extreme stability and accuracy is required.
Some micros can trim their oscillators digitally. You will need to get into the data sheet to determine what fits your needs.
-
\$\begingroup\$ Can confirm that the STM32 can digitally trim the RTC. Also the LSI is comically inaccurate (something like +/2%) so it's not really useful for timekeeping (there are other reasons to use the RTC module, such as periodic wakeup from sleep mode which is why it's still useful). \$\endgroup\$– JonCommented Feb 22, 2023 at 13:14
I'd suggest that assuming that whatever is providing the RTC's clock signal is of adequate stability this really boils down to two commercial questions: (1) can the design afford the component(s) and power for an external RTC and (2) what combination of components and manufacturers provide the best indemnity against out-of-spec behaviour?
All else equal, there's little point considering an external RTC to improve reliability if the MTBF is believed to be worse than the clock on the main chip, or if the manufacturer doesn't have a robust track-record of long-term (i.e. not just accelerated) testing.