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

Configure UART Transmit Pin as Open-Drain

Question: for the nRF52840, if I configure a GPIO pin as an open-drain output (DRIVE setting of S0D1) and then select this pin as a UART transmit pin, does the open drain setting persist or does the UART peripheral change the DRIVE setting?

Background: I would like to use a single wire to communicate (half-duplex) between a nRF52840 and another microcontroller. My concept was to have an external pull-up on the line and make the UART output from each micro open-drain. I could do this with additional hardware, but it would be nice to do it with a simple pin configuration change in the nRF52840.

I found MartinBL's post in this thread that says the GPIO DRIVE setting affects the pin operation even after the TWI module takes over. However, the post is 2 years old and I wanted to verify that this would apply to the UART peripheral as well.

Thanks!

  • Hi,

    The UART driver will reconfigure the tx and rx pins after it has been initialized. This can be seen in the lower layer driver nrfx_uart.c where it uses apply_config() to configure the pins in the initializing function. 

    From the product specification:

    "Other peripherals in the system can connect to GPIO pins and override their output value and configuration, or read their analog or digital input value"

    regards

    Jared 

  • Jared,

    Thanks for the reply. I'm willing to skip the UART driver and configure the GPIO and UART registers directly. I'm wondering what changes the UART peripheral makes to the GPIO configuration. The product spec quotation says a peripheral can override the GPIO configuration, but it doesn't say what part of the configuration is overridden.

    According to this quote from MartinBL in this thread, it would seem that the DRIVE field in the GPIO config is not overridden (at least for TWI). Can anyone confirm that this is also true for the UART?

    MartinBL quote: "I talked to one of our TWI architects and he said that the GPIO settings actually do influence the pin even when the TWI is enabled. In other words, changing the drive strength from S0D1 to S0S1 will have an effect on the TWI bus."

  • Hi,

    Well, the peripheral it's entirely dependent on the driver, which means that if you write your own driver that doesn't override the GPIO configuration then it will not happen. 

    regards

    Jared

Related