connecting internal GPIOs to create a pipe

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

connecting internal GPIOs to create a pipe

Postby davdav » Fri Sep 18, 2020 12:37 pm

Hi everybody,

In our project based on ESP32-WROOM-32D we use two UART ports:
-one is the "default" UART0 port (using standard TXD0 and RXD0 pins) used by customer
-the other is connected to a LTE modem (gpio_27 as TX pin and gpio_25 as RX pin)

In particular situation,it is necessary to talk directly to the modem via UART0 and we actually accomplish this behavior reading from UART0 and writing to UART1 and viceversa. In practice something like below:

Code: Select all

//Read data from UART0
int len = uart_read_bytes(UART_NUM_0, buffer, UART_BUFFSIZE, 100 / portTICK_RATE_MS);

if (len > 0)
{
	//write to UART1
	uart_write_bytes(UART_NUM_1, (const char*) buffer, len);
}
I wonder if IO_MUX can be setup such that the TXD0 pin is "physically connected" to gpio_27 and RXD0 is "physically connected" to gpio_25. In practice creating like a "pipe". Is it possible?

You may say: "Use interrupt on TXD0 and use gpio_set_level of gpio_27 to replicate the status". You are right but I would like to avoid interrupt.

Thanks in advance

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

Re: connecting internal GPIOs to create a pipe

Postby WiFive » Sat Sep 19, 2020 12:38 pm


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

Re: connecting internal GPIOs to create a pipe

Postby davdav » Mon Sep 21, 2020 11:04 am

WiFive wrote:
Sat Sep 19, 2020 12:38 pm
viewtopic.php?t=4253
Thanks @WiFive for suggestion. I have done the following test:

Code: Select all

gpio_matrix_in(GPIO_NUM_27, SIG_IN_FUNC228_IDX, false);                  //UART1 RX pin (GPIO_NUM_27)

gpio_matrix_out(GPIO_NUM_1, SIG_IN_FUNC228_IDX, false, false);       //UART0 TX pin (TXD0)

gpio_matrix_out(GPIO_NUM_21, SIG_IN_FUNC228_IDX, false, false);     //GPIO_NUM_21: just for test
gpio_matrix_out(GPIO_NUM_26, SIG_IN_FUNC228_IDX, false, false);     //GPIO_NUM_26: just for test
From GPIO_21 and GPIO_26 I'm able to check that the incoming character received from UART1 are "copied" to GPIOs. So the solution itself is promising.
However, I don't see anything exiting from GPIO_NUM_1.

Could it be a problem that GPIO_NUM_1 is used by uart driver so it can't output the signal from the matrix?

Thanks

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

Re: connecting internal GPIOs to create a pipe

Postby WiFive » Mon Sep 21, 2020 8:25 pm

Yes reconfigure mux

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

Re: connecting internal GPIOs to create a pipe

Postby davdav » Wed Sep 23, 2020 6:22 am

WiFive wrote:
Mon Sep 21, 2020 8:25 pm
Yes reconfigure mux
Thanks. The problem now is: how to do that? I will search some examples to reconfigure IO_MUX...

Do you think it is possible to reconfigure ONLY the TXD0 pin and let the RXD0 managed by uart driver? I this way I can still read the uart..

Thanks again

Who is online

Users browsing this forum: No registered users and 34 guests