SYSRTC - System Real Time Counter#

System Real Time Counter (SYSRTC) Peripheral API.

This module contains functions to control the SYSRTC peripheral of Silicon Labs 32-bit MCUs and SoCs. The SYSRTC ensures timekeeping in low energy modes.

Modules#

sl_hal_sysrtc_config_t

sl_hal_sysrtc_group_channel_compare_config_t

sl_hal_sysrtc_group_channel_capture_config_t

sl_hal_sysrtc_group_config_t

Enumerations#

enum
SL_HAL_SYSRTC_CAPTURE_EDGE_RISING = 0
SL_HAL_SYSRTC_CAPTURE_EDGE_FALLING
SL_HAL_SYSRTC_CAPTURE_EDGE_BOTH
}

Capture input edge select.

enum
SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_CLEAR = 0
SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_SET
SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_PULSE
SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_TOGGLE
SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_CMPIF
}

Compare match output action mode.

Variables#

uint32_t
uint8_t
uint8_t uint32_t

Functions#

void

Waits for the SYSRTC to complete reseting or disabling procedure.

void

Starts SYSRTC counter.

void

Stops the SYSRTC counter.

uint32_t

Gets SYSRTC STATUS register value.

void

Locks SYSRTC registers.

void

Unlocks SYSRTC registers.

void

Sets the SYSRTC counter value.

void
sl_hal_sysrtc_init(const sl_hal_sysrtc_config_t *p_config)

Initializes SYSRTC module.

void

Enables SYSRTC counting.

void

Disables SYSRTC counting.

void

Restores SYSRTC to its reset state.

void
sl_hal_sysrtc_init_group(uint8_t group_number, sl_hal_sysrtc_group_config_t const *p_group_config)

Initializes the selected SYSRTC group.

void
sl_hal_sysrtc_enable_group_interrupts(uint8_t group_number, uint32_t flags)

Enables one or more SYSRTC interrupts for the given group.

void
sl_hal_sysrtc_disable_group_interrupts(uint8_t group_number, uint32_t flags)

Disables one or more SYSRTC interrupts for the given group.

void
sl_hal_sysrtc_clear_group_interrupts(uint8_t group_number, uint32_t flags)

Clears one or more pending SYSRTC interrupts for the given group.

uint32_t

Gets pending SYSRTC interrupt flags for the given group.

uint32_t

Gets enabled and pending SYSRTC interrupt flags.

void
sl_hal_sysrtc_set_group_interrupts(uint8_t group_number, uint32_t flags)

Sets one or more pending SYSRTC interrupts for the given group from Software.

uint32_t
sl_hal_sysrtc_get_group_compare_channel_value(uint8_t group_number, uint8_t channel)

Gets SYSRTC compare register value for selected channel of given group.

void
sl_hal_sysrtc_set_group_compare_channel_value(uint8_t group_number, uint8_t channel, uint32_t value)

Sets SYSRTC compare register value for selected channel of given group.

uint32_t

Gets SYSRTC input capture register value for selected channel of given group.

SL_CODE_CLASSIFY(SL_CODE_COMPONENT_PERIPHERAL_SYSRTC, SL_CODE_CLASS_TIME_CRITICAL) inline void sl_hal_sysrtc_wait_sync(void)

Waits for the SYSRTC to complete all synchronization of register changes and commands.

Macros#

#define

Minimum compare channels for SYSRTC group.

#define

Maximum compare channels for SYSRTC group.

#define

Minimum capture channels for SYSRTC group.

#define

Maximum capture channels for SYSRTC group.

#define

Sysrtc group number.

#define

Validation of valid SYSRTC group for assert statements.

#define

Suggested default values for SYSRTC configuration structure.

#define

Suggested default values for compare channel configuration structure.

#define

Compare channel configuration for starting HFXO using PRS.

#define

Suggested default values for capture channel configuration structure.

#define

Suggested default values for SYSRTC group configuration structure.

Enumeration Documentation#

sl_hal_sysrtc_capture_edge_t#

sl_hal_sysrtc_capture_edge_t

Capture input edge select.

Enumerator
SL_HAL_SYSRTC_CAPTURE_EDGE_RISING

Rising edges detected.

SL_HAL_SYSRTC_CAPTURE_EDGE_FALLING

Falling edges detected.

SL_HAL_SYSRTC_CAPTURE_EDGE_BOTH

Both edges detected.


Definition at line 80 of file platform/peripheral/inc/sl_hal_sysrtc.h

sl_hal_sysrtc_compare_match_out_action_t#

sl_hal_sysrtc_compare_match_out_action_t

Compare match output action mode.

Enumerator
SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_CLEAR

Clear output.

SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_SET

Set output.

SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_PULSE

Generate a pulse.

SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_TOGGLE

Toggle output.

SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_CMPIF

Export CMPIF.


Definition at line 87 of file platform/peripheral/inc/sl_hal_sysrtc.h

Variable Documentation#

flags#

uint32_t flags

Definition at line 335 of file platform/peripheral/inc/sl_hal_sysrtc.h

channel#

uint8_t channel

Definition at line 419 of file platform/peripheral/inc/sl_hal_sysrtc.h

value#

uint8_t uint32_t value

Definition at line 434 of file platform/peripheral/inc/sl_hal_sysrtc.h

Function Documentation#

sl_hal_sysrtc_wait_sync#

void sl_hal_sysrtc_wait_sync (void )
Parameters
N/A

Definition at line 49 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_wait_ready#

void sl_hal_sysrtc_wait_ready (void )

Waits for the SYSRTC to complete reseting or disabling procedure.

Parameters
N/A

Definition at line 202 of file platform/peripheral/inc/sl_hal_sysrtc.h

sl_hal_sysrtc_start#

void sl_hal_sysrtc_start (void )

Starts SYSRTC counter.

Parameters
N/A

This function will send a start command to the SYSRTC peripheral. The SYSRTC peripheral will use some LF clock ticks before the command is executed. The sl_hal_sysrtc_wait_sync() function can be used to wait for the start command to be executed.

Note

  • This function requires the SYSRTC to be enabled.


Definition at line 219 of file platform/peripheral/inc/sl_hal_sysrtc.h

sl_hal_sysrtc_stop#

void sl_hal_sysrtc_stop (void )

Stops the SYSRTC counter.

Parameters
N/A

This function will send a stop command to the SYSRTC peripheral. The SYSRTC peripheral will use some LF clock ticks before the command is executed. The sl_hal_sysrtc_wait_sync() function can be used to wait for the stop command to be executed.

Note

  • This function requires the SYSRTC to be enabled.


Definition at line 235 of file platform/peripheral/inc/sl_hal_sysrtc.h

sl_hal_sysrtc_get_status#

uint32_t sl_hal_sysrtc_get_status (void )

Gets SYSRTC STATUS register value.

Parameters
N/A

Returns

  • Current STATUS register value.


Definition at line 251 of file platform/peripheral/inc/sl_hal_sysrtc.h

sl_hal_sysrtc_lock#

void sl_hal_sysrtc_lock (void )

Locks SYSRTC registers.

Parameters
N/A

Note

  • When SYSRTC registers are locked SYSRTC_EN, SYSRTC_CFG, SYSRTC_CMD, SYSRTC_SWRST, SYSRTC_CNT and SYSRTC_TOPCNT registers cannot be written to.


Definition at line 263 of file platform/peripheral/inc/sl_hal_sysrtc.h

sl_hal_sysrtc_unlock#

void sl_hal_sysrtc_unlock (void )

Unlocks SYSRTC registers.

Parameters
N/A

Note

  • When SYSRTC registers are locked SYSRTC_EN, SYSRTC_CFG, SYSRTC_CMD, SYSRTC_SWRST, SYSRTC_CNT and SYSRTC_TOPCNT registers cannot be written to.


Definition at line 275 of file platform/peripheral/inc/sl_hal_sysrtc.h

sl_hal_sysrtc_get_counter#

uint32_t sl_hal_sysrtc_get_counter (void )
Parameters
N/A

Definition at line 56 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_set_counter#

void sl_hal_sysrtc_set_counter (uint32_t value)

Sets the SYSRTC counter value.

Parameters
[in]value

The new SYSRTC counter value.


Definition at line 300 of file platform/peripheral/inc/sl_hal_sysrtc.h

sl_hal_sysrtc_init#

void sl_hal_sysrtc_init (const sl_hal_sysrtc_config_t * p_config)

Initializes SYSRTC module.

Parameters
[in]p_config

A pointer to the SYSRTC initialization structure variable.

Note that the compare values must be set separately with (sl_hal_sysrtc_set_group_compare_channel_value()), which should probably be done prior to the use of this function if configuring the SYSRTC to start when initialization is completed.


Definition at line 62 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_enable#

void sl_hal_sysrtc_enable (void )

Enables SYSRTC counting.

Parameters
N/A

Definition at line 81 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_disable#

void sl_hal_sysrtc_disable (void )

Disables SYSRTC counting.

Parameters
N/A

Definition at line 96 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_reset#

void sl_hal_sysrtc_reset (void )

Restores SYSRTC to its reset state.

Parameters
N/A

Definition at line 112 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_init_group#

void sl_hal_sysrtc_init_group (uint8_t group_number, sl_hal_sysrtc_group_config_t const * p_group_config)

Initializes the selected SYSRTC group.

Parameters
[in]group_number

SYSRTC group number to use.

[in]p_group_config

Pointer to group configuration structure variable.


Definition at line 121 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_enable_group_interrupts#

void sl_hal_sysrtc_enable_group_interrupts (uint8_t group_number, uint32_t flags)

Enables one or more SYSRTC interrupts for the given group.

Parameters
N/Agroup_number
N/Aflags

Definition at line 270 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_disable_group_interrupts#

void sl_hal_sysrtc_disable_group_interrupts (uint8_t group_number, uint32_t flags)

Disables one or more SYSRTC interrupts for the given group.

Parameters
N/Agroup_number
N/Aflags

Definition at line 330 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_clear_group_interrupts#

void sl_hal_sysrtc_clear_group_interrupts (uint8_t group_number, uint32_t flags)

Clears one or more pending SYSRTC interrupts for the given group.

Parameters
N/Agroup_number
N/Aflags

Definition at line 390 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_get_group_interrupts#

uint32_t sl_hal_sysrtc_get_group_interrupts (uint8_t group_number)

Gets pending SYSRTC interrupt flags for the given group.

Parameters
N/Agroup_number

Definition at line 450 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_get_group_enabled_interrupts#

uint32_t sl_hal_sysrtc_get_group_enabled_interrupts (uint8_t group_number)

Gets enabled and pending SYSRTC interrupt flags.

Parameters
[in]group_number

SYSRTC group number to use.

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 SYSRTC interrupt sources. The return value is the bitwise AND of

    • the enabled interrupt sources in SYSRTC_GRPx_IEN and

    • the pending interrupt flags SYSRTC_GRPx_IF.


Definition at line 502 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_set_group_interrupts#

void sl_hal_sysrtc_set_group_interrupts (uint8_t group_number, uint32_t flags)

Sets one or more pending SYSRTC interrupts for the given group from Software.

Parameters
[in]group_number

SYSRTC group number to use.

[in]flags

SYSRTC interrupt sources to set to pending. Use a set of interrupt flags OR-ed together to set multiple interrupt sources for the SYSRTC group.


Definition at line 564 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_get_group_compare_channel_value#

uint32_t sl_hal_sysrtc_get_group_compare_channel_value (uint8_t group_number, uint8_t channel)

Gets SYSRTC compare register value for selected channel of given group.

Parameters
N/Agroup_number
N/Achannel

Definition at line 624 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_set_group_compare_channel_value#

void sl_hal_sysrtc_set_group_compare_channel_value (uint8_t group_number, uint8_t channel, uint32_t value)

Sets SYSRTC compare register value for selected channel of given group.

Parameters
N/Agroup_number
N/Achannel
N/Avalue

Definition at line 781 of file platform/peripheral/src/sl_hal_sysrtc.c

sl_hal_sysrtc_get_group_capture_channel_value#

uint32_t sl_hal_sysrtc_get_group_capture_channel_value (uint8_t group_number)

Gets SYSRTC input capture register value for selected channel of given group.

Parameters
N/Agroup_number

Definition at line 946 of file platform/peripheral/src/sl_hal_sysrtc.c

SL_CODE_CLASSIFY#

SL_CODE_CLASSIFY (SL_CODE_COMPONENT_PERIPHERAL_SYSRTC , SL_CODE_CLASS_TIME_CRITICAL , group_number, flags, group_number, flags)

Waits for the SYSRTC to complete all synchronization of register changes and commands.

Parameters
[in]

SYSRTC group number to use.

[in]

Channel selector.

[in]group_number

Compare register value.

[in]flags

SYSRTC group number to use.

[in]group_number

SYSRTC group number to use.

[in]flags

SYSRTC interrupt sources to clear. Use a set of interrupt flags OR-ed together to clear multiple interrupt sources for the given SYSRTC group.

Gets SYSRTC input capture register value for capture channel of given group.

Sets SYSRTC compare register value for selected channel of given group.

Gets SYSRTC compare register value for selected channel of given group.

Gets pending SYSRTC interrupt flags for the given group.

Clears one or more pending SYSRTC interrupts for the given group.

Disables one or more SYSRTC interrupts for the given group.

Enables one or more SYSRTC interrupts for the given group.

Gets SYSRTC counter value.

Returns

  • Current SYSRTC counter value.

Note

  • Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using sl_hal_sysrtc_clear_group_interrupts() prior to enabling the interrupt.

Note

  • Event bits are not cleared by using this function.

Returns

  • Pending SYSRTC interrupt sources. Returns a set of interrupt flags OR-ed together for multiple interrupt sources in the SYSRTC group.

Returns

  • Compare register value.

Returns

  • Capture register value.


Definition at line 190 of file platform/peripheral/inc/sl_hal_sysrtc.h

Macro Definition Documentation#

SYSRTC_GROUP_MIN_CHANNEL_COMPARE#

#define SYSRTC_GROUP_MIN_CHANNEL_COMPARE
Value:
1u

Minimum compare channels for SYSRTC group.


Definition at line 58 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_GROUP_MAX_CHANNEL_COMPARE#

#define SYSRTC_GROUP_MAX_CHANNEL_COMPARE
Value:
2u

Maximum compare channels for SYSRTC group.


Definition at line 60 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_GROUP_MIN_CHANNEL_CAPTURE#

#define SYSRTC_GROUP_MIN_CHANNEL_CAPTURE
Value:
0u

Minimum capture channels for SYSRTC group.


Definition at line 63 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_GROUP_MAX_CHANNEL_CAPTURE#

#define SYSRTC_GROUP_MAX_CHANNEL_CAPTURE
Value:
1u

Maximum capture channels for SYSRTC group.


Definition at line 65 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_GROUP_NUMBER#

#define SYSRTC_GROUP_NUMBER
Value:
1u

Sysrtc group number.


Definition at line 69 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_GROUP_VALID#

#define SYSRTC_GROUP_VALID
Value:
(group)

Validation of valid SYSRTC group for assert statements.


Definition at line 73 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_CONFIG_DEFAULT#

#define SYSRTC_CONFIG_DEFAULT
Value:
{ \
false, /* Disable updating during debug halt. */ \
}

Suggested default values for SYSRTC configuration structure.


Definition at line 105 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_GROUP_CHANNEL_COMPARE_CONFIG_DEFAULT#

#define SYSRTC_GROUP_CHANNEL_COMPARE_CONFIG_DEFAULT
Value:
{ \
SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_PULSE \
}

Suggested default values for compare channel configuration structure.


Definition at line 131 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_GROUP_CHANNEL_COMPARE_CONFIG_EARLY_WAKEUP#

#define SYSRTC_GROUP_CHANNEL_COMPARE_CONFIG_EARLY_WAKEUP
Value:
{ \
SL_HAL_SYSRTC_COMPARE_MATCH_OUT_ACTION_CMPIF \
}

Compare channel configuration for starting HFXO using PRS.


Definition at line 137 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_GROUP_CHANNEL_CAPTURE_CONFIG_DEFAULT#

#define SYSRTC_GROUP_CHANNEL_CAPTURE_CONFIG_DEFAULT
Value:
{ \
SL_HAL_SYSRTC_CAPTURE_EDGE_RISING \
}

Suggested default values for capture channel configuration structure.


Definition at line 143 of file platform/peripheral/inc/sl_hal_sysrtc.h

SYSRTC_GROUP_CONFIG_DEFAULT#

#define SYSRTC_GROUP_CONFIG_DEFAULT
Value:
{ \
true, /* Enable compare channel 0. */ \
false, /* Disable compare channel 1. */ \
false, /* Disable capture channel 0. */ \
NULL, /* NULL Pointer to configuration structure for compare channel 0*/ \
NULL, /* NULL Pointer to configuration structure for compare channel 1*/ \
NULL /* NULL Pointer to configuration structure for capture channel 0*/ \
}

Suggested default values for SYSRTC group configuration structure.


Definition at line 149 of file platform/peripheral/inc/sl_hal_sysrtc.h