Cy_RTC_Init(cy_stc_rtc_config_t const *config)
Initializes the RTC driver.
Cy_RTC_SetDateAndTime(cy_stc_rtc_config_t const *dateTime)
Sets the time and date values into the RTC_TIME and RTC_DATE registers.
The function may return CY_RTC_INVALID_STATE if the RTC is busy with previous update. In such situation, user should call this function repetitively with appropriate parameters to ensure that RTC is updated with provided arguments.
Gets the current RTC time and date.
The AHB RTC Time and Date register values are stored into the *dateTime structure.
dateTime: The RTC time and date structure. See Data Structures.
Cy_RTC_SetDateAndTimeDirect(uint32_t sec, uint32_t min, uint32_t hour, uint32_t date, uint32_t month, uint32_t year)
Sets the time and date values into the RTC_TIME and RTC_DATE registers using direct time parameters.
The function reads the current 12/24-hour mode, then converts the hour value properly as the mode.
sec: The second valid range is [0-59].
min: The minute valid range is [0-59].
hour: The hour valid range is [0-23]. This parameter should be presented in the 24-hour format.
A validation check result of date and month. Returns an error, if the date range is invalid or the RTC time and date set was cancelled: the RTC Write bit was not set, the RTC was synchronizing. See cy_en_rtc_status_t.
date: The date valid range is [1-31], if the month of February is selected as the Month parameter, then the valid range is [0-29].
month: The month valid range is [1-12].
year: The year valid range is [0-99].
Sets the 12/24-hour mode.
Selects the RTC pre-scaler value and changes its clock frequency.
If the external 32.768 kHz WCO is absent on the board, the RTC can be driven by a 32.768kHz square clock source or an external 50-Hz or 60-Hz sine-wave clock source, for example the wall AC frequency.
In addition to generating the 32.768 kHz clock from external crystals, the WCO can be sourced by an external clock source (50 Hz or 60Hz), even the wall AC frequency as a timebase. The API helps select between the RTC sources:
A 32.768 kHz digital clock source.
An external 50-Hz or 60-Hz sine-wave clock source.
clkSel: clock frequency, see cy_en_rtc_clock_freq_t.
If you want to use an external 50-Hz or 60-Hz sine-wave clock source to drive the RTC, the next procedure is required:
Disable the WCO
Bypass the WCO using the Cy_SysClk_WcoBypass() function.
Configure both wco_out and wco_in pins. Note that only one of the wco pins should be driven and the other wco pin should be floating, which depends on the source that drives the RTC (*1).
Call Cy_RTC_SelectFrequencyPrescaler(CY_RTC_FREQ_60_HZ), if you want to drive the WCO, for example, with a 60 Hz source.
Enable the WCO.
If you want to use the WCO after using an external 50-Hz or 60-Hz sine-wave clock source:
Disable the WCO.
Switch-off the WCO bypass using the Cy_SysClk_WcoBypass() function.
Drive off the wco pin with an external signal source.
Enable the WCO.
(1) - Refer to the device TRM to know how to configure the wco pins properly and which wco pin should be driven/floating.
There is a limitation to the external clock source frequencies. Only two frequencies are allowed - 50 Hz or 60 Hz. Note that this limitation is related to the RTC pre-scaling feature presented in this function. This limitation is not related to WCO external clock sources which can drive the WCO in Bypass mode.
This API is available for CAT1A devices.