AB1805_RK periodic wake question

Is it possible to make an AB1805 watchdog wake a Boron every 15 minutes?

I see how I could wake every hour, or every minute, but don’t understand how (or if) I can periodic wake multiple times per hour.

Also, could you use Chrono literals in a way to combine minutes and seconds? To callout a sleep period of 11 minutes and 45 seconds, for example?

thx

I use the AB1805_RK library for lots of things. I modified the library as well for a few special circumstances (Allow calibration of the RTC, obtain and awake on the Hundredths Register from the RTC, etc.) It’s one of @rickkas7 many extremely useful libraries!

The way I accomplish what you are asking is the following steps:

  • Obtain the current time in EPOCH seconds
  • Do the remainder math to determine how many seconds until the next wake up period
  • Set an interrupt for that time in the future.

The code should be something like this:

ab1805.getRtcAsTime(time_cv); // Get the current UNIX EPOCH time
nxtRptStrt_sec = (rptInterval_sec - (uint32_t)time_cv % rptInterval_sec); // Determine number of seconds from now until the next period. 
nxtRptStrt_time = (uint32_t)time_cv + nxtRptStrt_sec; //Determine the UNIX EPOCH time of the next period. 
ab1805.interruptAtTime(nxtRptStrt_time) // Now just set an interrupt at that time. 

In this case if I set the nxtRptStrt_sec to 15 minutes. This would set an interrupt at the next 15 minute interval. I.e. if it’s 1:22 right now, the interrupt would fire at 1:30. Then each time I fall back asleep I just call it again to set the next interrupt at 1:45, 2:00, 2:15, 2:30, etc.

Not sure about the Chrono question. I don’t think the library itself has any reference to using Chrono literals.

3 Likes

Everything in the AB1805 is based on the real-time clock. Even options that look like they’re relative just add the increment to the current time in the chip. jgskara’s technique should work well.

The other option is to use interruptAtTm with a rptValue of REG_TIMER_CTRL_RPT_MIN. Set the tm_min field to the next increment (0, 15, 30, 45) each time.

3 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.