Page 1 of 2
[SOLVED]esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Thu Jul 25, 2019 1:57 pm
by davdav
Hi everybody,
I'm testing "esp_sleep_enable_uart_wakeup" function.
I have connected to UART0 (GPIO3 U0RX, GPIO1 U0TX) an external LTE module and I would like to wake up ESP32 when it is in light sleep but the external module send a particular string on the UART0.
I have done a very simple test. It seems to work, but as soon as I change these configuration for CONSOLE debug output from the default to the below ones:
Code: Select all
CONFIG_CONSOLE_UART_DEFAULT=
CONFIG_CONSOLE_UART_CUSTOM=y
CONFIG_CONSOLE_UART_NONE=
CONFIG_CONSOLE_UART_CUSTOM_NUM_0=
CONFIG_CONSOLE_UART_CUSTOM_NUM_1=y
CONFIG_CONSOLE_UART_NUM=1
CONFIG_CONSOLE_UART_TX_GPIO=25
CONFIG_CONSOLE_UART_RX_GPIO=27
CONFIG_CONSOLE_UART_BAUDRATE=115200
It doesn't work anymore. Unfortunately I would like to use UART1 to send out the debugs because UART0 is occupied to talk with the external module: but the changes in the sdkconfig (only the one reported above) seems to be the cause of the issue.
How to solve?
Thanks
Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Thu Jul 25, 2019 5:39 pm
by WiFive
Is uart0 initialized and functional before sleep?
Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Fri Jul 26, 2019 6:27 am
by davdav
WiFive wrote: ↑Thu Jul 25, 2019 5:39 pm
Is uart0 initialized and functional before sleep?
Yes, it is. UART0 is working perfectly and I can send commands (via U0TX GPIO1) and receive (via U0RX GPIO3) replies from the external module. Infact, with the "default" Configuration everything works as expected. The problem is to sent debugs on UART0 which interfere with external module.
I'm going to do a test the same configuration
Code: Select all
CONFIG_CONSOLE_UART_DEFAULT=
CONFIG_CONSOLE_UART_CUSTOM=y
CONFIG_CONSOLE_UART_NONE=
CONFIG_CONSOLE_UART_CUSTOM_NUM_0=
CONFIG_CONSOLE_UART_CUSTOM_NUM_1=y
CONFIG_CONSOLE_UART_NUM=1
CONFIG_CONSOLE_UART_TX_GPIO=25
CONFIG_CONSOLE_UART_RX_GPIO=27
CONFIG_CONSOLE_UART_BAUDRATE=115200
and enabling esp_sleep_enable_uart_wakeup on UART1 (i.e. my main uart in our design) in order to understand if it "follows" the configuration.
Thanks
Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Fri Jul 26, 2019 7:30 am
by WiFive
I think you might have to do this
Code: Select all
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);
Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Fri Jul 26, 2019 8:27 am
by davdav
WiFive wrote: ↑Fri Jul 26, 2019 7:30 am
I think you might have to do this
Code: Select all
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);
Unfortunately, it seems not working. This my code:
Code: Select all
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);
//wake up on uart0 (external module unsolicited)
uart_set_wakeup_threshold(UART_NUM_0, 3);
esp_sleep_enable_uart_wakeup(UART_NUM_0);
//write a debug on UART1 (main uart)
uart_write_bytes(UART_NUM_1, "enter light sleep\n", strlen("enter light sleep\n"));
uart_tx_wait_idle(UART_NUM_1);
vTaskDelay(pdMS_TO_TICKS(2000));
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_U0RXD);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_U0TXD);
/* Enter sleep mode */
esp_light_sleep_start();
I have used proposed function before and after esp_sleep_enable_uart_wakeup(UART_NUM_0).
I also checked that even if esp_sleep_enable_uart_wakeup(UART_NUM_1) is used and sdkconfig use a custom uart for CONSOLE, it doesn't work.
Thanks
Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Fri Jul 26, 2019 2:36 pm
by ESP_igrr
Sorry, this is only documented in the UART API reference at the moment — wakep only works on the IO MUX pins:
https://docs.espressif.com/projects/esp ... rt_port_ti
(see note in the function description)
Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Fri Jul 26, 2019 3:54 pm
by davdav
Thank you @ESP_igrr for the note. It is clear to me that GPIO3 should be used as function1 (i.e. U0RXD as reported in IO_MUX table in ESP32_datasheet_en.pdf page 50); however I don't figure out why this should be affected by the console config.
Despite this, is there a solution (even modifying some part of code in esp-idf) to my specific problem or do you confirm me that it is not possible to use UART0 RX (GPIO3) to wake up the module if UART1 is setup as custom console?
For example, can I force, just before entering light_sleep, GPIO3 to use function1 in IO_MUX? Is there a function/macro that can do this?
Thank you and regards.
Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Fri Jul 26, 2019 5:02 pm
by WiFive
Yes, the function I posted. I don't know why it doesn't work.
Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Fri Jul 26, 2019 9:35 pm
by davdav
WiFive wrote: ↑Fri Jul 26, 2019 5:02 pm
Yes, the function I posted. I don't know why it doesn't work.
If I share my test code, could you please check if you find something is wrong?
Maybe @ESP_igrr could also shade some light on this.
Thanks
Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration
Posted: Sat Jul 27, 2019 1:27 am
by WiFive
I have tested a simple example and it does work as long as you use the function calls I posted.