RTC - Real Time Counter#
Real Time Counter (RTC) Peripheral API.
This module contains functions to control the RTC peripheral of Silicon Labs 32-bit MCUs and SoCs. The RTC ensures timekeeping in low energy modes.
Modules#
Functions#
Get the RTC compare register value.
Set the RTC compare register value.
Get RTC counter value.
Set the RTC counter value.
Restart the RTC counter from zero.
Enable/disable RTC.
RTC register synchronization freeze control.
Initialize RTC.
Clear one or more pending RTC interrupts.
Disable one or more RTC interrupts.
Enable one or more RTC interrupts.
Get pending RTC interrupt flags.
Get enabled and pending RTC interrupt flags.
Set one or more pending RTC interrupts from SW.
Restore RTC to reset state.
Macros#
The RTC peripheral on series 0 devices support 2 compare channels while the RTC peripheral on series 1 devices support 6 compare channels.
Suggested default configuration for RTC initialization structure.
Function Documentation#
RTC_CompareGet#
uint32_t RTC_CompareGet (unsigned int comp)
Get the RTC compare register value.
[in] | comp | A compare register to get. This value must be less than NUM_RTC_CHANNELS. |
Returns
A compare register value, 0 if invalid register selected.
111
of file platform/emlib/src/em_rtc.c
RTC_CompareSet#
void RTC_CompareSet (unsigned int comp, uint32_t value)
Set the RTC compare register value.
[in] | comp | A compare register to set. This value must be less than NUM_RTC_CHANNELS. |
[in] | value | An initialization value (<= 0x00ffffff). |
Note
The setting of a compare register requires synchronization into the low-frequency domain. If the same register is modified before a previous update has completed, this function will stall until the previous synchronization has completed. This only applies to the Gecko Family. See comments in the regSync() internal function call.
157
of file platform/emlib/src/em_rtc.c
RTC_CounterGet#
uint32_t RTC_CounterGet (void )
Get RTC counter value.
N/A |
Returns
Current RTC counter value.
93
of file platform/emlib/inc/em_rtc.h
RTC_CounterSet#
void RTC_CounterSet (uint32_t value)
Set the RTC counter value.
[in] | value | The new RTC counter value. |
106
of file platform/emlib/inc/em_rtc.h
RTC_CounterReset#
void RTC_CounterReset (void )
Restart the RTC counter from zero.
N/A |
369
of file platform/emlib/src/em_rtc.c
RTC_Enable#
void RTC_Enable (bool enable)
Enable/disable RTC.
[in] | enable | True to enable counting, false to disable. |
Note
The enabling/disabling of RTC modifies the RTC CTRL register which requires synchronization into the low-frequency domain. If this register is modified before a previous update to the same register has completed, this function will stall until the previous synchronization has completed. This only applies to the Gecko Family. See comments in the regSync() internal function call.
220
of file platform/emlib/src/em_rtc.c
RTC_FreezeEnable#
void RTC_FreezeEnable (bool enable)
RTC register synchronization freeze control.
[in] | enable |
|
Some RTC registers require synchronization into the low-frequency (LF) domain. The freeze feature allows for several registers to be modified before passing them to the LF domain simultaneously (which takes place when the freeze mode is disabled).
Note
When enabling freeze mode, this function will wait for all current ongoing RTC synchronization to LF domain to complete (normally synchronization will not be in progress.) However, for this reason, when using freeze mode, modifications of registers requiring LF synchronization should be done within one freeze enable/disable block to avoid unnecessary stalling. This only applies to the Gecko Family. See the reference manual chapter about Access to Low Energy Peripherals (Asynchronos Registers) for details.
264
of file platform/emlib/src/em_rtc.c
RTC_Init#
void RTC_Init (const RTC_Init_TypeDef * init)
Initialize RTC.
[in] | init | A pointer to the RTC initialization structure. |
Note that the compare values must be set separately with RTC_CompareSet() prior to the use of this function if configuring the RTC to start when initialization is completed.
Note
The initialization of the RTC modifies the RTC CTRL register which requires synchronization into the low-frequency domain. If this register is modified before a previous update to the same register has completed, this function will stall until the previous synchronization has completed. This only applies to the Gecko Family. See comments in the regSync() internal function call.
305
of file platform/emlib/src/em_rtc.c
RTC_IntClear#
void RTC_IntClear (uint32_t flags)
Clear one or more pending RTC interrupts.
[in] | flags | RTC interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources for the RTC module (RTC_IFS_nnn). |
128
of file platform/emlib/inc/em_rtc.h
RTC_IntDisable#
void RTC_IntDisable (uint32_t flags)
Disable one or more RTC interrupts.
[in] | flags | RTC interrupt sources to disable. Use a set of interrupt flags OR-ed together to disable multiple interrupt sources for the RTC module (RTC_IFS_nnn). |
142
of file platform/emlib/inc/em_rtc.h
RTC_IntEnable#
void RTC_IntEnable (uint32_t flags)
Enable one or more RTC interrupts.
[in] | flags | RTC interrupt sources to enable. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the RTC module (RTC_IFS_nnn). |
Note
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using RTC_IntClear() prior to enabling the interrupt.
161
of file platform/emlib/inc/em_rtc.h
RTC_IntGet#
uint32_t RTC_IntGet (void )
Get pending RTC interrupt flags.
N/A |
Note
Event bits are not cleared by using this function.
Returns
Pending RTC interrupt sources. Returns a set of interrupt flags OR-ed together for multiple interrupt sources in the RTC module (RTC_IFS_nnn).
177
of file platform/emlib/inc/em_rtc.h
RTC_IntGetEnabled#
uint32_t RTC_IntGetEnabled (void )
Get enabled and pending RTC interrupt flags.
N/A |
Useful for handling more interrupt sources in the same interrupt handler.
Note
Interrupt flags are not cleared by using this function.
Returns
Pending and enabled RTC interrupt sources. The return value is the bitwise AND of
the enabled interrupt sources in RTC_IEN and
the pending interrupt flags RTC_IF.
196
of file platform/emlib/inc/em_rtc.h
RTC_IntSet#
void RTC_IntSet (uint32_t flags)
Set one or more pending RTC interrupts from SW.
[in] | flags | RTC interrupt sources to set to pending. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the RTC module (RTC_IFS_nnn). |
213
of file platform/emlib/inc/em_rtc.h
RTC_Reset#
void RTC_Reset (void )
Restore RTC to reset state.
N/A |
339
of file platform/emlib/src/em_rtc.c
Macro Definition Documentation#
NUM_RTC_CHANNELS#
#define NUM_RTC_CHANNELSValue:
2U
The RTC peripheral on series 0 devices support 2 compare channels while the RTC peripheral on series 1 devices support 6 compare channels.
55
of file platform/emlib/inc/em_rtc.h
RTC_INIT_DEFAULT#
#define RTC_INIT_DEFAULTValue:
Suggested default configuration for RTC initialization structure.
72
of file platform/emlib/inc/em_rtc.h