Real-time clock (RTC) is a clock that keeps track of the current time. Precise real time keeping is with a 32.768 KHz external crystal clock or a 32.768 KHz high precision internal clock. It provides a periodic time based interrupt and a programmable alarm interrupt on time match. It also supports wakeup from hibernate.
The RTC low level driver provides functions to configure and initialize the RTC hardware peripheral.
Also, the RTC block can be configured from the ModusToolbox™ Device Configurator: section_personality_rtc
◆ XMC_RTC_DEBUG_MODE_t
Debug mode status values
Enumerator |
---|
XMC_RTC_RUN_IN_DEBUG_MODE | RTC is not stopped during halting mode debug
|
XMC_RTC_STOP_IN_DEBUG_MODE | RTC is stopped during halting mode debug
|
◆ XMC_RTC_EVENT_t
Events which enables interrupt request generation
Enumerator |
---|
XMC_RTC_EVENT_PERIODIC_SECONDS | Mask value to enable an event on periodic seconds
|
XMC_RTC_EVENT_PERIODIC_MINUTES | Mask value to enable an event on periodic minutes
|
XMC_RTC_EVENT_PERIODIC_HOURS | Mask value to enable an event on periodic hours
|
XMC_RTC_EVENT_PERIODIC_DAYS | Mask value to enable an event on periodic days
|
XMC_RTC_EVENT_PERIODIC_MONTHS | Mask value to enable an event on periodic months
|
XMC_RTC_EVENT_PERIODIC_YEARS | Mask value to enable an event on periodic years
|
XMC_RTC_EVENT_ALARM | Mask value to enable an alarm event
|
◆ XMC_RTC_MONTH_t
Months used to program the date
◆ XMC_RTC_STATUS_t
Status return values for RTC low level driver
Enumerator |
---|
XMC_RTC_STATUS_OK | Operation successful
|
XMC_RTC_STATUS_ERROR | Operation unsuccessful
|
XMC_RTC_STATUS_BUSY | Busy with a previous request
|
◆ XMC_RTC_WEEKDAY_t
Week days used program the date
◆ XMC_RTC_ClearEvent()
void XMC_RTC_ClearEvent |
( |
const uint32_t |
event | ) |
|
- Parameters
-
event | A valid RTC event (XMC_RTC_EVENT_t) or a valid combination of logically OR'd events |
- Returns
- None
- Description:
- Clears periodic and alarm event(s) status
- The function sets the bitfields of CLRSR register to clear status bits in RAWSTAT and STSSR registers. Setting the value for the the RTC event(s) containing in the XMC_RTC_EVENT_t clears the corresponding status bits in RAWSTAT and STSSR registers.
- Related APIs:
- XMC_RTC_GetEventStatus()
◆ XMC_RTC_Disable()
void XMC_RTC_Disable |
( |
void |
| ) |
|
- Returns
- None
- Description
- Disables RTC peripheral for programming its registers
- Gates the peripheral clock.
- Related APIs:
- XMC_RTC_Enable(), XMC_SCU_RESET_AssertPeripheralReset()
◆ XMC_RTC_DisableEvent()
void XMC_RTC_DisableEvent |
( |
const uint32_t |
event | ) |
|
- Parameters
-
event | A valid RTC event (XMC_RTC_EVENT_t) or a valid combination of logically OR'd events |
- Returns
- None
- Description:
- Disable RTC periodic and alarm event(s)
- The function resets the bitfields of MSKSR register to disable interrupt generation for requested RTC event(s). Resetting the masking value for the the event(s) containing in the XMC_RTC_EVENT_t blocks the generation of the interrupt.
- Related APIs:
- XMC_RTC_EnableEvent()
◆ XMC_RTC_Enable()
void XMC_RTC_Enable |
( |
void |
| ) |
|
- Returns
- None
- Description
- Enables RTC peripheral for programming its registers
- Ungates the peripheral clock.
- Related APIs:
- XMC_RTC_Disable(), XMC_SCU_RESET_DeassertPeripheralReset()
◆ XMC_RTC_EnableEvent()
void XMC_RTC_EnableEvent |
( |
const uint32_t |
event | ) |
|
- Parameters
-
event | A valid RTC event (XMC_RTC_EVENT_t) or a valid combination of logically OR'd events |
- Returns
- None
- Description:
- Enable RTC periodic and alarm event(s)
- The function sets the bitfields of MSKSR register to enable interrupt generation for requested RTC event(s). Setting the masking value for the event(s) containing in the XMC_RTC_EVENT_t leads to a generation of the interrupt.
- Related APIs:
- XMC_RTC_DisableEvent()
◆ XMC_RTC_GetAlarm()
- Parameters
-
alarm | Pointer to a constant XMC_RTC_ALARM_t structure containing the time parameters alarm seconds, alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month and alarm year. |
- Returns
- None
- Description:
- Gets the RTC module alarm time value
- The function gets the alarm time values from ATIM0, ATIM1 registers. See the structure XMC_RTC_ALARM_t for the valid range of alarm time value parameters.
- Related APIs:
- XMC_RTC_SetAlarm()
◆ XMC_RTC_GetAlarmStdFormat()
void XMC_RTC_GetAlarmStdFormat |
( |
struct tm *const |
stdtime | ) |
|
- Parameters
-
stdtime | Pointer to a constant ::tm structure containing the time parameters alarm seconds, alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month, alarm year(since 1900) and alarm days in a year in standard format. |
- Returns
- None
- Description:
- Gets the RTC module alarm time value in standard format
- The function gets the alarm time values from ATIM0, ATIM1 registers. See the structure XMC_RTC_ALARM_t for the valid range of alarm time value parameters.
For days the valid range is (1 - Actual days of month), year (since 1900) and daysinyear (0 -365).
- Related APIs:
- XMC_RTC_SetAlarm(), XMC_RTC_GetAlarm()
◆ XMC_RTC_GetEventStatus()
uint32_t XMC_RTC_GetEventStatus |
( |
void |
| ) |
|
- Returns
- None
- Description:
- Gets the RTC periodic and alarm event(s) status
- The function reads the bitfields of STSSR register to get the status of RTC events. Reading the value of the register STSSR gives the status of the event(s) containing in the XMC_RTC_EVENT_t.
- Related APIs:
- XMC_RTC_ClearEvent()
◆ XMC_RTC_GetPrescaler()
uint32_t XMC_RTC_GetPrescaler |
( |
void |
| ) |
|
- Returns
- None
- Description:
- Gets the RTC module prescaler value
- The function reads the CTR.DIV bitfield to get the prescalar value. The default value for the prescalar with the 32.768kHz crystal (or the internal clock) is 7FFFH for a time interval of 1 sec.
- Related APIs:
- XMC_RTC_SetPrescaler()
◆ XMC_RTC_GetTime()
- Parameters
-
time | Pointer to a constant XMC_RTC_TIME_t structure containing the time parameters seconds, minutes, hours, days, daysofweek, month and year. |
- Returns
- None
- Description:
- Gets the RTC module time value
- The function gets the time values from TIM0, TIM1 registers. See the structure XMC_RTC_TIME_t for the valid range of time value parameters.
- Related APIs:
- XMC_RTC_SetTime()
◆ XMC_RTC_GetTimeStdFormat()
void XMC_RTC_GetTimeStdFormat |
( |
struct tm *const |
stdtime | ) |
|
- Parameters
-
stdtime | Pointer to a constant ::tm structure containing the time parameters seconds, minutes, hours, days, daysofweek, month, year(since 1900) and days in a year in standard format. |
- Returns
- None
- Description:
- Gets the RTC module time value in standard format
- The function gets the time values from TIM0, TIM1 registers. See the structure XMC_RTC_TIME_t for the valid range of time value parameters.
For days the valid range is (1 - Actual days of month), year (since 1900) and daysinyear (0 -365).
- Related APIs:
- XMC_RTC_SetTime(), XMC_RTC_GetTime()
◆ XMC_RTC_Init()
- Parameters
-
config | Constant pointer to a constant XMC_RTC_CONFIG_t structure containing the time, alarm time and clock divider(prescaler) configuration. |
- Returns
- XMC_RTC_STATUS_t Always returns XMC_RTC_STATUS_OK (It contains only register assignment statements)
- Description:
- Initialize the RTC peripheral
- The function ungates the peripheral clock for RTC, configures internal clock divider, time and alarm values by writing to the CTR.DIV, TIM0, TIM1, ATIM0 and ATIM1 registers.
◆ XMC_RTC_IsEnabled()
bool XMC_RTC_IsEnabled |
( |
void |
| ) |
|
- Returns
- None
- Description
- Checks RTC peripheral is enabled for programming its registers
- Checks peripheral clock is ungated or not.
- Related APIs:
- XMC_RTC_Enable(), XMC_RTC_Disable(), XMC_SCU_RESET_DeassertPeripheralReset(), XMC_SCU_RESET_AssertPeripheralReset()
◆ XMC_RTC_IsRunning()
bool XMC_RTC_IsRunning |
( |
void |
| ) |
|
- Returns
- bool true if RTC is running false if RTC is not running
- Description:
- Checks the running status of the RTC
- The function reads the bitfield ENB of CTR register to get the running status of RTC.
- Related APIs:
- XMC_RTC_Start(), XMC_RTC_Stop()
◆ XMC_RTC_SetAlarm()
- Parameters
-
alarm | Constant pointer to a constant XMC_RTC_ALARM_t structure containing the alarm time parameters alarm seconds, alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month and alarm year. |
- Returns
- None
- Description:
- Sets the RTC module alarm time value
- The function sets the ATIM0, ATIM1 registers with alarm time values. See the structure XMC_RTC_ALARM_t for the valid range of alarm time value parameters.
- Related APIs:
- XMC_RTC_GetAlarm()
◆ XMC_RTC_SetAlarmStdFormat()
void XMC_RTC_SetAlarmStdFormat |
( |
const struct tm *const |
stdtime | ) |
|
- Parameters
-
stdtime | Pointer to a ::tm structure containing the time parameters alarm seconds, alarm minutes, alarm hours, alarm days, alarm daysofweek, alarm month, alarm year(since 1900) and alarm days in a year in standard format. |
- Returns
- None
- Description:
- Sets the RTC module alarm time value in standard format
- The function sets the alarm time values from ATIM0, ATIM1 registers.
- Related APIs:
- XMC_RTC_SetAlarm(), XMC_RTC_GetAlarm()
◆ XMC_RTC_SetDebugMode()
- Parameters
-
- Returns
- None
- Description:
- Configures the RTC into running or stopping mode during halting mode debug
- The function sets the CTR.SUS bitfield to configure the RTC into running or stopping mode during halting mode debug.
◆ XMC_RTC_SetPrescaler()
void XMC_RTC_SetPrescaler |
( |
uint16_t |
prescaler | ) |
|
- Parameters
-
prescaler | Prescaler value to be set |
- Returns
- None
- Description:
- Sets the RTC module prescaler value
- The function sets the CTR.DIV bitfield to configure the prescalar value. The default value for the prescalar with the 32.768kHz crystal (or the internal clock) is 7FFFH for a time interval of 1 sec. Before setting the prescaler value RTC should be in stop mode and hibernate domain should be enabled.
- Related APIs:
- XMC_RTC_Stop(), XMC_RTC_Enable(), XMC_RTC_GetPrescaler()
◆ XMC_RTC_SetTime()
- Parameters
-
timeval | Contstant pointer to a constant XMC_RTC_TIME_t structure containing the time parameters seconds, minutes, hours, days, daysofweek, month and year. |
- Returns
- None
- Description:
- Sets the RTC module time values
- The function sets the TIM0, TIM1 registers with time values. The values can only be written when RTC is disabled. See the structure XMC_RTC_TIME_t for the valid range of time value parameters.
- Related APIs:
- XMC_RTC_GetTime(), XMC_RTC_Stop()
◆ XMC_RTC_SetTimeStdFormat()
void XMC_RTC_SetTimeStdFormat |
( |
const struct tm *const |
stdtime | ) |
|
- Parameters
-
stdtime | Pointer to a ::tm structure containing the time parameters seconds, minutes, hours, days, daysofweek, month, year(since 1900) and days in a year in standard format. |
- Returns
- None
- Description:
- Sets the RTC module time value in standard format
- The function sets the time values from TIM0, TIM1 registers.
- Related APIs:
- XMC_RTC_SetTime(), XMC_RTC_GetTime()
◆ XMC_RTC_Start()
void XMC_RTC_Start |
( |
void |
| ) |
|
- Returns
- None
- Description
- Enables RTC peripheral to start counting time
- The function starts the RTC for counting time by setting CTR.ENB bit. Before starting the RTC, it should not be in running mode and also hibernate domain should be enabled.
- Related APIs:
- XMC_RTC_Enable(), XMC_RTC_Stop(), XMC_SCU_RESET_DeassertPeripheralReset()
◆ XMC_RTC_Stop()
void XMC_RTC_Stop |
( |
void |
| ) |
|
- Returns
- None
- Description
- Disables RTC peripheral to start counting time
- The function stops the RTC for counting time by resetting CTR.ENB. Before stopping the RTC, hibernate domain should be enabled.
- Related APIs:
- XMC_RTC_Enable(), XMC_RTC_Start(), XMC_SCU_RESET_AssertPeripheralReset()