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

NRF52832 single wire uart

Is it possible to use the NRF52832 UART in half-duplex single-wire mode, by assigning TXD and RXD to the same GPIO, setting the GPIO drive to disconnect '1' and using a pull-up resistor?

  • I misunderstood you when you said "disconnect", I thought (for some reason) that you meant input buffer disconnect.

    Using S0D1 or H0D1 should work the same way as the diode, you are correct.

    I tested assigning UART RXD and TXD to the same pin and it works, but we cannot guarantee correct behaviour always. You should test it thoroughly before going for that solution.

    I will update my answer.

  • Hi Ole!

    So, you said that you will update the answer. How's it going now? I also need this solution for my application requirements. I set UART TX and RX to the same pin (pin 6) and then connected this pin 6 to USB uart cable (a 10k resistor is connected between TX and Rx of the USB uart cable). In my application, the nrf52832 uart, most of the time, is set to Rx. Only when a valid command is received from an external processor, it changes the pin 6 direction to output and sends a reply. After finishing sending the reply, the application configures pin 6 direction to input again. I configure pin 6 for tx as follows:

    #define SERIAL_TX_PIN 6
    #define SERIAL_RX_PIN 6
        nrf_gpio_cfg(
            SERIAL_TX_PIN,
            NRF_GPIO_PIN_DIR_OUTPUT,
            NRF_GPIO_PIN_INPUT_DISCONNECT,
            NRF_GPIO_PIN_PULLUP,
            NRF_GPIO_PIN_H0D1,
            NRF_GPIO_PIN_NOSENSE
        );
    
    uart_write("this is a reply");
    
        nrf_gpio_cfg(
                SERIAL_RX_PIN,
                NRF_GPIO_PIN_DIR_INPUT,
                NRF_GPIO_PIN_INPUT_DISCONNECT,
                NRF_GPIO_PIN_PULLUP,
                NRF_GPIO_PIN_H0D1,
                NRF_GPIO_PIN_NOSENSE
        ); 
    

    The problem is that every time is send by uart tx, the terminal continously displays what has been sent out all the time witout stopping.

    I'm actually porting my code from another BLE SoC to Nordic nRF52832 SoC. The hardware interface is nothing but a usb uart cable connected directly to pin 6 of nrf52832.

  • @Quangng: Could you post your full code ? What exactly inside uart_write() ? Would it be blocking code ? I suspect that right after you send your reply and switch to RX, there is an issue that trigger the reply again ( as maybe there was something accidentally got in the RX buffer ).

    I would suggest you to create another question.

  • Hi!

    The problem is now solved. The configuration of uart pin direction works correctly. It works by rebuilding the project, not by building (F7 in Keil IDE) the project.

  • hi joojoo. This is my problem. can you give me your full code, pls? Thank you very much.

Related