RTC wakeup timeout

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
smhodge
Posts: 86
Joined: Tue Jan 22, 2019 2:16 am
Location: Kirkland, WA, USA

RTC wakeup timeout

Post by smhodge » Sun Oct 20, 2019 4:00 am

The RTC.wakeup() method specifies a "timeout" in milliseconds. Is that real time or relative time? For example if you specify a timeout of 60000 do you get an interupt every 60 seconds of real time, i.e., on the minute mark of the RTC? If so, does it keep repeating every minute mark? Thanks.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: RTC wakeup timeout

Post by jimmo » Mon Oct 21, 2019 12:16 am

Hi,

I'm not quite sure what you mean by real vs relative time, but the way I think about the RTC is in two parts:
- A low frequency counter that will continue incrementing even in low-power states.
- Some circuitry that knows how to use this to make a calendar. (i.e. it understands seconds/hours/minutes/days/weeks/etc).

`wakeup` is only relevant to the first part. In that sense it's not much different to pyb.Timer except it with different wake-from-sleep behavior (and much lower resolution).

So by specifying a 60000ms interval, you get a callback every minute, but this has no relation to what the current "minute" value is. It doesn't interpret 60000ms as "one minute" and then give you a callback at exactly the minute rollover (and zero seconds) -- it just gives you a callback every 60000ms.

Here's an example out that prints out the current rtc.datetime() every callback:

Code: Select all

(2019, 10, 21, 1, 11, 8, 48, 255)
(2019, 10, 21, 1, 11, 9, 48, 255)
(2019, 10, 21, 1, 11, 10, 48, 255)
(2019, 10, 21, 1, 11, 11, 48, 255)
(2019, 10, 21, 1, 11, 12, 48, 255)
They're one minute apart, but I wouldn't say they're "on the minute mark".

smhodge
Posts: 86
Joined: Tue Jan 22, 2019 2:16 am
Location: Kirkland, WA, USA

Re: RTC wakeup timeout

Post by smhodge » Fri Oct 25, 2019 3:06 am

Thanks for the confirmation. That's what I figured. I need minute marks for my application, and I've coded RTC chips (M41T83Z, DS3234) to do that for another application I have, using assembly to program the chips directly. Looking at the STM reference manual it looks like that should be possible.

Is there anyone out there who has done that?

Thanks

Post Reply