How to use the internal RTC with a battery

Discussions around product based on ARM Cortex M0+ core.

Moderator: nferre

pozz
Posts: 68
Joined: Fri Jun 13, 2014 2:55 pm

How to use the internal RTC with a battery

Tue Mar 08, 2016 12:21 pm

I'd like to use the internal RTC for keeping current date and time.

I think I'll use a 32kHz crystal connected to XIN32/XOUT32 and feed RTC peripherals with 1Hz clock derived from 32kHz.

The problem is I'd like to keep RTC running even if the power supply is not present. Of course, with a battery.

However D20 MCU doesn't have a Vbat power input pin! Does this mean I can't use internal RTC for calendar purpose?

Maybe one solution is to use an external power supply switch (a couple of MOS) to select power from battery or mains (of course, mains is priority). At the same time, the MCU should monitor the mains presence. In case of absence, it should go in a sleep state where only RTC peripheral (and its clock) is running.

Is there an application note, example code, schematics that shows this?
sarlacii
Posts: 68
Joined: Mon Jan 26, 2015 2:33 pm

Re: How to use the internal RTC with a battery

Wed Mar 09, 2016 9:06 am

pozz wrote:<snip>

I think I'll use a 32kHz crystal connected to XIN32/XOUT32 and feed RTC peripherals with 1Hz clock derived from 32kHz.

<snip>

Maybe one solution is to use an external power supply switch (a couple of MOS) to select power from battery or mains (of course, mains is priority). At the same time, the MCU should monitor the mains presence. In case of absence, it should go in a sleep state where only RTC peripheral (and its clock) is running.

Is there an application note, example code, schematics that shows this?
Greetings

From what I have learnt while using the D20, your idea is the way to go. Perhaps consider just using the internal 32kHz clock, instead of an external source? Easier to manage.

The uC has tons of power control options, as that is one of its strong points, so connecting an external 3V3 battery via a battery charger/change-over circuit will work... and then shut down all the clocks except the 32kHz ref and sleep the uC.

I don't know of any specific ASF examples etc. that do this... but maybe the "SLEEPWALKING_ADC1 - SAM Sleepwalking Voltage Monitor Application" is a place to start. When the mains voltage comes back on and you detect it via your sleepwalking AC fail monitoring circuit, then you bring everything back up.

Go well.
pozz
Posts: 68
Joined: Fri Jun 13, 2014 2:55 pm

Re: How to use the internal RTC with a battery

Wed Mar 09, 2016 2:23 pm

sarlacii wrote:Perhaps consider just using the internal 32kHz clock, instead of an external source? Easier to manage.
I'm not sure the 32kHz internal clock could be used for calendar purpose. Maybe its tolerance is too high.
sarlacii wrote:The uC has tons of power control options, as that is one of its strong points, so connecting an external 3V3 battery via a battery charger/change-over circuit will work... and then shut down all the clocks except the 32kHz ref and sleep the uC.

I don't know of any specific ASF examples etc. that do this... but maybe the "SLEEPWALKING_ADC1 - SAM Sleepwalking Voltage Monitor Application" is a place to start. When the mains voltage comes back on and you detect it via your sleepwalking AC fail monitoring circuit, then you bring everything back up.
Thank you for your suggestions. It's a pity Atmel doesn't provide an evaluation board/kit showing this feature.

A battery for keeping RTC up and running is a very frequent application.

Return to “SAM D20 Cortex-M0+ MCU”

Who is online

Users browsing this forum: No registered users and 1 guest