Datasheet

Table Of Contents
4.9.2. Leap year
If the current value of YEAR in SETUP_0 is evenly divisible by 4, a leapyear is detected, and Feb 28th is followed by Feb 29th,
not March 1st. Since this is not always true (century years for example), the leapyear checking can be forced off by setting
the CTRL.FORCE_NOTLEAPYEAR. The next occurrence when this should happen is in year 2100.
NOTE
The leap year check is done only when needed (the second following Feb 28, 23:59:59). The software can set
FORCE_NOTLEAPYEAR anytime after 2096 Mar 1 00:00:00 as long as it arrives before 2100 Feb 28 23:59:59 (i.e. taking into
account the clock domain crossing latency)
4.9.3. Interrupt
One can set up a time in the future, which, when reached, will cause the RTC to generate an interrupt. There is a global bit,
MATCH_ENA in IRQ_SETUP_0 to enable this feature, and individual enables for each time field (year, month, day, day-of-the-
week, hour, minute, second). The individual enables can be used to implement repeating interrupts at specified times (TO
DO: LIAM/ANDRAS: sample code would be a useful illustration of this concept e.g. to do something every Monday at
11:00 am, enable matching on day of the week, hour, minute, second fields and set those fields to the desired values).
The alarm interrupt is sent to the processors and also to the ROSC and XOSC to wake them from dormant mode. See
Section 4.9.4.6 for more information.
4.9.4. How to use the RTC
There are three setup tasks:
Set the 1 sec reference
Set the clock
Set an alarm
TO DO: LIAM/ANDRAS: sample code for each of these tasks would be awesome. I note sample code is included below in
"programmer" section - I’d suggest transferring the following narratives to comments in the code samples and referencing
that code. As is, these narratives are confusing.
4.9.4.1. Setup of the 1 second reference:
Select the source for clk_rtc. This is done outside the RTC registers.
From XOSC
Set up the clock divider in the clk_rtc clock slice to 256. This will give us a clk_rtc of 46875Hz. Disable the RTC.
Check status, to confirm that RTC is not running. Then load decimal 46874 to CLKDIV_M1.
From GPIN
Assume we have an external reference of 32768Hz. Disable the RTC. Check status, to confirm that RTC is not
running. Load decimal 32767 to CLKDIV_M1.
RP2040 Datasheet
4.9. RTC 573