ESP32 ULP minimum wakeup time
Posted: Thu Sep 06, 2018 11:16 am
Hi,
I'm trying to check the minimum wakeup period for the ULP. For that I did a small sample code for the ULP which just turns ON and OFF RTC_GPIO17 (GPIO27) and halts. In the main app I just configure GPIO direction and set the wakeup period for the ESP32 using the IDF provided function for that. The main CPU then goes deep sleep and it never wakes up. Only ULP keeps running.
The code for ULP is as follows:
And the code for the main processor just sets GPIO direction, configures ULP and sets it off calling ULP run. The configuration function contains basically this code:
For what I understand, ULP wakeup period is configurable in 6.67us steps (uses 150 kHz clock) and the ulp_set_wakeup_period helper function takes microseconds as argument.
For example, doing ulp_set_wakeup_period(0, 300) should generate a periodic signal consisting of a very narrow pulse every 300us.
The problem is that it doesn't. Every period I set yields a periodic signal with approx 160us extra period. I mean,
This:
ulp_set_wakeup_period(0, 300)
generates a periodic signal with ~460us period, while this:
ulp_set_wakeup_period(0, 7)
generates a ~167us periodic signal.
Pulse width of the signal is about 1.2us in all cases (ULP execution time).
I can't find anything about these extra 160us in the documentation. Do you have any extra info about it?
I'm trying to check the minimum wakeup period for the ULP. For that I did a small sample code for the ULP which just turns ON and OFF RTC_GPIO17 (GPIO27) and halts. In the main app I just configure GPIO direction and set the wakeup period for the ESP32 using the IDF provided function for that. The main CPU then goes deep sleep and it never wakes up. Only ULP keeps running.
The code for ULP is as follows:
Code: Select all
#include "soc/rtc_cntl_reg.h"
#include "soc/soc_ulp.h"
#include "soc/rtc_io_reg.h"
.bss
/* Code goes into .text section */
.text
.global entry
entry:
/* Disable hold of RTC_GPIO17 output */
WRITE_RTC_REG(RTC_IO_TOUCH_PAD7_REG,RTC_IO_TOUCH_PAD7_HOLD_S,1,0)
/* Set the RTC_GPIO17 output HIGH */
WRITE_RTC_REG(RTC_GPIO_OUT_W1TS_REG,RTC_GPIO_OUT_DATA_W1TS_S+17,1,1)
/* Set the RTC_GPIO17 output LOW */
WRITE_RTC_REG(RTC_GPIO_OUT_W1TC_REG,RTC_GPIO_OUT_DATA_W1TC_S+17,1,1)
/* Enable hold of RTC_GPIO17 output */
WRITE_RTC_REG(RTC_IO_TOUCH_PAD7_REG,RTC_IO_TOUCH_PAD7_HOLD_S,1,1)
/*halt and wait for next ULP timer wakeup*/
halt
Code: Select all
rtc_gpio_init(ulp_toggle_num);
rtc_gpio_set_direction(ulp_toggle_num, RTC_GPIO_MODE_OUTPUT_ONLY);
/* Set ULP wake up period to XXus */
ulp_set_wakeup_period(0, XX);
For example, doing ulp_set_wakeup_period(0, 300) should generate a periodic signal consisting of a very narrow pulse every 300us.
The problem is that it doesn't. Every period I set yields a periodic signal with approx 160us extra period. I mean,
This:
ulp_set_wakeup_period(0, 300)
generates a periodic signal with ~460us period, while this:
ulp_set_wakeup_period(0, 7)
generates a ~167us periodic signal.
Pulse width of the signal is about 1.2us in all cases (ULP execution time).
I can't find anything about these extra 160us in the documentation. Do you have any extra info about it?