Files
arcs/arcs-sdk/samples/drivers/devices/lisa_rtc/time_basic

LISA RTC 基础时间示例

功能说明

本示例演示如何使用 LISA RTC 驱动进行时间读写操作。

硬件连接

无需外部连接,RTC 为芯片内部外设。

示例内容

  1. 初始化 RTC 设备
  2. 设置当前时间为 2025-01-15 12:30:00
  3. 循环读取并显示当前时间

编译

.. include:: /sample_build.rst

预期输出

=== LISA RTC time example ===
rtc0 device ready
RTC time set: 2025-01-15 12:30:00
Start reading RTC time...
Current time: 2025-01-15 12:30:00
Current time: 2025-01-15 12:30:01
Current time: 2025-01-15 12:30:02
Current time: 2025-01-15 12:30:03
...

参数说明

  • 设备名称: rtc0
  • 初始时间: 2025-01-15 Wednesday 12:30:00
  • 读取间隔: 1秒

注意事项

  1. 时间格式: ARCS 使用 CALENDAR 外设,支持完整的年/月/日/星期/时/分/秒
  2. 年份范围: 0-127(建议使用两位数,如 25 代表 2025 年)
  3. 时间精度: 秒级精度
  4. 自动校准: 驱动会自动启用时钟校准功能