[SOLVED]esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

[SOLVED]esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby davdav » Thu Jul 25, 2019 1:57 pm

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
Last edited by davdav on Mon Jul 29, 2019 9:55 am, edited 1 time in total.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby WiFive » Thu Jul 25, 2019 5:39 pm

Is uart0 initialized and functional before sleep?

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby davdav » Fri Jul 26, 2019 6:27 am

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

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby WiFive » 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);

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby davdav » Fri Jul 26, 2019 8:27 am

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

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby ESP_igrr » Fri Jul 26, 2019 2:36 pm

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)

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby davdav » Fri Jul 26, 2019 3:54 pm

ESP_igrr wrote:
Fri Jul 26, 2019 2:36 pm
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)
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.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby WiFive » Fri Jul 26, 2019 5:02 pm

Yes, the function I posted. I don't know why it doesn't work.

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby davdav » Fri Jul 26, 2019 9:35 pm

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

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: esp_sleep_enable_uart_wakeup with CONFIG_CONSOLE_UART_CUSTOM configuration

Postby WiFive » Sat Jul 27, 2019 1:27 am

I have tested a simple example and it does work as long as you use the function calls I posted.

Who is online

Users browsing this forum: Google [Bot] and 69 guests