匿名
未登录
登录
百问网嵌入式Linux wiki
搜索
查看“How to use the RTC”的源代码
来自百问网嵌入式Linux wiki
名字空间
页面
讨论
更多
更多
页面选项
Read
查看源代码
历史
←
How to use the RTC
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
__TOC__ <br /> ==Purpose== 本文介绍了如何使用RTC。 [[RTC overview]]文章中介绍了RTC概述。 <br/> == How to set a hardware clock using the hwclock tool == The correct system time must first be set with the date command. Type the date command to see the date and time format of the string: {{Board$}} date Fri Mar 9 12:18:51 UTC 2018 {{Board$}} date --set="Fri Mar 9 19:18:51 UTC 2018" Fri Mar 9 19:18:51 UTC 2018 Set the hardware clock to this date: {{Board$}} hwclock Fri Mar 9 12:21:03 2018 0.000000 seconds {{Board$}} hwclock --systohc --utc {{Board$}} hwclock Fri Mar 9 19:19:52 2018 0.000000 seconds See <ref name="date">http://man7.org/linux/man-pages/man1/date.1.html</ref> for more about date settings. See <ref name="hwclock">http://man7.org/linux/man-pages/man8/hwclock.8.html</ref> for more about hwclock settings. == How to set an alarm == {{highlight|# disable the alarm}} {{Board$}} echo 0 > /sys/class/rtc/rtc0/wakealarm {{highlight|# calculate alarm with 1 minute later}} {{Board$}} wakeuptime=`date -d "1 minute" +%s` {{highlight|# set the alarm}} {{Board$}} echo $wakeuptime > /sys/class/rtc/rtc0/wakealarm root@stm32mp1:~# [ 829.279019] rtc rtc0: Alarm occurred You can also set an alarm 'n' seconds later: {{Board$}} echo +10 > /sys/class/rtc/rtc0/wakealarm == How to set an alarm and go into a system sleep state with the rtcwake tool == {{highlight|# calculate an alarm 1 minute later}} {{Board$}} wakeuptime=`date -d "1 minute" +%s` {{highlight|# set wakeup on /dev/rtc0}} {{Board$}} rtcwake -lt$wakeuptime -m mem rtcwake: wakeup from "mem" using /dev/rtc0 at Sun Mar 11 10:48:06 2018 [ 154.022303] PM: suspend entry (deep) [ 154.024421] PM: Syncing filesystems ... done. [ 154.037258] Freezing user space processes ... (elapsed 0.001 seconds) done. [ 154.044397] OOM killer disabled. [ 154.047555] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done. [ 154.055039] Suspending console(s) (use no_console_suspend to debug) One minute later... NOTICE: CPU: STM32MP157CAA Rev.B NOTICE: Model: STMicroelectronics STM32MP157C eval daughter on eval mother NOTICE: Board: MB1263 Var1 Rev.C-01 INFO: Reset reason (0x810): INFO: System exits from STANDBY INFO: Using SDMMC INFO: Instance 1 INFO: Boot used partition fsbl1 INFO: Product_below_2v5=1: HSLVEN update is INFO: destructive, no update as VDD>2.7V NOTICE: BL2: v2.0(debug):v2.0-stm32mp-19-01-29 NOTICE: BL2: Built : 15:58:42, Jan 29 2019 INFO: BL2: Doing platform setup INFO: PMIC version = 0x10 INFO: RAM: DDR3-1066/888 bin G 2x4Gb 533MHz v1.41 INFO: BL2 runs SP_MIN setup INFO: BL2: Loading image id 4 INFO: Loading image id=4 at address 0x2ffe5000 INFO: Image id=4 loaded: 0x2ffe5000 - 0x30000000 INFO: BL2: Skip loading image id 5 INFO: read version 0 current version 0 NOTICE: BL2: Booting BL32 INFO: Entry point address = 0x2ffe5000 INFO: SPSR = 0x1d3 INFO: PMIC version = 0x10 NOTICE: SP_MIN: v2.0(debug):v2.0-stm32mp-19-01-29 NOTICE: SP_MIN: Built : 15:58:42, Jan 29 2019 INFO: ARM GICv2 driver initialized INFO: stm32mp HSI (18): Secure only INFO: stm32mp HSE (20): Secure only INFO: stm32mp PLL2 (27): Secure only INFO: stm32mp PLL2_R (30): Secure only INFO: SP_MIN: Initializing runtime services INFO: SP_MIN: Preparing exit to normal world [ 154.074319] dwc2 49000000.usb-otg: suspending usb gadget configfs-gadget [ 154.196804] Disabling non-boot CPUs ... [ 154.250046] CPU1 killed. [ 154.251704] Enabling non-boot CPUs ... [ 154.252697] CPU1 is up [ 154.254885] rtc rtc0: Alarm occurred [ 154.273940] dwmac4: Master AXI performs any burst length [ 154.273972] stm32-dwmac 5800a000.ethernet eth0: No Safety Features support found [ 154.276938] usb usb2: root hub lost power or was reset [ 154.284703] dwc2 49000000.usb-otg: resuming usb gadget configfs-gadget [ 154.491151] dwc2 49000000.usb-otg: new device is high-speed [ 154.619589] dwc2 49000000.usb-otg: new device is high-speed [ 154.669343] usb 2-1: reset high-speed USB device number 2 using ehci-platform [ 154.697272] dwc2 49000000.usb-otg: new address 2 [ 154.722774] configfs-gadget gadget: high-speed config #1: c [ 155.066198] OOM killer enabled. [ 155.069339] Restarting tasks ... done. [ 155.075470] PM: suspend exit See <ref name="rtcwake">http://man7.org/linux/man-pages/man8/rtcwake.8.html</ref> for more about rtcwake settings. ==References== <references/> <noinclude> [[Category:RTC|3]] {{PublicationRequestId |15042 | 2020-02-21}} </noinclude>
该页面使用的模板:
模板:Board$
(
查看源代码
)
模板:Highlight
(
查看源代码
)
返回至
How to use the RTC
。
导航
导航
WIKI首页
官方店铺
资料下载
交流社区
所有页面
所有产品
MPU-Linux开发板
MCU-单片机开发板
Linux开发系列视频
单片机开发系列视频
所有模块配件
Wiki工具
Wiki工具
特殊页面
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志