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 Reply
  • 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?

Children
  • 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

  • I tried it, even tried to disable interrupt for TXDRDY but still not working. I am unable to receive and transmit in the same application.

  • Hi 

    Another thing worth trying is to change the GPIO configuration on the TX pin. If RX doesn't work it could be because the TX pin is pulling the line high, and changing the drive settings might fix it. 

    Could you try to set the GPIO settings on your TX pin using one of the two configurations here and see if it works better?

        NRF_P0->PIN_CNF[x] = GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos |
                             GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos |
                             GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos;
    
        NRF_P0->PIN_CNF[x] = GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos |
                             GPIO_PIN_CNF_DRIVE_S0D1 << GPIO_PIN_CNF_DRIVE_Pos |
                             GPIO_PIN_CNF_PULL_Pullup << GPIO_PIN_CNF_PULL_Pos;

    Best regards
    Torbjørn

  • Thanks Torbjørn, It did not work. But I could see that the time elapsed in deinit and init is 2 ticks. So I think it may not affect much.

    But lastly I want to perform DFU using this module, what is your though on this.

  • Hi 

    You mean you want to do DFU over the UART?

    We have a serial transport module for DFU, but I am not sure it will work with half duplex only. It might require some changes to work with your UART implementation. 

    If you have a lot of questions on DFU I would recommend opening a new ticket, then one of the DFU experts can help you out Slight smile

    Best regards
    Torbjørn

Related