Watchdog Timer#
Introduction#
The WatchDog Timer is used to generate an interrupt on timeout and a reset in case of a system failure, which can be caused by an external event like ESD (Electro Static Discharge) pulse or due to a software failure. The Interrupt can also be used as a Wakeup source for transitioning from SLEEP/STANDBY to ACTIVE states.
Features supported by 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.
APB Interface for accesses from CPU.
Able to operate when CPU is in SLEEP state during power-save applications.
Configurable timeout period.
Option to clocked using a low power internal RC (32 KHz) or external 32KHz XTAL.
Configuration#
By calling the sl_si91x_watchdog_init_timer and sl_si91x_watchdog_configure_clock, the watchdog timer is initialized and its clocks are configured. By using sl_si91x_watchdog_set_configuration watchdog parameters including Interrupt time, system reset time and window time are configured.
For more information on configuring available parameters refer to the respective peripheral example readme document.
Usage#
Below functions will initiate and configure the watchdog timer, which is the general flow for implementation:
sl_si91x_watchdog_get_timer_system_reset_status (Optional, if required to check whether its a power-on reset or WDT system reset.)
sl_si91x_watchdog_restart_timer (To kick watchdog timer)
To read time values following APIs are used:
sl_si91x_watchdog_get_system_reset_time to read system-reset time.
sl_si91x_watchdog_get_interrupt_time to read interrupt time.
sl_si91x_watchdog_get_window_time to read window time.
Modules#
Enumerations#
Enumeration to represent possible time delays values for WDT interrupt time and system reset time with 32 KHZ clock freq.
Typedefs#
Typedef for the function pointer of the callback function.
Renaming high frequency fsm-clock type enum.
Renaming low frequency fsm-clock type enum.
Variables#
low frequency FSM clock source, low_freq_fsm_clock_t
high frequency FSM clock source, high_freq_fsm_clock_t
bg_pmu clock source, bg_pmu_clock_t
timer timeout interrupt duration, number of clock pulses = 2^(system_reset_time), time_delays_t
timer system-reset duration, number of clock pulses = 2^(system_reset_time), time_delays_t
timer window duration, number of clock pulses = 2^(window_time), time_delays_t, but should be less than TIME_DELAY_16
Release version number.
sqa version number
dev version number
Functions#
This API will initialize the Watchdog timer.
This API will enable and configures the timer clock sources.
This API configures watchdog timer parameters.
This API will register the Watchdog timer timeout callback.
This API will set the Watchdog timer interrupt time (Overflow or Restart time).
This API will read the Watchdog timer interrupt time configured value.
This API will set the Watchdog timer system-reset time duration.
This API will read the Watchdog timer system-reset time configured value.
This API will set the Watchdog timer window time value.
This API will read the Watchdog timer window time configured value.
This API will read the Watchdog timer system-reset status.
This API will de-initialize the Watchdog timer.
This API will unregisters the Watchdog timer timeout callback.
This API will get the API version of the Watchdog timer.
This API will start and enable the Watchdog timer.
This API will stop the Watchdog timer by disabling it.
Enables the Watchdog timer to reset the system on processor lockup.
This API is used to disables the watchdog timer to reset system on processor lockup or on processor stuck.
Enumeration Documentation#
bg_pmu_clock_t#
bg_pmu_clock_t
Enumeration to represent bg-pmu clock sources.
Enumerator | |
---|---|
RO_32KHZ_CLOCK | RO_32KHz_clock. |
MCU_FSM__CLOCK | mcu_fsm__clock |
65
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 delays values for WDT interrupt time and system reset time with 32 KHZ clock freq.
Enumerator | |
---|---|
TIME_DELAY_0 | for time delay of 0.03125 milliseconds |
TIME_DELAY_1 | for time delay of 0.0625 milliseconds |
TIME_DELAY_2 | for time delay of 0.125 milliseconds |
TIME_DELAY_3 | for time delay of 0.25 milliseconds |
TIME_DELAY_4 | for time delay of 0.5 milliseconds |
TIME_DELAY_5 | for time delay of 1 milliseconds |
TIME_DELAY_6 | for time delay of 2 milliseconds |
TIME_DELAY_7 | for time delay of 4 milliseconds |
TIME_DELAY_8 | for time delay of 8 milliseconds |
TIME_DELAY_9 | for time delay of 16 milliseconds |
TIME_DELAY_10 | for time delay of 32 milliseconds |
TIME_DELAY_11 | for time delay of 64 milliseconds |
TIME_DELAY_12 | for time delay of 128 milliseconds |
TIME_DELAY_13 | for time delay of 256 milliseconds |
TIME_DELAY_14 | for time delay of 512 milliseconds |
TIME_DELAY_15 | for time delay of 1.024 seconds |
TIME_DELAY_16 | for time delay of 2.048 seconds |
TIME_DELAY_17 | for time delay of 4.096 seconds |
TIME_DELAY_18 | for time delay of 8.192 seconds |
TIME_DELAY_19 | for time delay of 16.384 seconds |
TIME_DELAY_20 | for time delay of 32.768 seconds |
TIME_DELAY_21 | for time delay of 65.536 seconds |
TIME_DELAY_22 | for time delay of 131.072 seconds |
TIME_DELAY_23 | for time delay of 262.144 seconds |
TIME_DELAY_24 | for time delay of 524.288 seconds |
TIME_DELAY_25 | for time delay of 1048.576 seconds |
TIME_DELAY_26 | for time delay of 2097.152 seconds |
TIME_DELAY_27 | for time delay of 4194.304 seconds |
TIME_DELAY_28 | for time delay of 8388.60 seconds |
TIME_DELAY_29 | for time delay of 16777.216 seconds |
TIME_DELAY_30 | for time delay of 33554.432 seconds |
TIME_DELAY_31 | for time delay of 67108.864 seconds |
TIME_DELAY_LAST | for time delay value validation |
71
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.
N/A | data | (void *)extra parameter for user application |
60
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.
61
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.
62
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
Variable Documentation#
low_freq_fsm_clock_src#
uint8_t watchdog_timer_clock_config_t::low_freq_fsm_clock_src
low frequency FSM clock source, low_freq_fsm_clock_t
109
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
high_freq_fsm_clock_src#
uint8_t watchdog_timer_clock_config_t::high_freq_fsm_clock_src
high frequency FSM clock source, high_freq_fsm_clock_t
110
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
bg_pmu_clock_source#
uint8_t watchdog_timer_clock_config_t::bg_pmu_clock_source
bg_pmu clock source, bg_pmu_clock_t
111
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
interrupt_time#
uint8_t watchdog_timer_config_t::interrupt_time
timer timeout interrupt duration, number of clock pulses = 2^(system_reset_time), time_delays_t
117
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
system_reset_time#
uint8_t watchdog_timer_config_t::system_reset_time
timer system-reset duration, number of clock pulses = 2^(system_reset_time), time_delays_t
119
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
window_time#
uint8_t watchdog_timer_config_t::window_time
timer window duration, number of clock pulses = 2^(window_time), time_delays_t, but should be less than TIME_DELAY_16
121
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
release#
uint8_t sl_watchdog_timer_version_t::release
Release version number.
126
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
major#
uint8_t sl_watchdog_timer_version_t::major
sqa version number
127
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h
minor#
uint8_t sl_watchdog_timer_version_t::minor
dev version number
128
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 )
This API will initialize the Watchdog timer.
N/A |
This API will initialize the Watchdog timer by enabling the peripheral power. It also enables to run watchdog-timer during sleep mode. Also un-masks its interrupt.
Returns
none
143
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)
This API will enable and configures the timer clock sources.
[in] | timer_clk_config_ptr | Pointer to timer clock configuration structure |
Configures the watchdog-timer low frequency and bg-pmu clock sources.
Pre-condition:
Returns
status 0 if successful, else error code as follows:
SL_STATUS_INVALID_PARAMETER (0x0021) - Timer configuration structure members have invalid values, for members watchdog_timer_clock_config_t
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer
SL_STATUS_OK (0x0000) - Success, timer clock-source parameters configured properly
158
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)
This API configures watchdog timer parameters.
[in] | timer_config_ptr | Pointer to timer clock configuration structure watchdog_timer_config_t. |
The configurable parameters are interrupt time (WDT restart time), system reset time & window time (lower time stamp for WDT restart, if required). Interrupt time should be greater than window time, else API will give an error.
Returns
status 0 if successful, else error code as follows:
SL_STATUS_INVALID_PARAMETER (0x0021) - Timer configuration structure members have invalid values, for members watchdog_timer_config_t
SL_STATUS_INVALID_CONFIGURATION (0x0023) - Timer configuration structure member 'interrupt_time' is less than or equal to 'window_time'. It should be greater than window time of timer.
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer
SL_STATUS_OK (0x0000) - Success, timer parameters configured properly
179
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)
This API will register the Watchdog timer timeout callback.
[in] | on_timeout_callback | (function pointer) Callback function pointer to be called when timer timeout interrupt occurred. |
Registering call back also enables its interrupts. Before registering a callback, the user must unregister if any callbacks that are already registered.
Returns
status 0 if successful, else error code as follows:
SL_STATUS_NULL_POINTER (0x0022) - Callback function pointer parameter is a null pointer.
SL_STATUS_BUSY (0x0004) - The callback is already registered, the user must unregister the previous callback before registering again
SL_STATUS_OK (0x0000) - Successfully registered timer timer-out callback
194
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)
This API will set the Watchdog timer interrupt time (Overflow or Restart time).
[in] | interrupt_time | (time_delays_t), timer timeout interrupt duration, Number of clock pulses = 2^(interrupt_time), time_delays_t |
This also referred as upper time-stamp for WDT restart Its maximum value is 31.
Number of clock pulses for timer timeout = 2^(interrupt_time) Note
The 'interrupt time' value should be greater than window time.
Pre-conditions:
Returns
status 0 if successful, else error code as follows:
SL_STATUS_INVALID_PARAMETER (0x0021) - 'interrupt_time' parameter has an invalid value.
SL_STATUS_INVALID_CONFIGURATION (0x0023) - 'interrupt_time' value is less than window time.
SL_STATUS_OK (0x0000) - Successfully set watchdog timer timeout time value
214
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 )
This API will read the Watchdog timer interrupt time configured value.
N/A |
It will return interrupt time in terms of power of two.
Pre-conditions:
Returns
returns interrupt time (uint8_t) value, time_delays_t
226
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)
This API will set the Watchdog timer system-reset time duration.
[in] | system_reset_time | (time_delays_t) timer system-reset duration, Number of clock pulses = 2^(system_reset_time), time_delays_t |
Number of clock pulses for system reset time = 2^(system_reset_time). Its maximum value is 31. This value should be greater than timer window time.
Returns
status 0 if successful, else error code as follows:
SL_STATUS_INVALID_PARAMETER (0x0021) - 'system_reset_time' parameter has an invalid value.
SL_STATUS_INVALID_CONFIGURATION (0x0023) - 'system_reset_time' value is less than window time.
SL_STATUS_OK (0x0000) - Successfully set watchdog timer system-reset time value
243
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 )
This API will read the Watchdog timer system-reset time configured value.
N/A |
It will return system reset time in terms of power of two.
Pre-conditions:
Returns
returns system-reset time (uint8_t) value, time_delays_t
255
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)
This API will set the Watchdog timer window time value.
[in] | window_time | (time_delays_t), timer window time, Number of clock pulses = 2^(window_time),time_delays_t |
By setting this value timer becomes as Window watchdog timer, if this value is zero it act as regular WDT. It is also referred as lower time-stamp for WDT restart. Its maximum value is 15. Number of clock pulses for window time = 2^(window_time). This value should be less than timer interrupt time and system-reset time.
Pre-conditions:
Returns
status 0 if successful, else error code as follows:
SL_STATUS_INVALID_PARAMETER (0x0021) - 'window_time' parameter has an invalid value.
SL_STATUS_INVALID_CONFIGURATION (0x0023) - 'window_time' value is greater than interrupt time or system reset time
SL_STATUS_OK (0x0000) - Successfully set watchdog timer window time value
275
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 )
This API will read the Watchdog timer window time configured value.
N/A |
It returns the set window time value (not current count) in terms of power of two.
Pre-conditions:
Returns
returns window time (uint8_t) value, time_delays_t.
287
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 )
This API will read the Watchdog timer system-reset status.
N/A |
This will return true when watchdog-timer resets system and returns false when it is a power-on reset.
Returns
returns true if watchdog timer resets system, else returns false
297
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 )
This API will de-initialize the Watchdog timer.
N/A |
De-initializes, mask interrupts, unregisters the callback and disable timer.
Returns
none
Note
Unregisters the timer callback.
309
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 )
This API will unregisters the Watchdog timer timeout callback.
N/A |
It will unregister the callback, i.e., clear the callback function address and pass NULL value to the variable.
Pre-condition:
Returns
none
321
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 ( none)
This API will get the API version of the Watchdog timer.
N/A | none |
This API is used to know the API version of Watchdog timer.
Returns
( sl_watchdog_version_t) type structure
330
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 )
This API will start and enable the Watchdog timer.
N/A |
Once WDT is started interrupt time will start incrementing as it reaches set interrupt time value, WDT will generate interrupt and timer will load system reset time value and before it reaches this value WDT should be restarted (kicked) to avoid System reset.
Pre-conditions:
Returns
none
345
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 )
This API will stop the Watchdog timer by disabling it.
N/A |
Used to stop an already running timer. It disables the timer by updating 'WWD_TIMER_ENABLE' register bits. It updates 'wwd_timer_en'(23:16) bits of timer enable register by 0xF0, to disable the WDT timer.
Pre-conditions:
Returns
none
361
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 )
N/A |
379
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 )
Enables the Watchdog timer to reset the system on processor lockup.
N/A |
It enables WDT to generate a system-reset when the processor got stuck or reached a lock-up state, by setting 'PROCESSOR_STUCK_RESET_EN' bit of 'WWD_ARM_STUCK_EN' register of WDT.
Pre-conditions:
Returns
none
395
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 )
This API is used to disables the watchdog timer to reset system on processor lockup or on processor stuck.
N/A |
It disables the WDT to generate system-reset when processor got stuck or reached lock-up state, by writing '0' to 'PROCESSOR_STUCK_RESET_EN' bit of 'WWD_ARM_STUCK_EN' register of WDT.
Pre-conditions:
Returns
none.
414
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_watchdog_timer.h