RTC Example

Source code path: example/hal/rtc

Supported Platforms

  • sf32lb52-lcd_n16r8

  • sf32lb58-lcd_n16r64n4

Overview

This example demonstrates HAL layer RTC usage, including:

  • RTC initialization configuration.

  • Setting date and time, reading date and time.

  • Setting Alarm.

Example Usage

Hardware Requirements

Before running this example, you need to prepare a development board supported by this example

Compilation and Programming

Switch to the example project directory and run the scons command to compile:

scons --board=sf32lb52-lcd_n16r8 -j32

Run build_sf32lb52-lcd_n16r8_hcpu\uart_download.bat, select the port as prompted to download:

$ ./uart_download.bat

     Uart Download

please input the serial port num:5

For detailed steps on compilation and downloading, please refer to the relevant introduction in Getting Started Guide.

Expected Results

After the example starts, the serial port outputs the following:

  1. Initialization

10-08 23:04:30:177    SFBL
10-08 23:04:32:397    RTC use LXT RTC_CR=00000001
10-08 23:04:32:399    RTC Init success.
  1. Set system time to 2025/01/01 08:30:00

10-08 23:04:32:401    SET RTC TIME : Wed Jan  1 08:30:00 2025
10-08 23:04:32:403    GET RTC TIME : Wed Jan  1 08:30:00 2025
  1. Set Alarm, arrival time: 08:31:00

10-08 23:04:32:405    SET ALARM : [8 31 0]
  1. Alarm arrives

10-08 23:05:31:464    GET RTC TIME : Wed Jan  1 08:30:59 2025
10-08 23:05:32:394    Alarm triggered.
10-08 23:05:32:462    GET RTC TIME : Wed Jan  1 08:31:00 2025
  1. Periodically get system time (every second)

10-08 23:05:34:633    GET RTC TIME : Wed Jan  1 08:31:02 2025
10-08 23:05:35:460    GET RTC TIME : Wed Jan  1 08:31:03 2025
10-08 23:05:36:473    GET RTC TIME : Wed Jan  1 08:31:04 2025

Exception Diagnosis

Reference Documents

Update Log

Version

Date

Release Notes

0.0.1

10/2024

Initial version