Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
RTC standalone driver

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

Table of Contents

Table of Contents
excludeTable 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

Table of Contents

operational when the low-power domain supply is ON.
The RTC has an alarm function that generates an alarm at a specific time and date with a 136-year range.
The RTC also has periodic software calibration and logic to correct the static fractional inaccuracy of an oscillator.

How to enable

Source Path for the driver
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


Info

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/

commits/master

tree/xilinx-v2020.1/XilinxProcessorIPLib/drivers/rtcpsu

Driver


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

  • Maintains the real time, even when the device is off (powered-off).
  • Has the capability to generate an alarm at a specific time and date.
  • Includes the means for periodic software calibration of the RTC.
  • Includes logic to correct the static fractional inaccuracy of the oscillator.
  • Keeps track of time within a window of more than 136 years (232 seconds) from a reference point.
  • Implemented as three counters.
    • 16-bit tick counter creates one second based on the crystal clock.
    • 4-bit fraction counter keeps track of the static crystal errors in one second that is less than one oscillator tick.
    • 32-bit seconds counter holds the real time and allows on-demand reload whenever current time of the RTC is set.
  • Allows wake-up at a specific second within the 136 years (32-bit alarm)

Driver Supported Features

The RTC Standalone driver support the below things.
  • All controller features supported.

Known Issues and Limitations

  • None.

...


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.

...


Test NameExample Source

Description


Alarmxrtcpsu_alarm_interrupt_example.c

...

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

xrtcpsu_alarm_polled_example.c

...

This 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.c

...

This 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.c

...

This seconds example uses the XRtcPsu driver in interrupt mode.

xrtcpsu_seconds_polled_example.c

...

This seconds example uses the XRtcPsu driver in polled mode.
Calibrationxrtcpsu_set_calibration_example.c

...

This example uses the XRtcPsu driver to update the calibration register value

...

Set Timexrtcpsu_set_time_example.c

...

This example uses the XRtcPsu driver to update the current time.

...

Change Log

  • 2017.1

    • Summary
      • rtcpsu : Fixed compilation warnings
      • RTCPSU : Corrected calibration and frequency macros.
      • rtcpsu: Added readme.txt file to generate doxygen for examples
    • Commits
      • dc92361 : rtcpsu : Fixed compilation warnings.
      • 91ee3a6 : RTCPSU : Corrected calibration and frequency macros.
      • 49a6a78 : rtcpsu: Added readme.txt file to generate doxygen for examples.
  • 2017.2

    • Summary
      • rtcpsu: Modified filename tag in examples
    • Commits
      • d65236a : rtcpsu: Modified filename tag in examples
  • 2017.3

    • Summary
      • rtcpsu: Fixed compilation warnings
      • rtcpsu: Code cleanup
    • Commits
      • 61974ae : rtcpsu: Fixed compilation warnings.
      • dc74ed7 : rtcpsu: Code cleanup.
  • 2018.1

    • None
  • 2018.2

    • None
  • 2018.3

    • None
  • 2019.1

    • Summary
      • rtcpsu: Fixed MISRA-C warnings
    • Commits
      • cd670acMISRA-C:No brackets to loop body
      • f79d426MISRA-C:No brackets to then/else
      • e8eb02aMISRA-C:Casting operation to a pointer
      • fc917b6MISRA-C:Array has no bounds specified
      • dddc939MISRA-C:Literal value requires a U suffix
      • b37d04eMISRA-C:Logical conjunctions need brackets
      • dd928e7MISRA-C:Pointer param should be declared pointer to const
      • 405723bUpdated year and change version history

...

  • Summary
    • rtcpsu: Corrected calibration algorithm
    • rtcpsu: Updated set calibration example with right sequence
  • Commits
    • 575af1b1  rtcpsu: Corrected calibration algorithm
    • 09ec4457 rtcpsu: Updated set calibration example with right sequence

...

2020.1

  • None

2020.2

...

  • rtcpsu: Update Makefile for parallel make execution
  • rtcpsu: MISRA-C fixes

...

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

Code Block
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


Code Block
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

Code Block
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

Code Block
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


Related Links