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.
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 seconds
|
XMC_RTC_EVENT_PERIODIC_HOURS |
Mask value to enable an event on periodic seconds
|
XMC_RTC_EVENT_PERIODIC_DAYS |
Mask value to enable an event on periodic seconds
|
XMC_RTC_EVENT_PERIODIC_MONTHS |
Mask value to enable an event on periodic seconds
|
XMC_RTC_EVENT_PERIODIC_YEARS |
Mask value to enable an event on periodic seconds
|
XMC_RTC_EVENT_ALARM |
Mask value to enable an event on periodic seconds
|
Months used to program the date
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
|
Wakeup events for RTC from hibernate domain
Enumerator |
---|
XMC_RTC_WAKEUP_EVENT_ON_ALARM |
Wakeup from alarm event
|
XMC_RTC_WAKEUP_EVENT_ON_SECONDS |
Wakeup from seconds event
|
XMC_RTC_WAKEUP_EVENT_ON_MINUTES |
Wakeup from minutes event
|
XMC_RTC_WAKEUP_EVENT_ON_HOURS |
Wakeup from hours event
|
XMC_RTC_WAKEUP_EVENT_ON_DAYS |
Wakeup from days event
|
XMC_RTC_WAKEUP_EVENT_ON_MONTHS |
Wakeup from months event
|
XMC_RTC_WAKEUP_EVENT_ON_YEARS |
Wakeup from years event
|
Week days used program the date
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()
void XMC_RTC_Disable |
( |
void |
| ) |
|
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()
void XMC_RTC_DisableHibernationWakeUp |
( |
const uint32_t |
event | ) |
|
- Parameters
-
- Returns
- None
- Description:
- Disable Wakeup from hibernate mode
- The function resets the bitfields of CTR register to disable wakeup from hibernate mode. Resetting the masking value for the RTC wakeup events containing in the XMC_RTC_WAKEUP_EVENT_t disables wakeup from hibernate mode.
- Related APIs:
- XMC_RTC_EnableHibernationWakeUp()
void XMC_RTC_Enable |
( |
void |
| ) |
|
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()
void XMC_RTC_EnableHibernationWakeUp |
( |
const uint32_t |
event | ) |
|
- Parameters
-
- Returns
- None
- Description:
- Enable Wakeup from hibernate mode
- The function sets the bitfields of CTR register to enable wakeup from hibernate mode. Setting the masking value for the RTC wakeup events containing in the XMC_RTC_WAKEUP_EVENT_t leads to a wakeup from hibernate mode.
- Related APIs:
- XMC_RTC_DisableHibernationWakeUp()
- 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()
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()
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()
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()
- 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()
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()
- 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 enables the hibernate domain for accessing RTC peripheral registers, configures
- internal clock divider, time and alarm values by writing to the CTR.DIV, TIM0, TIM1, ATIM0 and ATIM1 registers.
bool XMC_RTC_IsEnabled |
( |
void |
| ) |
|
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()
- 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()
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()
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()
- 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()
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()
void XMC_RTC_Start |
( |
void |
| ) |
|
void XMC_RTC_Stop |
( |
void |
| ) |
|