You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/api-guides/deep-sleep-stub.rst
+73Lines changed: 73 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -155,3 +155,76 @@ Application Examples
155
155
.. only:: SOC_RTC_FAST_MEM_SUPPORTED
156
156
157
157
- :example:`system/deep_sleep_wake_stub` demonstrates how to use the Deep-sleep wake stub on {IDF_TARGET_NAME} to quickly perform some tasks (the wake stub code) immediately after wake-up before going back to sleep.
158
+
159
+
Measure Time from Deep-sleep Wake-up to Wake Stub Execution
In certain low-power scenarios, you may want to measure the time it takes for an {IDF_TARGET_NAME} chip to wake up from Deep-sleep to executing the wake stub function.
163
+
164
+
This section describes two methods for measuring this wake-up duration.
165
+
166
+
Method 1: Estimate Using CPU Cycle Count
167
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
168
+
169
+
This method uses the CPU's internal cycle counter to estimate the wake-up time. At the beginning of the stub (with the function type of `esp_deep_sleep_wake_stub_fn_t`), the current CPU cycle count is read and converted into time based on the running CPU frequency.
After running the example, you will see a log similar to:
174
+
175
+
.. code-block:: bash
176
+
177
+
Enabling timer wakeup, 10s
178
+
Entering deep sleep
179
+
ESP-ROM:esp32c3-api1-20210207
180
+
Build:Feb 7 2021
181
+
rst:0x5 (DSLEEP),boot:0xc (SPI_FAST_FLASH_BOOT)
182
+
wake stub: wakeup count is 1, wakeup cause is 8, wakeup cost 12734 us
183
+
wake stub: going to deep sleep
184
+
ESP-ROM:esp32c3-api1-20210207
185
+
Build:Feb 7 2021
186
+
rst:0x5 (DSLEEP),boot:0xc (SPI_FAST_FLASH_BOOT)
187
+
188
+
The ``wakeup cost 12734 us`` is time between Deep-sleep wake-up and wake stub execution.
189
+
190
+
Advantages:
191
+
192
+
- Requires no external hardware.
193
+
- Easy to implement.
194
+
195
+
Limitations:
196
+
197
+
- The measured duration may include part of the initialization flow.
198
+
- Not suitable for ultra-precise timing analysis.
199
+
200
+
Method 2: Use GPIO pins and Logic Analyzer
201
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
202
+
203
+
You can use one GPIO pin as the wake-up source and another GPIO pin to indicate when the wake stub begins execution. By observing the timing between these GPIO transitions on a logic analyzer, you can obtain an accurate measurement of the time from wake-up to stub execution.
204
+
205
+
For example, in the screenshot below, GPIO4 functions as the wake-up source, and GPIO5 indicates when the wake stub begins execution. The timing between the high level of GPIO4 and GPIO5 is the time from wake-up to stub execution.
0 commit comments