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

Unable to receive on Rx pin because Tx is always high.

I have a custom board. It has its Tx and Rx combined into one wire bus. I am able to transmit data on the bus. But I am unable to receive any data on the board. This is because of circuit design.

In order to receive data I thought of disconnection the Tx pin when I am done transmitting the data. I did it by adding some code in `$SDK_ROOT/modules/nrfx/hal/nrf_uart.h`.

__STATIC_INLINE void nrf_uart_tx_pins_disconnect(NRF_UART_Type * p_reg)
{
#if defined(UART_PSEL_TXD_CONNECT_Pos)
    p_reg->PSEL.TXD = NRF_UART_PSEL_DISCONNECTED;
#else
    p_reg->PSELTXD = NRF_UART_PSEL_DISCONNECTED;
#endif
}

I thought of calling this function when I am done transmitting and want to receive data. This is works partially.

When I transmit and disconnect tx pin then I do not receive any data. But If I do not send any data and directly try to receive it works.

I want both way communication.

Is there anything to turn off Tx completely and just wait for receive, and when I want to transmit I enable the Tx and starts sending.

Parents
  • Hi

    Did you try to configure TX and RX to the same pin in the UART?

    In this case everything you send on TX will also be received on the RX, but you wouldn't have to switch back and forth. 

    Best regards
    Torbjørn

  • I am using different pin numbers.Its a custom board.


    Right now following workaround worked for me.

    Init UART using valid pin numbers for Tx and Rx.
    When done sending data uninit UART.
    Init UART with Rx and Tx pin as disconnected.

    This way I was able to receive and send data.

    But uninit/init would be a heck of overhead for the system. Do you know any better way to disconnect Tx completely but need to connect back when device needs to transmit data?

  • Hi 

    You should be able to manually overwrite the PSEL.TXD register without un-initializing the driver. It's a bit outside of how the driver is normally used, and is not tested by us, but with your interface being as it is the standard way doesn't really work ;)

    Once you set PSEL.TXD to 0xFFFFFFFF the pin will no longer be controlled by the UART peripheral, and the standard IO configuration from the NRF_GPIO module will take effect. 

    Best regards
    Torbjørn

Reply
  • Hi 

    You should be able to manually overwrite the PSEL.TXD register without un-initializing the driver. It's a bit outside of how the driver is normally used, and is not tested by us, but with your interface being as it is the standard way doesn't really work ;)

    Once you set PSEL.TXD to 0xFFFFFFFF the pin will no longer be controlled by the UART peripheral, and the standard IO configuration from the NRF_GPIO module will take effect. 

    Best regards
    Torbjørn

Children
Related