This article introduces how to use the RTC (real-time clock) implemented on the evaluation board with SoC FPGA (how to set the time).
1. Introduction
Many evaluation boards with SoC FPGAs, including the Mpression Sodia board, have an RTC (real-time clock) implemented. By loading the button battery specified by the board, the time set in the RTC can be backed up by battery backup, which is useful for cases where you want to record time stamps in the log information during evaluation/verification.
2. Button battery loading
Refer to the evaluation board manual or circuit diagram for the button battery to be used. Also check the datasheet specs of the RTC product, such as the voltage of the battery power supply at, to be sure.
For the Soida board, the RTC is the DS1339 I2C Serial Real-Time Clock (DS1339C-33#) from maxim.
The button battery is BR-1225.
The red frame in the image below is the button battery slot for battery backup of the RTC.
The button battery designation was indicated in the schematic.
3. Time setting (supported by Linux commands)
The time setting of the RTC can be handled by the hwclock command if you use the reference environment for Linux.
- hwclock --show .. Displays the current RTC time.
- hwclock --systohc .. Reflects system time to RTC time
- hwclock --hctosys .. Reflects the RTC time to the system time
The system time is set by the date command.
- date -s "YYYYY-MM-DD HH:MM:SS"
The following is a log of the actual test results.
root@cyclone5:~# date -s "2019-06-20 13:55:00" <-- Set system time
Thu Jun 20 13:55:00 UTC 2019
root@cyclone5:~# hwclock --systohc <-- Save system time to RTC
root@cyclone5:~# hwclock --show
Thu Jun 20 13:55:11 2019 0.000000 seconds <-- Confirm that the RTC time is reflected
root@cyclone5:~#
root@cyclone5:~#
root@cyclone5:~# date -s "2020-12-31 13:55:00" <-- Change system time (do not store in RTC)
Thu Dec 31 13:55:00 UTC 2020
root@cyclone5:~#
: * Power on again
cyclone5 login: root
Last login: Wed Sep 26 03:39:19 UTC 2018 on ttyS0
root@cyclone5:~#
root@cyclone5:~#
root@cyclone5:~#
root@cyclone5:~#
root@cyclone5:~# date
Thu Jun 20 13:55:56 UTC 2019 <-- Reflects last saved RTC time in system time
root@cyclone5:~#
Summary
In case of Linux, the driver for maxim RTC (DS1339) is prepared in advance, so it is very easy to set up just by executing the commands for RTC setting as described above.
For other than Linux, it is possible that the RTOS supports the same function, but basically it is necessary to refer to the datasheet of the RTC product and send commands via I2C interface.