Information on the module guide itself and the associated resources and known issues are available here.
The Real-Time Clock (RTC) HAL module is a high-level API for RTC applications and is implemented on r_rtc. The RTC HAL module configures the RTC module and controls clock, calendar, and alarm functions. The RTC uses the real-time clock module on the Synergy MCU. A user-defined callback can be created to respond to any of the three supported interrupt types- alarm, periodic, or carry.
The RTC HAL module supports the following features:
- RTC peripheral configuration
- Clock and calendar functions:
- Alarm, periodic, and carry interrupts
- Time-capture function
- Event linkage to other peripherals
The r_rtc HAL module guide is targeted for SSP 1.2.0 and above and the SK-S7G2 Kit.
The most recent versions of the RTC HAL module guide application note, application project and import guide are available here
Module Guide Errata
Section 1- Features added bullets
- RTC sub-clock error adjustment
- RTC status get
Section 3.1.2- RTC HAL Module Limitations edit to bullet
- LOCO clock-error correction
Section 6- Using the RTC HAL Module in an Application added sections
Avoid drift issue after reset
To avoid drift in RTC time across MCU reset, the application needs to follow the steps given below.
Make these changes to module configuration settings:
- Disable the “Configure Subclock Drive On Reset” option in the CGC stack element of the ISDE configurator.
- Disable the “Configure RTC hardware in open() call” option in the RTC stack element of the ISDE configurator.
Make these calls in the application code:
- Call the RTC open API as usual.
- Call the RTC configure API only on a cold start. This will initialize the RTC only in a cold start condition.
The aforementioned steps can be performed by using the following initialization sequence in the application:
/* initialize RTC if its status is stopped state i.e. on cold start */
if(RTC_STATUS_STOPPED == info1.status)
/* if the RTC clock source is sub-clock, stop it so that the sub-clock drive capacity is set correctly in the configure API */
An alternative way to determine cold start condition (instead of status) is to obtain the information from the reset status registers (RSTSRx).
Date and Time validation
The “Parameter Checking” needs to be enabled in the ISDE configurator if date and time validation is required for calendarTimeSet and calendarAlarmSet APIs. If “Parameter Checking” is enabled, the 'day of the week' field is automatically calculated and updated by the driver for the provided date. When using the calendarAlarmSet API, only the fields which have their corresponding match flag set are written to the registers. Other register fields are reset to default value.
Sub-Clock error adjustment
The errorAdjustmentModeSet and errorAdjustmentSet APIs can be used to correct the error in the RTC sub-clock source. These APIs need to be used only after the RTC is configured and time is set.
The error adjustment is reset every time RTC is reconfigured or time is set.
The configuration property ‘Configure RTC hardware in open() call’ in the RTC stack of ISDE configurator controls the behavior of open API. If enabled, the RTC peripheral is configured in the open API. If disabled, it is the responsibility of the application to make sure that RTC is configured before usage, by using the configure API.
Module Guide Resources
- The RTC HAL module is used in the Developer Examples available for the DK-S7G2. You can find a Knowledge Base article that describes the Developer Examples and how to create a project using the template here.
- Refer to the SSP release notes for known issues, available here.