pinMode vs gpio_set_direction for UART

michcfr
Posts: 30
Joined: Mon Jan 29, 2018 5:55 pm

pinMode vs gpio_set_direction for UART

Postby michcfr » Wed Nov 17, 2021 1:37 am

Hello,
I am using the UART1 (RX:pin16 and TX:pin17) and I need TX to be push-pull output, so I used gpio_set_direction like this:

Code: Select all

#define Sender_Txd_pin 17
...
gpio_set_direction((gpio_num_t)Sender_Txd_pin, GPIO_MODE_OUTPUT);
But it is not possible to send data (println) through the UART. However, I can send data when I replace the above line by:

Code: Select all

pinMode(Sender_Txd_pin, OUTPUT);
My questions are:
-What did I missed to add before or after gpio_set_direction?
-Is pinMode(Sender_Txd_pin, OUTPUT) equivalent to gpio_set_direction((gpio_num_t)Sender_Txd_pin, GPIO_MODE_OUTPUT) to get TX push-pull output?

thx
Michel

chegewara
Posts: 2375
Joined: Wed Jun 14, 2017 9:00 pm

Re: pinMode vs gpio_set_direction for UART

Postby chegewara » Wed Nov 17, 2021 5:41 pm


michcfr
Posts: 30
Joined: Mon Jan 29, 2018 5:55 pm

Re: pinMode vs gpio_set_direction for UART

Postby michcfr » Wed Nov 17, 2021 6:00 pm

chegewara wrote:
Wed Nov 17, 2021 5:41 pm
pinMode is more than that:
https://github.com/espressif/arduino-es ... pio.c#L160
Ok, see. Thx
When calling pinMode(TX_pin, OUTPUT), is TX_pin In push-pull output mode?

michcfr
Posts: 30
Joined: Mon Jan 29, 2018 5:55 pm

Re: pinMode vs gpio_set_direction for UART

Postby michcfr » Tue Nov 23, 2021 11:54 pm

Hello
Can somebody help me on hox to know if calling pinMode(TX_pin, OUTPUT), makes TX_pin In push-pull output mode?

thx

Who is online

Users browsing this forum: No registered users and 111 guests