uart_set_pin problem with UART_PIN_NO_CHANGE ?

samsam
Posts: 50
Joined: Sun Jun 04, 2017 5:26 pm

uart_set_pin problem with UART_PIN_NO_CHANGE ?

Postby samsam » Sun Jul 09, 2017 3:31 am

I was trying to use UART2 with this statement:

uart_set_pin(EX_UART_NUM, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); // as per esp-idf UART example
and my external serial device output was connected to GPIO16, but the statement doesn work.

instead

uart_set_pin(EX_UART_NUM, 17, 16, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); // works Ok

so the documentation for uart_set_pin and UART_PIN_NO_CHANGE is a little confusing:
"UART ** pin GPIO number, if set to UART_PIN_NO_CHANGE, use the current pin. " and my wild guess was that current pin eventaually mean the pin listed in esp32_datasheet_en.pdf pg47 table IO_MUX which for UART2 are 16(RXD) and 17(TXD), but obviously either my guess is wrong, or there is some bug in the SDK?
Could you explain where is the problem?
Thanks

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

Re: uart_set_pin problem with UART_PIN_NO_CHANGE ?

Postby WiFive » Sun Jul 09, 2017 4:18 am

UART_PIN_NO_CHANGE means do not set this pin, it does not mean UART_PIN_DEFAULT. There is no UART_PIN_DEFAULT. The reason the example works is because the bootloader configures UART0. Really it is not helpful though and you should always specify your pins on the first call.

samsam
Posts: 50
Joined: Sun Jun 04, 2017 5:26 pm

Re: uart_set_pin problem with UART_PIN_NO_CHANGE ?

Postby samsam » Sun Jul 09, 2017 2:55 pm

Thanks WiFive, I guessed that UART_PIN_NO_CHANGE might mean what you said, but left it behind as I didn't imagine how then in the example the driver could guess which are the pins to use :(

One more question:
in uart_events_example_main.c > uart_event_task() there is one buffer allocated that is never used:

uint8_t* dtmp = (uint8_t*) malloc(BUF_SIZE);

Just at the end (which btw is not reacheble) is purged.

Is dtmp has some hidden use(s) there or is just some leftover/or for future use - let say if there will be some code to procced the uart data inside uart_event_task()?

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

Re: uart_set_pin problem with UART_PIN_NO_CHANGE ?

Postby WiFive » Sun Jul 09, 2017 7:38 pm

Probably just forgot to copy the data there

User avatar
rudi ;-)
Posts: 1727
Joined: Fri Nov 13, 2015 3:25 pm

Re: uart_set_pin problem with UART_PIN_NO_CHANGE ?

Postby rudi ;-) » Sun Jul 09, 2017 7:42 pm

@WiFive
can you test ?
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

Who is online

Users browsing this forum: akasaka_spk and 92 guests