Ultra-Low-Power (ULP) Timer Low-Power Instance#
The Ultra-Low-Power (ULP) Timer maintains accurate timing while the system operates in low-power states. It uses low-power clock sources to generate wake-up interrupts that bring the system out of sleep when required.
To use the ULP Timer in low-power modes:
Select a clock source that remains active in your target power state.
Configure the ULP Subsystem (ULPSS) as the wake source.
Start the timer before entering low-power mode.
Recompute match values if the clock changes during power-state transitions.
Why Use ULP Timers in Low Power#
ULP Timers enable precise wake-ups while minimizing energy consumption, ideal for systems that require scheduled activity during extended sleep periods.
Benefits of ULP Timers#
Minimal Energy Usage: Provides deterministic wake-ups without running the CPU
Flexible Configuration: Supports multiple clock sources (32 kHz RC, 32 kHz XTAL, MHz RC)
Power Manager Integration: Seamlessly integrates with ULPSS to manage wake events
Note: When using an external XTAL clock, configure it using:
sl_si91x_ulp_timer_configure_xtal_clock(xtal_pin 0..4);
Power State Compatibility#
The ULP Timer operates differently across various power states of the SiWx917 device. The following table summarizes timer behavior, available clock domains, and common use cases for each power mode.
Power State | Description | ULP Timer Status | Clock Domain | Typical Use Cases |
|---|---|---|---|---|
PS4 | High-Power Mode | Fully operational | Active | Full functionality and all features available |
PS2 | Ultra-Low-Power Mode | Fully operational | Active | Sleep-mode timing and wake scheduling |
PS1 | Sleep Mode | Wake source only | Limited | Wake scheduling (requires ULPSS wake-source configuration) |
PS0 | Deep Sleep Mode | Not available | Gated | ULP Timer disabled; cannot operate in this mode |
Summary:
The ULP Timer operates normally in PS4 and PS2, functions as a wake source in PS1, and is not available in PS0.
Notes on PS2 and PS1 Transitions#
When transitioning between PS2 and PS1, clock availability and frequency may change. To maintain accurate timing, recalculate match values after each transition using the following API:
sl_si91x_ulp_timer_configure_soc_clock(div_type, div);Parameter | Description |
|---|---|
| Even divisors |
| Odd divisors |
The divisor’s parity must match the selected
div_type.
Tip: Always revalidate match values after a power-state transition to ensure precise timing and predictable wake-up behavior.
Low-Power Setup Example#
The following code example demonstrates how to initialize and configure a ULP Timer for low-power operation with wake-up capability.
// Initialize ULP Timer clock source
status = sl_si91x_ulp_timer_init(&sl_timer_clk_handle);
// Configure timer instance
status = sl_si91x_ulp_timer_set_configuration(&sl_timer_handle_timer0);
// Register timeout callback
status = sl_si91x_ulp_timer_register_timeout_callback(ULP_TIMER_INSTANCE, ulp_timer_callback);
// Configure ULPSS as wake source for Power Manager
status = sl_si91x_power_manager_set_wakeup_sources(
SL_SI91X_POWER_MANAGER_ULPSS_WAKEUP,
true
);
// Start ULP Timer instance
status = sl_si91x_ulp_timer_start(ULP_TIMER_INSTANCE);Key Steps for Low-Power Configuration#
Follow these steps to configure and operate the Ultra-Low-Power (ULP) Timer efficiently on the SiWx917 device during low-power operation.
Select the Appropriate Clock Source
Use the 32 kHz RC or 32 kHz XTAL clock options for PS1 (Sleep) and PS2 (Ultra-Low-Power) modes to minimize energy consumption.
Use the MHz or REF clocks only in PS4 (Active mode) when sub-millisecond precision is required.
Configure the Wake Source
Enable the ULP Subsystem (ULPSS) as a wake source in the SiWx917 Power Manager.
This allows the ULP Timer to trigger wake-up events while the system is in low-power mode.
Start the Timer Before Entering Sleep
Always start the ULP Timer before transitioning to a low-power state to ensure continuous timing operation.
Recalculate After Wake-Up
Recalculate match values after waking up from low-power states, as the clock frequency or divider configuration may have changed.
Tip: Configure the ULPSS wake source before entering PS1 or PS2 modes. Start the ULP Timer last to avoid synchronization issues between the timer and power-state transitions.
Practical Low-Power Examples#
The following examples demonstrate how to configure and optimize ULP Timers on SiWx917 devices for various low-power applications.
Example 1: Smart Agriculture Sensor#
Requirements
Wake every 15 minutes to check soil moisture.
Operate for several months on battery power.
Timing accuracy of ±1 minute per day is acceptable.
Solution
// Use 32kHz XTAL for lowest power with good accuracy
ulp_timer_clk_src_config_t clock_config = {
.ulp_timer_clk_type = ULP_TIMER_CLK_TYPE_STATIC,
.ulp_timer_sync_to_ulpss_pclk = false,
.ulp_timer_clk_input_src = ULP_TIMER_32KHZ_XTAL_CLK_SRC,
.ulp_timer_skip_switch_time = true
};
// 15 minutes = 900 seconds = 900,000,000 microseconds
uint32_t match_value;
sl_si91x_ulp_timer_get_match_value(ULP_TIMER_TYP_1US, 900000000, &match_value);
// Configure for periodic operation
ulp_timer_config_t timer_config = {
.timer_num = ULP_TIMER_0,
.timer_mode = ULP_TIMER_MODE_PERIODIC,
.timer_type = ULP_TIMER_TYP_1US,
.timer_match_value = match_value,
.timer_direction = ULP_TIMER_DIRECTION_DOWN
};Parameter | Value |
|---|---|
Power Consumption | 1–2 µA (sleep), 10–20 mA (active) |
Estimated Battery Life | 6–12 months (AA batteries) |
Example 2: Wearable Health Monitor#
Requirements
Wake the device every 30 seconds to perform a heart-rate measurement.
Operate continuously for several days on a small coin-cell battery.
Maintain timing accuracy within ±100 ms per minute to ensure consistent sampling intervals.
Solution:
// Use 32kHz XTAL for good balance of power and accuracy
ulp_timer_clk_src_config_t clock_config = {
.ulp_timer_clk_type = ULP_TIMER_CLK_TYPE_STATIC,
.ulp_timer_sync_to_ulpss_pclk = false,
.ulp_timer_clk_input_src = ULP_TIMER_32KHZ_XTAL_CLK_SRC,
.ulp_timer_skip_switch_time = true
};
// 30 seconds = 30,000,000 microseconds
uint32_t match_value;
sl_si91x_ulp_timer_get_match_value(ULP_TIMER_TYP_1US, 30000000, &match_value);
// Configure for periodic operation
ulp_timer_config_t timer_config = {
.timer_num = ULP_TIMER_0,
.timer_mode = ULP_TIMER_MODE_PERIODIC,
.timer_type = ULP_TIMER_TYP_1US,
.timer_match_value = match_value,
.timer_direction = ULP_TIMER_DIRECTION_DOWN
};Parameter | Value |
|---|---|
Power Consumption | 2–3 µA (sleep), 5–15 mA (active) |
Estimated Battery Life | 3–7 days (coin-cell battery) |
Example 3: Industrial IoT Gateway#
Requirements:
Wake every 5 minutes for data transmission.
Operate for years on mains power with battery backup.
Timing accuracy of ±10 seconds per day is acceptable
Solution:
// Use 32kHz RC for lowest power (accuracy less critical for long periods)
ulp_timer_clk_src_config_t clock_config = {
.ulp_timer_clk_type = ULP_TIMER_CLK_TYPE_STATIC,
.ulp_timer_sync_to_ulpss_pclk = false,
.ulp_timer_clk_input_src = ULP_TIMER_32KHZ_RC_CLK_SRC,
.ulp_timer_skip_switch_time = true
};
// 5 minutes = 300 seconds = 300,000,000 microseconds
uint32_t match_value;
sl_si91x_ulp_timer_get_match_value(ULP_TIMER_TYP_1US, 300000000, &match_value);
// Configure for periodic operation
ulp_timer_config_t timer_config = {
.timer_num = ULP_TIMER_0,
.timer_mode = ULP_TIMER_MODE_PERIODIC,
.timer_type = ULP_TIMER_TYP_1US,
.timer_match_value = match_value,
.timer_direction = ULP_TIMER_DIRECTION_DOWN
};Parameter | Value |
|---|---|
Power Consumption | 0.5–1 µA (sleep), 50–200 mA (active) |
Estimated Battery Life | 2–5 years (with backup battery) |
Advanced Low-Power Techniques#
Dynamic Clock Switching#
Some applications require different timing characteristics during active and sleep modes. The SiWx917 ULP Timer supports dynamic clock switching to balance accuracy and power consumption.
// High accuracy mode (calibration, active operation)
void enter_high_accuracy_mode(void) {
ulp_timer_clk_src_config_t high_accuracy_config = {
.ulp_timer_clk_type = ULP_TIMER_CLK_TYPE_DYNAMIC,
.ulp_timer_sync_to_ulpss_pclk = false,
.ulp_timer_clk_input_src = ULP_TIMER_REF_CLK_SRC,
.ulp_timer_skip_switch_time = false // Wait for stability
};
sl_si91x_ulp_timer_configure_clock(&high_accuracy_config);
// Recalculate match values for new clock frequency
uint32_t new_match_value;
sl_si91x_ulp_timer_get_match_value(ULP_TIMER_TYP_1US, 1000000, &new_match_value);
sl_si91x_ulp_timer_set_count(ULP_TIMER_0, new_match_value);
}
// Low power mode (normal operation, sleep)
void enter_low_power_mode(void) {
ulp_timer_clk_src_config_t low_power_config = {
.ulp_timer_clk_type = ULP_TIMER_CLK_TYPE_DYNAMIC,
.ulp_timer_sync_to_ulpss_pclk = false,
.ulp_timer_clk_input_src = ULP_TIMER_32KHZ_XTAL_CLK_SRC,
.ulp_timer_skip_switch_time = true
};
sl_si91x_ulp_timer_configure_clock(&low_power_config);
// Recalculate match values for new clock frequency
uint32_t new_match_value;
sl_si91x_ulp_timer_get_match_value(ULP_TIMER_TYP_1US, 1000000, &new_match_value);
sl_si91x_ulp_timer_set_count(ULP_TIMER_0, new_match_value);
}Tip: Use high-frequency clocks during active periods for precise timing, and switch to 32 kHz sources in low-power modes to extend battery life.
Multi-Timer Power Management#
Use multiple ULP Timers for different operational needs in SiWx917 power modes.
// Timer 0: High frequency, high power (active mode)
void configure_active_timer(void) {
ulp_timer_config_t active_config = {
.timer_num = ULP_TIMER_0,
.timer_mode = ULP_TIMER_MODE_PERIODIC,
.timer_type = ULP_TIMER_TYP_1US,
.timer_match_value = 100000, // 100ms
.timer_direction = ULP_TIMER_DIRECTION_DOWN
};
sl_si91x_ulp_timer_set_configuration(&active_config);
}
// Timer 1: Low frequency, low power (sleep mode)
void configure_sleep_timer(void) {
ulp_timer_config_t sleep_config = {
.timer_num = ULP_TIMER_1,
.timer_mode = ULP_TIMER_MODE_PERIODIC,
.timer_type = ULP_TIMER_TYP_1US,
.timer_match_value = 30000000, // 30 seconds
.timer_direction = ULP_TIMER_DIRECTION_DOWN
};
sl_si91x_ulp_timer_set_configuration(&sleep_config);
}
// Switch between modes based on system state
void switch_to_sleep_mode(void) {
sl_si91x_ulp_timer_stop(ULP_TIMER_0); // Stop high-power timer
sl_si91x_ulp_timer_start(ULP_TIMER_1); // Start low-power timer
// Enter low power mode
}Implementation Notes
Use Timer 0 for high-precision timing in PS4 (Active) mode.
Use Timer 1 for long-duration low-power timing in PS2 (ULP) mode.
Ensure correct timer synchronization before switching between modes.
Tip: Leverage multiple ULP Timers to manage different timing domains, such as fast control loops, slow wake events, and periodic maintenance cycles.
Best Practices for Power Optimization#
Follow these recommendations to ensure maximum efficiency when using the ULP Timer on the SiWx917 device:
Select the lowest-frequency clock that meets your timing accuracy requirements.
Use 32 kHz sources for long-duration, low-power timing.
Use MHz or REF clocks only when microsecond-level precision is needed.
Use the 1 µs timer type for most applications.
This mode provides the best balance between simplicity, precision, and efficiency.
Avoid unnecessary reconfiguration during low-power operation.
Configure timers once before sleep to reduce register writes and CPU wakeups.
Prefer periodic mode over repeatedly restarting one-shot timers.
Periodic mode minimizes software overhead and timing drift.
Apply clock division for very long timer intervals.
This reduces power consumption while maintaining timing accuracy.
Test in all target power states (PS4, PS2, PS1).
Verify actual current consumption and wake-up timing under real operating conditions.
Tip: Measure both sleep and active current to confirm that low-power performance aligns with your design goals.
Integration with Power Management#
Proper integration with the SiWx917 Power Manager ensures the ULP Timer operates seamlessly across power states and acts as a reliable wake source.
Wake Source Configuration#
Use the API below to configure the ULP Timer as a wake source.
// Configure ULP timer as wake source
sl_status_t status = sl_si91x_power_manager_set_wakeup_sources(
SL_SI91X_POWER_MANAGER_ULPSS_WAKEUP,
true
);
if (status != SL_STATUS_OK) {
// Handle configuration error
return;
}Note: Always configure the wake source before entering low-power mode to ensure the timer’s interrupt can wake the system correctly.
Power State Transitions#
The following example shows how to prepare the ULP Timer for low-power mode and handle wake-up events.
// Before entering low power mode
void prepare_for_low_power(void) {
// Ensure timer is running
if (!is_timer_running(ULP_TIMER_0)) {
sl_si91x_ulp_timer_start(ULP_TIMER_0);
}
// Verify wake source is configured
verify_wake_source_configuration();
// Enter low power mode
enter_power_state(PS1);
}
// After waking from low power mode
void handle_wake_from_timer(void) {
// Check if ULP timer caused the wake
if (is_ulp_timer_wake_source()) {
// Process timer event
process_timer_event();
// Re-enter low power mode if needed
if (should_continue_sleeping()) {
enter_power_state(PS1);
}
}
}Tip: Always verify that the ULP Timer clock source remains active in your target power mode (PS1/PS2) before entering sleep.
Troubleshooting Low-Power Issues#
Use the following guidance to resolve common issues when operating the SiWx917 ULP Timer in low-power modes.
Common Problems#
Issue | Possible Cause | Recommended Action |
|---|---|---|
Timer not waking system | Wake source not configured | Ensure Power Manager wake source is set correctly. |
Incorrect timing after wake | Clock frequency changed | Recalculate match values after each wake transition. |
High power consumption | Incorrect clock or mode | Verify that low-frequency clock sources are used in PS1/PS2. |
Timer stops during sleep | Clock domain inactive | Confirm the selected clock remains active in your power mode. |
Debugging Techniques#
Use GPIO toggles to confirm timer operation and interrupt behavior during sleep.
Measure power consumption using a current meter or power analyzer to validate ULP performance.
Check clock frequency before and after each power-state transition.
Verify wake-source configuration in the Power Manager before entering low-power states.
Start simple: Test with a basic timer example before integrating into complex timing workflows.
Note: Keep interrupt service routines (ISRs) short and non-blocking to prevent long wake durations and unnecessary energy consumption.