This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART as 485

Hi, everyone,

We develope project on nRF52832 Chip. It has one UART port and we need to make it working as RS485. For this purpose we connected to TX/RX pins the required IC. In software we selected for UART these pins as TX/RX too. But in addition to these two pins the third Transfare enable pin exists too that we mustapply to UART too. We are developing the project on SDK15.0. for pin selection exists the structure "nrf_drv_uart_config_t" where are the "pselrxd" and "pseltxd" variables for applying the pin. How is it possible to apply the third Transfare Enable pin?

If the option for the third Transfare Enable pin doesn't exist theoreically it is possible to set and clear the pin value manualy but there we meet another problems:

1. If we set this pin, then sending the data and then we are clearing the pin the algorhythm will work correctly only if the UART is configured in blocking mode.

2. To solve the problem "1." for non-blocking mode we can of cose to move the pin clearing function to the event handler applied to uart, but in this case we meet another two problems:

3. In the event handler exists only three events: "Transmit complate", "Receive complate" and "Error", but the event "Start of transmission" doesn't exist at all. Due to this reason we cannot move to the event handler the function setting "Enable Transmission Pin" too. Of cose we don't need to do it -- we can set the pin before calling sending transmission procedure, but the algorhythm in this case becomes not estetic enough.

4. The controlling algorhythm for the "Transfare Enable Pin" becomes different for blocking mode and non blocking mode. And in the future if someone chnges it's mode and forgets to move the Pin Clearing command to event or from it the program will malfunction tha can cause to a lot of time spending for finding problem.

What is the most elegant desition for this problem?

Best Regards

Boris Fridman

Related