Datasheet

Table Of Contents
140
141 // Enable the IRQ at the proc
142 irq_enable(RTC_IRQ, true);
143
144 // Set matching and wait for it to be enabled
145 hw_set_bits(&rtc_hw->irq_setup_0, RTC_IRQ_SETUP_0_MATCH_ENA_BITS);
146 while(!(rtc_hw->irq_setup_0 & RTC_IRQ_SETUP_0_MATCH_ACTIVE_BITS));
147 }
4.9.5.5. Complete Pico SDK example
Pico Examples: https://github.com/raspberrypi/pico-examples/tree/pre_release/rtc/hello_rtc/hello_rtc.c Lines 13 - 44
13 int main() {
14 setup_default_uart();
15 printf("Hello RTC!\n");
16
17 char datetime_buf[256];
18 char *datetime_str = &datetime_buf[0];
19
20 // Start on Friday 5th of June 2020 15:45:00
21 datetime_t t = {
22 .year = 2020,
23 .month = 06,
24 .day = 05,
25 .dotw = 5, // 0 is Sunday, so 5 is Friday
26 .hour = 15,
27 .min = 45,
28 .sec = 00
29 };
30
31 // Start the RTC
32 rtc_init();
33 rtc_set_datetime(&t);
34
35 // Print the time
36 while (true) {
37 rtc_get_datetime(&t);
38 datetime_to_str(datetime_str, sizeof(datetime_buf), &t);
39 printf("\r%s ", datetime_str);
40 sleep_ms(100);
41 }
42
43 return 0;
44 }
4.9.6. List of Registers
Table 580. List of RTC
registers
Offset Name Info
0x00 CLKDIV_M1 Divider minus 1 for the 1 second counter. Safe to change the
value when RTC is not enabled.
0x04 SETUP_0 RTC setup register 0
0x08 SETUP_1 RTC setup register 1
RP2040 Datasheet
4.9. RTC 578