Datasheet

Table Of Contents
Bits Name Description Type Reset
8:0 CYCLES Total number of clk_tick cycles before the next tick. RW 0x000
4.9. RTC
The Real-time Clock (RTC) provides time in human-readable format and can be set to generate events at specific times.
Time is stored in binary, separated in seven fields:
Table 579. RTC
storage format
Date/Time Field Size Legal values
Year 12 bits 0..4095
Month 4 bits 1..12
Day 5 bits 1..[28,29,30,31], depending on the
month
Day of Week 3 bits 0..6. Sunday = 0
Hour 5 bits 0..23
Minute 6 bits 0..59
Seconds 6 bits 0..59
The RTC does not check values. Illegal values may cause unexpected behaviours.
The RTC uses a reference clock clk_rtc, which should be set to any integer frequency in the range 1…65536 Hz.
The internal 1 Hz reference is derived internally with an integer divider. Program the desired division value minus 1
through CLKDIV_M1.
The clk_rtc can be driven either from an internal or external clock source. Those sources can be prescaled, using a
fractional divider (see Clocks).
NOTE
All RTC register reads and writes are done from the processor clock domain clk_sys. All data are synchronised back
and forth between the domains. Writing to the RTC will take 2 clk_rtc clock periods to arrive, additional to the clk_sys
domain. This should be taken into account especially when the reference is slow (e.g. 1 Hz)
Useful examples:
1. Select XOSC 12MHz, divide externally by 256, set CLKDIV_M1 = 46874.
2.
If the crystal is not exactly 12MHz, but very close, set a fractional value to get clk_rtc as close as possible to 46875
Hz.
3. Use an external reference from a GPS, which generates one pulse per second. Bypass the divider external to the rtc
and set CLKDIV_M1 = 0
TO DO: LIAM/ANDRAS: Seems like this would be a good place for some example code
4.9.1. Day of the week
Day of the week is encoded as Sun 0, Mon 1, …, Sat 6 (i.e. ISO8601 mod 7).
There is no built-in calendar function. The chip will not compute the correct day of the week; it will only increment the
existing value.
RP2040 Datasheet
4.9. RTC 572