4.3 RTC
This example demonstrates how to use Linux API to read and write real time on
RTC
,
please refer to the source code for detail. Users can also test the RTC with
date
and
hwclock
command built with Buildroot.
Hardware Preparation:
Hardware debugging environment to see chapter second.
CR1220 3V button cell
Board Type
MYD-AM335X
MYD-AM335X-Y
MYD-AM335X-J
CR1220 button cell
J1
J2
J23
Software Preparation:
Linux Kernel 4.1.18
date, hwclock command
rtc_test application
Test Steps:
Copy cross compiled
<WORKDIR>/Examples/rtc/rtc_test
to
/usr/bin
directory of the
MYD-AM335X seriesdevelopment board, run
rtc_test
application as below:
# chmod 777 /usr/bin/rtc_test
# rtc_test -h
Usage: rtc_test [options]
Version 1.0
Options:
-d | --device name rtc device name, default: /dev/rtc0
-w | --write time time string with format MMDDhhmm[CCYY][.ss]. such as: 111817582
016.18
-h | --help Print this message
# rtc_test -d /dev/rtc -w 111817582016.18
date/time is updated to: 18-11-2016, 17:58:18.
Power off the development board, wait for a while, power on again and read the
rtc time by
rtc_test
as below:
37