---
title: "RTC Clock"
description: "Set the SoC RTC, then read it back. The minimal demo for ``."
source: https://docs.alplab.ai/sdk/examples/rtc-clock
---

# `rtc-clock`

Set the SoC RTC, then read it back. The minimal demo for [`<alp/rtc.h>`](https://docs.alplab.ai/sdk/api/rtc).

Source: [`examples/power-timing/rtc-clock/`](https://github.com/alplabai/alp-sdk/tree/main/examples/power-timing/rtc-clock).

## `board.yaml`

```yaml
som:
  sku: E1M-AEN801

preset: e1m-evk

cores:
  m55_hp:
    app: ./src
    peripherals: [rtc]

diagnostics:
  log_level: info
```

## Source (abbreviated)

```c
#include <stdio.h>

#include "alp/peripheral.h"
#include "alp/rtc.h"

int main(void) {
    alp_rtc_t *rtc = alp_rtc_open(0);          /* RTC instance 0 */
    if (rtc == NULL) {
        printf("[rtc] open failed: alp_last_error=%d\n", (int)alp_last_error());
        return 0;
    }

    alp_rtc_time_t set_t = {
        .year = 2026, .month = 5, .day = 10,
        .hour = 14,   .minute = 30, .second = 0,
    };
    alp_status_t s = alp_rtc_set_time(rtc, &set_t);
    printf("[rtc] set_time(2026-05-10 14:30:00) -> %d\n", (int)s);

    alp_delay_ms(250);

    alp_rtc_time_t got;
    s = alp_rtc_get_time(rtc, &got);
    printf("[rtc] get_time -> status=%d, %04u-%02u-%02u %02u:%02u:%02u\n", (int)s,
           got.year, got.month, got.day, got.hour, got.minute, got.second);

    alp_rtc_close(rtc);
    return 0;
}
```

## On-module RTC (V2N)

V2N modules carry a Micro Crystal RV-3028-C7 on `BRD_I2C` (`0x52`) alongside the SoC RTC. As of alp-sdk v0.17.0 that bus is A55/Linux-exclusive, so on V2N the RV-3028-C7 is bound by the Linux kernel and exposed as `/dev/rtc0`; use the standard Linux RTC interface from the A55. The former `v2n-rtc-multi-alarm` example, which drove it from the Cortex-M33, was retired for that reason.

## See also

- [`<alp/rtc.h>` reference](https://docs.alplab.ai/sdk/api/rtc)
- [Examples overview](https://docs.alplab.ai/sdk/examples/overview)
