RTC示例
源码路径:example/rt_device/rtc
支持的平台
em-lb525
em-lb587
概述
例程演示基于RT device框架的系统时间设置、系统时间读取以及闹钟使用:
设置日期时间、读取日期时间。
设置Alarm。
例程的使用
硬件需求
运行该例程前,需要准备一块本例程支持的开发板
编译和烧录
切换到例程project目录,运行scons命令执行编译:
scons --board=em-lb525 -j32
运行build_em-lb525_hcpu\uart_download.bat
,按提示选择端口即可进行下载:
$ ./uart_download.bat
Uart Download
please input the serial port num:5
关于编译、下载的详细步骤,请参考上手指南的相关介绍。
例程的预期结果
例程启动后,串口输出如下:
设置系统时间为2024/01/01 08:30:00
10-09 11:01:46:350 set system time (by RT DEVICE): 2024 01 01 08:30:00
10-09 11:01:46:352 current system time: 2024 01 01 08:30:00
设置系统时间为2024/02/01 08:30:00
10-09 11:01:46:354 set system time (by RTT API): 2024 02 01 08:30:00
10-09 11:01:46:356 current system time: 2024 02 01 08:30:00
设置单次闹钟,闹钟达到时间为08:32:00
10-09 11:01:46:358 SET ONESHOT ALARM : [08:32:00]
闹钟到达
10-09 11:03:46:301 Alarm triggered at 2024 02 01 08:32:00
周期获取系统时间(每秒)
10-09 11:03:56:885 current system time: 2024 02 01 08:32:11
10-09 11:03:57:852 current system time: 2024 02 01 08:32:12
10-09 11:03:58:880 current system time: 2024 02 01 08:32:13
10-09 11:03:59:847 current system time: 2024 02 01 08:32:14
10-09 11:04:00:861 current system time: 2024 02 01 08:32:15
异常诊断
参考文档
更新记录
版本 |
日期 |
发布说明 |
---|---|---|
0.0.1 |
10/2024 |
初始版本 |