RS-485 support

EndlessDelirium
Posts: 8
Joined: Wed May 10, 2017 1:12 pm

RS-485 support

Postby EndlessDelirium » Wed May 10, 2017 1:23 pm

Hi there

The datasheet claims that there is some RS-485 support and in the IDF reference manual there are also some related registers. Unfortunately there is very limited documentation of this feature and I just cannot make sense of the very short register documentation.
Could anyone else already figure out how to use those RS-485 related features?

What I'm most interested in is to convince the UART module to somehow automatically switch on/off the RS-485 transmitter whenever we start/stop sending.

Thanks in advance for your help!

Edit (2017-08-13):
Since this thread is quite long already, here a short recap: Edit (2017-09-17):
A code example can be found here: https://github.com/espressif/esp-idf/pull/1006
Last edited by EndlessDelirium on Sun Sep 17, 2017 10:45 am, edited 2 times in total.

willko1107
Posts: 1
Joined: Wed May 17, 2017 1:27 pm

Re: RS-485 support

Postby willko1107 » Wed May 17, 2017 1:31 pm

@EndlessDelirium, I've noticed the same thing. A few registers and that's it. I'm not skilled enough to even understand whether there is a complete implementation based on looking at the registers, and I'm certainly not able to create meaningful code from them.

If someone has successfully gotten 485 working and can share some example code, it would be really great!

WK

iosixllc
Posts: 71
Joined: Fri Mar 17, 2017 12:13 am

Re: RS-485 support

Postby iosixllc » Wed May 24, 2017 10:56 pm

Same here. I need to implement J1708. No issues at all with the ESP8266, but the new driver seems to be a bit of a mess.

EndlessDelirium
Posts: 8
Joined: Wed May 10, 2017 1:12 pm

Re: RS-485 support

Postby EndlessDelirium » Mon May 29, 2017 7:10 am

I've now submitted a technical inquiry to Espressif directly. Let's see whether we get an answer... :-)

hwmaier
Posts: 31
Joined: Sun May 28, 2017 7:30 am

Re: RS-485 support

Postby hwmaier » Tue May 30, 2017 2:29 am

I am also interested whether a line driver can be automatically controlled and if it can, how this is accomplished.

There are heaps of RS485 specific functions in the UART which lack documentation and one only can guess what they are, collision detection for example seems an interesting feature (UART_RS485_CLASH_INT). The others are the purpose of the various delay features.

I also wonder what the purpose of a special UART_RS485_PARITY_ERR_INT and UART_RS485_FRM_ERR_INT interrupts is compared to the generic UART_PARITY_ERR_INT and UART_FRM_ERR_INT interrupts. Why different ones?

hwmaier
Posts: 31
Joined: Sun May 28, 2017 7:30 am

Re: RS-485 support

Postby hwmaier » Wed May 31, 2017 3:19 am

I am also interested whether a line driver can be automatically controlled
If the UART cannot do this automatically, there is always the option to use a GPIO output to turn on the driver before filling the FIFO and turning it off once transmission is finished.

Something like should work:

Code: Select all

gpio_set_level(RS485DRIVER_EN_GPIO, 0);
uart_write_bytes(...)
uart_wait_tx_done(...)
gpio_set_level(RS485DRIVER_EN_GPIO, 1);

EndlessDelirium
Posts: 8
Joined: Wed May 10, 2017 1:12 pm

Re: RS-485 support

Postby EndlessDelirium » Wed May 31, 2017 12:13 pm

@hwmaier: Yes, that's more or less what we are currently doing. Regarding uart_wait_tx_done the documentation says that this call blocks until the TX FIFO is empty. That however doesn't necessarily means that the last bit of the data is already shifted out once that call returns.

We kinda expect this functionality to be available in hardware. Otherwise it would be rather ridiculous to claim that this SoC has RS-485 support.

The technical inquiry I've sent to Espressif is currently still unanswered.

User avatar
martinayotte
Posts: 141
Joined: Fri Nov 13, 2015 4:27 pm

Re: RS-485 support

Postby martinayotte » Wed May 31, 2017 4:00 pm

There are also driver chips, such MAX13487, that does automatic TX enabling without any GPIO requirement.

hwmaier
Posts: 31
Joined: Sun May 28, 2017 7:30 am

Re: RS-485 support

Postby hwmaier » Thu Jun 01, 2017 1:24 am

@ EndlessDelirium: uart_wait_tx_done() is actually not using the TXFIFO_EMPTY interrupt but a dedicated TX_DONE interrupt which is raised once transmission has completed if I understand the documentation correctly, eg the last bit shifted out. I verified this using a logic analyzer and also patched uart.c to control the line driver automatically from the ISR rather using wait_tx_done(). This resulted in perfect and precise control of the line driver. But I agree this should be done in hardware if they claim RS485 support.

@martinayotte: Thanks for the suggestion. There are many ways to implement the feature using additional hardware (which increases BOM cost) or additional software, but the expectation was, that integrated RS485 support would offer this feature out of the box (like other SoC and uC do when they claim RS485 support). Sadly we still do not know from official sources if the ESP32 does support it or not. There is no documentation whatsoever regards the workings of the so called RS485 mode.

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: RS-485 support

Postby ESP_Sprite » Thu Jun 01, 2017 1:51 am

Fyi, we can see if we can integrate this in our driver. Could you maybe also open up an official feature request as an issue on the esp-idf Github repo at https://github.com/espressif/esp-idf/issues ? That way, we can track the request.

Who is online

Users browsing this forum: ESP_Sprite and 215 guests