This page gives an overview of the bare-metal driver support for the Real Time Clock(RTC) module.

Table of Contents

Introduction

The Zynq® UltraScale+™ MPSoC real time clock (RTC) provides the real time even when the device is powered off.
When the device is off, the RTC is switched to the battery power supply. A battery-backed RAM (BBRAM) is
provided for when device is operating in the battery mode. However, the RTC controller and user interface are only
For more information, please refer Chapter 7: Real Time Clock in Zynqmp Trm which includes links to the official documentation and resource utilization. 

Driver Sources

The source code for the driver is included with the Vitis Unified Software Platform installation, as well as being available in the Xilinx Github repository. 

Driver Name

Path in Vitis

Path in Github

rtcpsu

<Vitis Install Directory>/data/embedded/XilinxProcessorIPLib/drivers/rtcpsu

https://github.com/Xilinx/embeddedsw/tree/master/XilinxProcessorIPLib/drivers/rtcpsu


Note: To view the sources for a particular release, use the rel-version tag in github.  For example, for the 2020.1 release, the proper version of the code is: https://github.com/Xilinx/embeddedsw/tree/xilinx-v2020.1/XilinxProcessorIPLib/drivers/rtcpsu


The driver source code is organized into different folders. The table below shows the rtcpsu driver source organization.

DirectoryDescription
srcDriver source files, make and cmakelists file
examplesExample applications that show how to use the driver features
docProvides the API and data structure details
dataDriver .tcl , .mdd and .yaml files

Note: AMD Xilinx embeddedsw build flow is changed from 2023.2 release to adapt to the new system device tree based flow. For further information, refer to the wiki page Porting embeddedsw components to system device tree (SDT) based flow - Xilinx Wiki - Confluence (atlassian.net).

The .yaml(in data folder) and CMakeLists.txt(in src folder) files are needed for the System Device Tree based flow. The Driver .tcl and .mdd files are for the older build flow which will be deprecated in the future.

Driver Implementation

For a full list of features supported by this IP, please refer Chapter 7: Real Time Clock in Zynqmp Trm

Features Supported in the driver

Controller Features supported

Driver Supported Features

The RTC Standalone driver support the below things.

Known Issues and Limitations


Example Applications

Refer to the driver examples directory for various example applications that exercise the different features of the driver. Each application is linked in the table below. The following sections describe the usage and expected output of the various applications.  These example applications can be imported into the Vitis IDE from the Board Support Package  settings tab.

Links to Examples

Examples Path:

https://github.com/Xilinx/embeddedsw/tree/master/XilinxProcessorIPLib/drivers/rtcpsu


Test NameExample Source

Description


Alarmxrtcpsu_alarm_interrupt_example.cThis alarm example uses the XRtcPsu driver in interrupt mode. It sets alarm for a specified time from the current time.

xrtcpsu_alarm_polled_example.cThis alarm example uses the XRtcPsu driver in polled mode. It sets alarm for a specified time from the current time.

xrtcpsu_periodic_alarm_interrupt_example.cThis periodic alarm example using the XRtcPsu driver in interrupt mode. It sets periodical alarm for specified times from the current time. For demontration purpose, a periodic alarm for future.
secondsxrtcpsu_seconds_interrupt_example.cThis seconds example uses the XRtcPsu driver in interrupt mode.

xrtcpsu_seconds_polled_example.cThis seconds example uses the XRtcPsu driver in polled mode.
Calibrationxrtcpsu_set_calibration_example.cThis example uses the XRtcPsu driver to update the calibration register value
Set Timexrtcpsu_set_time_example.cThis example uses the XRtcPsu driver to update the current time.

Example Application Usage

RTC  Alarm examples

This alarm example uses the XRtcPsu driver in interrupt mode. It sets alarm for a specified time from the current time.

Expected Output

xrtcpsu_alarm_interrupt_example.c
OUTPUT:
Day Convention : 0-Fri, 1-Sat, 2-Sun, 3-Mon, 4-Tue, 5-Wed, 6-Thur
Current RTC time is..
YEAR:MM:DD HR:MM:SS 	 2021:06:28 16:56:23	 Day = 3
Alarm generated.
Successfully ran RTC Alarm Polled Mode Example Test

xrtcpsu_alarm_polled_example.c
OUTPUT:
Day Convention : 0-Fri, 1-Sat, 2-Sun, 3-Mon, 4-Tue, 5-Wed, 6-Thur
Current RTC time is..
YEAR:MM:DD HR:MM:SS 	 2021:06:28 15:51:25	 Day = 3
Alarm generated.
Successfully ran RTC Alarm Polled Mode Example Test

xrtcpsu_periodic_alarm_interrupt_example.c
OUTPUT:
Day Convention : 0-Fri, 1-Sat, 2-Sun, 3-Mon, 4-Tue, 5-Wed, 6-Thur
Current RTC time is..
YEAR:MM:DD HR:MM:SS 	 2021:06:28 17:27:34	 Day = 3
2Sec Periodic Alarm generated.
2Sec Periodic Alarm generated.
2Sec Periodic Alarm generated.
2Sec Periodic Alarm generated.
2Sec Periodic Alarm generated.
2Sec Periodic Alarm generated.
2Sec Periodic Alarm generated.
2Sec Periodic Alarm generated.
2Sec Periodic Alarm generated.
2Sec Periodic Alarm generated.
Successfully ran RTC Periodic Alarm Interrupt Example Test

RTC  Seconds examples

This seconds example uses the XRtcPsu driver in interrupt mode.

Expected Output


xrtcpsu_seconds_polled_example.c
OUTPUT:
Seconds value is 01.
Seconds value is 02.
Seconds value is 03.
Seconds value is 04.
Seconds value is 05.
Seconds value is 06.
Seconds value is 07.
Seconds value is 08.
Seconds value is 09.
Seconds value is 10.
Seconds feature tested.
Successfully ran RTC Seconds Polled Mode Example Test

xrtcpsu_seconds_interrupt_example.c
OUTPUT:
A new second is generated.
A new second is generated.
A new second is generated.
A new second is generated.
A new second is generated.
A new second is generated.
A new second is generated.
A new second is generated.
A new second is generated.
A new second is generated.
Successfully ran RTC Seconds Interrupt Example Test




RTC  Calibration examples

Expected Output

xrtcpsu_set_calibration_example.c
OUTPUT:Enter Crystal oscillator frequency : 
Enter Internet / Network Time YEAR:MM:DD HR:MM:SS : 2021 6 28 17 39 44

Old Calibration value : 00007FFF Crystal Frequency : 00008000
New Calibration value : FFFEFFFF Crystal Frequency : 00008000
Successfully ran RTC Set Calibration Example Test


RTC  Set timeout examples

Expected Output

xrtcpsu_set_time_example.c
OUTPUT:
Day Convention : 0-Fri, 1-Sat, 2-Sun, 3-Mon, 4-Tue, 5-Wed, 6-Thur
Last set time for RTC is..
YEAR:MM:DD HR:MM:SS 	 2049:08:31 14:11:07	 Day = 4
Current RTC time is..
YEAR:MM:DD HR:MM:SS 	 2049:09:27 02:48:07	 Day = 3
Enter Desired Current Time YEAR:MM:DD HR:MM:SS : 2021 6 28 15 50 45
Successfully ran RTC Set time Example Test


Example Design Architecture

NA


Change Log

Related Links