Watchdog Timer#
Introduction#
The Watchdog Timer is used to generate an interrupt upon a timeout and to perform a reset in the event of a system failure, which may result from an external event such as an Electrostatic Discharge (ESD) pulse or a software malfunction. The interrupt can also be used as a wakeup source for transitioning from SLEEP/STANDBY to ACTIVE states.
Features supported by the Watchdog Timer
Independent window watchdog timer.
Interrupt is generated before the system reset is applied, which can be used as a wakeup source.
Individually controllable power domain for low-power applications.
Able to operate when the CPU is in the SLEEP state during power-save applications.
Configurable timeout period.
Option to be clocked using either a low-power internal RC (32 KHz) or an external 32KHz XTAL.
Configuration#
The Watchdog Timer can be configured using several parameters:
Initialize the Watchdog Timer:sl_si91x_watchdog_init_timer
Configure the Clocks:sl_si91x_watchdog_configure_clock
Set Watchdog Parameters: Configure interrupt time, system reset time, and window time using sl_si91x_watchdog_set_configuration.
For more information on configuring available parameters, see the respective peripheral example readme document.
Usage#
The following functions will initiate and configure the Watchdog Timer, representing the general flow for implementation:
Initialize the Watchdog Timer:sl_si91x_watchdog_init_timer
Configure the timer clock:sl_si91x_watchdog_configure_clock
System reset status:sl_si91x_watchdog_get_timer_system_reset_status (Optional, if required to check whether it is a power-on reset or WDT system reset.)
Configure the Watchdog Timer:sl_si91x_watchdog_set_configuration
Register Watchdog Timer timeout callback:sl_si91x_watchdog_register_timeout_callback
Start Watchdog Timer:sl_si91x_watchdog_start_timer
Restart Watchdog Timer (To kick the Watchdog Timer):sl_si91x_watchdog_restart_timer
Stop Watchdog Timer:sl_si91x_watchdog_stop_timer
De-initialize Watchdog Timer:sl_si91x_watchdog_deinit_timer
To read time values, use the following APIs:
Read System-Reset Time:sl_si91x_watchdog_get_system_reset_time
Read Interrupt Time:sl_si91x_watchdog_get_interrupt_time
Read Window Time:sl_si91x_watchdog_get_window_time
Modules#
Enumerations#
Enumeration to represent possible time delay values for WDT interrupt time and system reset time with a 32 KHz clock frequency.
Typedefs#
Typedef for the function pointer of the callback function.
Renaming high frequency fsm-clock type enum.
Renaming low frequency fsm-clock type enum.
Functions#
To initialize the Watchdog Timer.
To enable and configure the Watchdog Timer clock sources.
To configure Watchdog Timer parameters.
To register the Watchdog Timer timeout callback.
To set the Watchdog Timer interrupt time (Overflow or Restart time).
To read the configured Watchdog Timer interrupt time.
To set the Watchdog Timer system reset time duration.
To read the configured Watchdog Timer system reset time.
To set the Watchdog Timer window time value.
To read the configured Watchdog Timer window time.
To read the Watchdog Timer system reset status.
To de-initialize the Watchdog Timer.
To unregister the Watchdog Timer timeout callback.
To get the API version of the Watchdog timer.
To start and enable the Watchdog Timer.
To stop the Watchdog Timer by disabling it.
To restart (kick) an already running Watchdog Timer.
To enable the Watchdog Timer to reset the system on processor lockup.
To disable the Watchdog Timer from resetting the system on processor lockup.
Enumeration Documentation#
bg_pmu_clock_t#
bg_pmu_clock_t
To represent BG-PMU clock sources.
This enumeration defines the possible clock sources for the BG-PMU (Background Power Management Unit).
Enumerator | |
---|---|
RO_32KHZ_CLOCK | RO 32KHz clock. |
MCU_FSM__CLOCK | MCU FSM clock. |
68
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
time_delays_t#
time_delays_t
Enumeration to represent possible time delay values for WDT interrupt time and system reset time with a 32 KHz clock frequency.
This enumeration defines the possible time delay values for the Watchdog Timer (WDT) interrupt and system reset times when using a 32-KHz clock frequency.
Enumerator | |
---|---|
TIME_DELAY_0 | Time delay of 0.03125 milliseconds. |
TIME_DELAY_1 | Time delay of 0.0625 milliseconds. |
TIME_DELAY_2 | Time delay of 0.125 milliseconds. |
TIME_DELAY_3 | Time delay of 0.25 milliseconds. |
TIME_DELAY_4 | Time delay of 0.5 milliseconds. |
TIME_DELAY_5 | Time delay of 1 millisecond. |
TIME_DELAY_6 | Time delay of 2 milliseconds. |
TIME_DELAY_7 | Time delay of 4 milliseconds. |
TIME_DELAY_8 | Time delay of 8 milliseconds. |
TIME_DELAY_9 | Time delay of 16 milliseconds. |
TIME_DELAY_10 | Time delay of 32 milliseconds. |
TIME_DELAY_11 | Time delay of 64 milliseconds. |
TIME_DELAY_12 | Time delay of 128 milliseconds. |
TIME_DELAY_13 | Time delay of 256 milliseconds. |
TIME_DELAY_14 | Time delay of 512 milliseconds. |
TIME_DELAY_15 | Time delay of 1.024 seconds. |
TIME_DELAY_16 | Time delay of 2.048 seconds. |
TIME_DELAY_17 | Time delay of 4.096 seconds. |
TIME_DELAY_18 | Time delay of 8.192 seconds. |
TIME_DELAY_19 | Time delay of 16.384 seconds. |
TIME_DELAY_20 | Time delay of 32.768 seconds. |
TIME_DELAY_21 | Time delay of 65.536 seconds. |
TIME_DELAY_22 | Time delay of 131.072 seconds. |
TIME_DELAY_23 | Time delay of 262.144 seconds. |
TIME_DELAY_24 | Time delay of 524.288 seconds. |
TIME_DELAY_25 | Time delay of 1048.576 seconds. |
TIME_DELAY_26 | Time delay of 2097.152 seconds. |
TIME_DELAY_27 | Time delay of 4194.304 seconds. |
TIME_DELAY_28 | Time delay of 8388.608 seconds. |
TIME_DELAY_29 | Time delay of 16777.216 seconds. |
TIME_DELAY_30 | Time delay of 33554.432 seconds. |
TIME_DELAY_31 | Time delay of 67108.864 seconds. |
TIME_DELAY_LAST | Time delay value validation. |
79
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
Typedef Documentation#
watchdog_timer_callback_t#
typedef void(* watchdog_timer_callback_t) (void) )(void)
Typedef for the function pointer of the callback function.
58
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
high_freq_fsm_clock_t#
typedef FSM_CLK_T high_freq_fsm_clock_t
Renaming high frequency fsm-clock type enum.
59
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
low_freq_fsm_clock_t#
typedef AON_CLK_T low_freq_fsm_clock_t
Renaming low frequency fsm-clock type enum.
60
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
Function Documentation#
sl_si91x_watchdog_init_timer#
void sl_si91x_watchdog_init_timer (void )
To initialize the Watchdog Timer.
N/A |
This API initializes the Watchdog Timer by enabling the peripheral power. It also configures the Watchdog Timer to run during sleep mode and unmasks its interrupt.
Note
This function should be called before using any other Watchdog Timer functions.
166
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_configure_clock#
sl_status_t sl_si91x_watchdog_configure_clock (watchdog_timer_clock_config_t * timer_clk_config_ptr)
To enable and configure the Watchdog Timer clock sources.
[in] | timer_clk_config_ptr | Pointer to the timer clock configuration structure. |
This API configures the Watchdog Timer's low frequency and BG-PMU clock sources.
Pre-condition:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success, timer clock-source parameters configured properly.
SL_STATUS_INVALID_PARAMETER (0x0021) - Timer configuration structure members have invalid values.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
186
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_set_configuration#
sl_status_t sl_si91x_watchdog_set_configuration (watchdog_timer_config_t * timer_config_ptr)
To configure Watchdog Timer parameters.
[in] | timer_config_ptr | Pointer to the timer configuration structure watchdog_timer_config_t. |
This API configures the Watchdog Timer parameters, including interrupt time (WDT restart time), system reset time, and window time (lower time stamp for WDT restart, if necessary). The interrupt time should be greater than the window time; otherwise, the API will return an error.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Success, timer parameters configured properly.
SL_STATUS_INVALID_PARAMETER (0x0021) - Timer configuration structure members have invalid values.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer.
SL_STATUS_INVALID_CONFIGURATION (0x0023) - Timer configuration structure member 'interrupt_time' is less than or equal to 'window_time'. It should be greater than the window time of the timer.
For more information on status codes, see SL STATUS DOCUMENTATION.
210
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_register_timeout_callback#
sl_status_t sl_si91x_watchdog_register_timeout_callback (watchdog_timer_callback_t on_timeout_callback)
To register the Watchdog Timer timeout callback.
[in] | on_timeout_callback | Function pointer to the callback function to be called when the timer timeout interrupt occurs. |
This API registers a callback function to be called when the Watchdog Timer timeout interrupt occurs. Registering the callback also enables its interrupts. Before registering a new callback, the user must unregister any previously registered callback using the sl_si91x_watchdog_unregister_timeout_callback function.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Successfully registered the timer timeout callback.
SL_STATUS_BUSY (0x0004) - The callback is already registered; the user must unregister the previous callback before registering again.
SL_STATUS_NULL_POINTER (0x0022) - The callback function pointer parameter is a null pointer.
For more information on status codes, see SL STATUS DOCUMENTATION.
229
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_set_interrupt_time#
sl_status_t sl_si91x_watchdog_set_interrupt_time (time_delays_t interrupt_time)
To set the Watchdog Timer interrupt time (Overflow or Restart time).
[in] | interrupt_time | Timer timeout interrupt duration, represented as time_delays_t. Number of clock pulses = 2^(interrupt_time). |
This API sets the Watchdog Timer interrupt time, also referred to as the upper time-stamp for WDT restart. The maximum value for the interrupt time is 31.
Number of clock pulses for timer timeout = 2^(interrupt_time)
Note
The 'interrupt_time' value should be greater than the window time.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Successfully set the Watchdog Timer timeout value.
SL_STATUS_INVALID_PARAMETER (0x0021) - The 'interrupt_time' parameter has an invalid value.
SL_STATUS_INVALID_CONFIGURATION (0x0023) - The 'interrupt_time' value is less than the window time.
For more information on status codes, see SL STATUS DOCUMENTATION.
256
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_get_interrupt_time#
uint8_t sl_si91x_watchdog_get_interrupt_time (void )
To read the configured Watchdog Timer interrupt time.
N/A |
This API returns the interrupt time configured for the Watchdog Timer in terms of the power of two.
Pre-conditions:
Returns
uint8_t The configured interrupt time value, see time_delays_t.
269
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_set_system_reset_time#
sl_status_t sl_si91x_watchdog_set_system_reset_time (time_delays_t system_reset_time)
To set the Watchdog Timer system reset time duration.
[in] | system_reset_time | Timer system reset duration, represented as time_delays_t. Number of clock pulses = 2^(system_reset_time). |
This API sets the duration for the Watchdog Timer system reset. The number of clock pulses for the system reset time is calculated as 2^(system_reset_time). The maximum value for system_reset_time is 31. This value should be greater than the timer window time.
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Successfully set the Watchdog Timer system reset time value.
SL_STATUS_INVALID_PARAMETER (0x0021) - The 'system_reset_time' parameter has an invalid value.
SL_STATUS_INVALID_CONFIGURATION (0x0023) - The 'system_reset_time' value is less than the window time.
For more information on status codes, see SL STATUS DOCUMENTATION.
291
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_get_system_reset_time#
uint8_t sl_si91x_watchdog_get_system_reset_time (void )
To read the configured Watchdog Timer system reset time.
N/A |
This API returns the system reset time configured for the Watchdog Timer in terms of the power of two.
Pre-conditions:
Returns
uint8_t The configured system reset time value, see time_delays_t.
304
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_set_window_time#
sl_status_t sl_si91x_watchdog_set_window_time (time_delays_t window_time)
To set the Watchdog Timer window time value.
[in] | window_time | Timer window time, represented as time_delays_t. Number of clock pulses = 2^(window_time). |
This API sets the window time value for the Watchdog Timer. By setting this value, the timer becomes a window Watchdog Timer. If this value is zero, it acts as a regular WDT. It is also referred to as the lower time-stamp for WDT restart. The maximum value is 15.
Number of clock pulses for window time = 2^(window_time).
This value should be less than the timer interrupt time and system reset time.
Pre-conditions:
Returns
sl_status_t Status code indicating the result:
SL_STATUS_OK (0x0000) - Successfully set the Watchdog Timer window time value.
SL_STATUS_INVALID_PARAMETER (0x0021) - The 'window_time' parameter has an invalid value.
SL_STATUS_INVALID_CONFIGURATION (0x0023) - The 'window_time' value is greater than the interrupt time or system reset time.
For more information on status codes, see SL STATUS DOCUMENTATION.
330
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_get_window_time#
uint8_t sl_si91x_watchdog_get_window_time (void )
To read the configured Watchdog Timer window time.
N/A |
This API returns the set window time value (not the current count) in terms of the power of two.
Pre-conditions:
Returns
uint8_t The configured window time value, see time_delays_t.
343
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_get_timer_system_reset_status#
boolean_t sl_si91x_watchdog_get_timer_system_reset_status (void )
To read the Watchdog Timer system reset status.
N/A |
This API returns the system reset status of the Watchdog Timer. It returns true if the system was reset by the Watchdog Timer, and false if it was a power-on reset.
Returns
boolean_t Returns true if the Watchdog Timer reset the system, otherwise returns false.
353
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_deinit_timer#
void sl_si91x_watchdog_deinit_timer (void )
To de-initialize the Watchdog Timer.
N/A |
This API de-initializes the Watchdog Timer by masking interrupts, unregistering the callback, and disabling the timer.
365
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_unregister_timeout_callback#
void sl_si91x_watchdog_unregister_timeout_callback (void )
To unregister the Watchdog Timer timeout callback.
N/A |
This API unregisters the callback function for the Watchdog Timer timeout interrupt. It clears the callback function address and sets the callback variable to NULL.
Pre-condition:
389
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_get_version#
sl_watchdog_timer_version_t sl_si91x_watchdog_get_version (void )
To get the API version of the Watchdog timer.
N/A |
This API retrieves the version information of the Watchdog timer.
Returns
sl_watchdog_timer_version_t Structure containing the version information.
399
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_start_timer#
__STATIC_INLINE void sl_si91x_watchdog_start_timer (void )
To start and enable the Watchdog Timer.
N/A |
Once the Watchdog Timer (WDT) is started, the interrupt time will begin incrementing. When it reaches the set interrupt time value, the WDT will generate an interrupt, and the timer will load the system reset time value. Before it reaches this value, the WDT should be restarted (kicked) to avoid a system reset.
Pre-conditions:
415
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_stop_timer#
__STATIC_INLINE void sl_si91x_watchdog_stop_timer (void )
To stop the Watchdog Timer by disabling it.
N/A |
This API stops an already running Watchdog Timer. It disables the timer by updating the 'WWD_TIMER_ENABLE' register bits. Specifically, it updates the 'wwd_timer_en' (23:16) bits of the timer enable register to 0xF0, thereby disabling the WDT timer.
Pre-conditions:
430
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_restart_timer#
__STATIC_INLINE void sl_si91x_watchdog_restart_timer (void )
To restart (kick) an already running Watchdog Timer.
N/A |
This API sets the restart bit of the Watchdog Timer when it is already enabled. It should be used for an already started WDT timer, not for starting a stopped timer.
Pre-conditions:
447
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_enable_system_reset_on_processor_lockup#
__STATIC_INLINE void sl_si91x_watchdog_enable_system_reset_on_processor_lockup (void )
To enable the Watchdog Timer to reset the system on processor lockup.
N/A |
This API enables the Watchdog Timer (WDT) to generate a system reset when the processor gets stuck or reaches a lockup state. It achieves this by setting the 'PROCESSOR_STUCK_RESET_EN' bit of the 'WWD_ARM_STUCK_EN' register of the WDT.
Pre-conditions:
462
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
sl_si91x_watchdog_disable_system_reset_on_processor_lockup#
__STATIC_INLINE void sl_si91x_watchdog_disable_system_reset_on_processor_lockup (void )
To disable the Watchdog Timer from resetting the system on processor lockup.
N/A |
This API disables the Watchdog Timer (WDT) from generating a system reset when the processor gets stuck or reaches a lockup state. It achieves this by writing '0' to the 'PROCESSOR_STUCK_RESET_EN' bit of the 'WWD_ARM_STUCK_EN' register of the WDT.
Pre-conditions:
478
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h