Power Manager Debugging and Error Handling#
This section provides guidance on troubleshooting, interpreting error codes, and applying best practices for effective power management in Silicon Labs applications. It also covers considerations for power state transitions, peripheral dependencies, and measuring power consumption.
Common Debugging Tips#
When debugging applications, use systematic checks to identify issues quickly. Refer to the official troubleshooting resource for detailed steps: WiSeConnect Debugging Guide.
If a power transition is not working, check the following:
Verify the domain dependency tree.
Confirm peripheral requirements.
Review power state constraints.
Error Code Handling#
Error code handling is essential for building resilient applications. This section explains how the Power Manager Service communicates results using standardized return values.
The Power Manager Service uses Silicon Labs status codes (sl_status_t)
to indicate the result of an operation. These codes provide detailed
diagnostic information and support robust error recovery across the
power management system.
Understanding Error Codes#
All Power Manager APIs return error codes that indicate success or failure.
Each code has a unique hexadecimal value for programmatic checks.
Codes are grouped by category, such as success, state errors, parameter errors, or resource issues.
Applications should always check return values and implement appropriate recovery strategies.
Complete Error Code Reference#
Error Code | Value | Category | Description | Specific Power Manager Context | Recovery Action |
|---|---|---|---|---|---|
SL_STATUS_OK | 0x0000 | Success | Operation completed successfully | API call executed without errors, power state transition completed, configuration applied successfully | Continue normal operation |
SL_STATUS_FAIL | 0x0001 | General | General failure from underlying system | Hardware abstraction layer failure, ROM API error, clock configuration failure | Check system state, verify hardware configuration, retry after delay |
SL_STATUS_INVALID_STATE | 0x0002 | State Error | Invalid power state for requested operation | Sleep request from PS0/PS1, conflicting PS1/Standby requests, transition not allowed in current state | Check current power state, remove conflicting requirements, ensure valid transition path |
SL_STATUS_NOT_READY | 0x0003 | State Error | System not ready for operation | Hardware initialization incomplete, clocks not stabilized | Wait for system stabilization, check initialization sequence |
SL_STATUS_BUSY | 0x0004 | State Error | System busy, operation cannot proceed |
| Wait for idle conditions, check blocking peripherals, retry after delay |
SL_STATUS_IN_PROGRESS | 0x0005 | State Error | Operation already in progress | Power-state transition ongoing, configuration change in process | Wait for completion, avoid concurrent operations |
SL_STATUS_TIMEOUT | 0x0007 | State Error | Operation timed out | Power transition timeout, peripheral response timeout, clock stabilization timeout | Check hardware connections, verify system clock, increase timeout if appropriate |
SL_STATUS_NOT_AVAILABLE | 0x000E | State Error | Feature not available | Peripheral not present, functionality disabled, unsupported on current variant | Check hardware configuration, verify component installation, use alternative approach |
SL_STATUS_NOT_SUPPORTED | 0x000F | State Error | Operation not supported | Feature not implemented, unsupported power state combination | Use supported alternatives, check API documentation |
SL_STATUS_NOT_INITIALIZED | 0x0011 | Initialization | Power Manager not initialized | API called before | Call |
SL_STATUS_ALREADY_INITIALIZED | 0x0012 | Initialization | Service already initialized |
| Continue normal operation, avoid duplicate initialization |
SL_STATUS_ALLOCATION_FAILED | 0x0019 | Resource | Memory allocation failed | Insufficient heap memory, resource exhaustion | Check memory usage, free unused resources, increase heap size if needed |
SL_STATUS_NO_MORE_RESOURCE | 0x001A | Resource | No more resources available | Maximum callbacks registered, resource pool exhausted | Release unused resources, check resource limits |
SL_STATUS_INVALID_PARAMETER | 0x0021 | Parameter | Invalid parameter value | Power state out of range, invalid clock scaling mode, unsupported peripheral combination | Validate parameter ranges, check enum values, verify parameter combinations |
SL_STATUS_NULL_POINTER | 0x0022 | Parameter | Required pointer is null | Null passed for output parameter, missing configuration structure | Provide valid pointer arguments, allocate required structures |
SL_STATUS_INVALID_CONFIGURATION | 0x0023 | Parameter | Invalid configuration | Conflicting peripheral settings, invalid RAM retention configuration | Review configuration parameters, check component dependencies |
SL_STATUS_INVALID_MODE | 0x0024 | Parameter | Invalid mode specified | Unsupported clock scaling mode, invalid wake-up mode | Use supported mode values, check API documentation |
SL_STATUS_INVALID_HANDLE | 0x0025 | Parameter | Invalid handle provided | Invalid event subscription handle, corrupted callback handle | Re-subscribe to events, verify handle validity |
SL_STATUS_INVALID_RANGE | 0x0028 | Parameter | Parameter out of valid range | Counter overflow (>255), invalid RAM bank selection | Check parameter bounds, validate against supported ranges |
Best Practices#
This section outlines best practices for managing power states, peripherals, sleep modes, error handling, and performance optimization.
Power State Management#
Start with PS3: Begin system initialization in PS3 mode to balance performance and power consumption.
Gradual transitions: Move through power states progressively (for example, PS3 → PS2 → PS1) to maintain system stability.
State requirements: Always add power state requirements before removing them to prevent unintended transitions.
Event handling: Subscribe to power state transition events to reconfigure peripherals when states change.
Peripheral Management#
Effective peripheral management minimizes power usage while maintaining functionality.
Power gates configuration: Enable or disable power gates based on active peripheral requirements.
RAM retention settings: Configure random access memory (RAM) retention based on memory usage during sleep.
Wake-up source selection: Choose wake-up sources (for example, general-purpose input/output [GPIO], calendar) that fit application needs.
Peripheral cleanup: Deinitialize peripherals before entering sleep modes to ensure clean state transitions.
Sleep Mode Optimization#
Sleep mode optimization reduces unnecessary power consumption.
RAM retention balance: Balance RAM retention with power savings to minimize overhead.
Peripheral shutdown: Power down unused peripherals before sleep.
Clock scaling: Apply clock scaling to reduce frequency when full performance is unnecessary.
Error Handling#
Robust error handling ensures application reliability.
Status checking: Always check return values from Power Manager API calls.
Error recovery: Implement recovery mechanisms to maintain system stability.
Graceful degradation: Design fallback strategies to handle failures without causing system crashes.
Performance Optimization#
Performance optimization reduces overhead while maintaining efficiency.
Minimize transitions: Avoid frequent or unnecessary power state transitions.
Peripheral efficiency: Keep only essential peripherals powered.
RAM usage optimization: Optimize RAM usage to reduce retention requirements during sleep.
Considerations#
This section provides considerations for managing power state requirements, handling peripheral dependencies, and measuring power consumption.
Add or Remove Power State Requirements#
The current state of the Cortex-M4 processor depends on the most recent active state. For example, if the PS4 state requirement is added and then removed, followed by adding and removing the PS3 requirement, the processor remains in the PS3 state.
In a multithreaded application:
The Power Manager maintains the highest state requested.
The processor transitions to a lower state only after all higher state requirements are removed.
If multiple requirements are added, the state changes when all requirements are removed.
Remove Peripheral Requirement#
If any peripheral is disabled in the PS4 state (for example, disabling the synchronous serial interface [SSI]), switching to the PS2 state and then back to the PS4 state powers on all peripherals again.
To disable peripherals after such transitions, call
sl_si91x_power_manager_remove_peripheral_requirement().
Measuring Power Consumption#
To measure power consumption selectively:
For the Network Wireless Processor (NWP): Configure the M4 processor in PS0 without RAM retention.
For the M4 processor: Configure the NWP in deep sleep without RAM retention (
DEEP_SLEEP_WITHOUT_RAM_RETENTION) when the device is not associated with an access point (AP).
Wi-Fi Dependency#
The function sl_si91x_power_manager_is_tx_command_in_progress()
returns a valid status only if the Wi-Fi component is included in the
system.