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

Time multiplexing UART nrf52832

Hi

I am using nRF52832 Soft device S132 sdk 15 and interfaced it with two peripherals over UART.  However I dont want to use them simultaneously. Since nrf42832 can support only one UART peripheral at a time, I would like to know how I can reconfigure the pins to establish a time mux based UART communication. Any examples related to internal pin crossbar would be highly appreciated.

Regards

Vignesh

Parents
  • You just need to change the pin numbers in PSEL.TXD and PSEL.RXD, and optionally PSEL.RTS and PSEL.CTS, at any time the UARTE is not in a transfer. 

    See f.ex. the UARTE HAL's nrf_uarte_txrx_pins_set function. 

    The pins you intend to switch to needs to be configured first:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    // Configure Tx and Rx pins:
    nrf_gpio_pin_set(NEW_TX_PIN);
    nrf_gpio_cfg_output(NEW_TX_PIN);
    nrf_gpio_cfg_input(NEW_RX_PIN, NRF_GPIO_PIN_NOPULL);
    nrf_uarte_txrx_pins_set(NRF_DRV_UART_INSTANCE(0), NEW_TX_PIN, NEW_RX_PIN);
    //If you indent to use HW Flow Control:
    nrf_gpio_pin_set(NEW_RTS_PIN);
    nrf_gpio_cfg_output(NEW_RTS_PIN);
    nrf_gpio_cfg_input(NEW_CTS_PIN, NRF_GPIO_PIN_NOPULL);
    nrf_uarte_hwfc_pins_set(NRF_DRV_UART_INSTANCE(0), NEW_RTS_PIN, NEW_CTS_PIN);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • How would you go along using that but while using the Serial Port Library?  I  have my serial define in: NRF_SERIAL_UART_DEF(m_serial_uart, 0);

    And m_serial_uart.instance was made by the macro: .instance = NRF_DRV_UART_INSTANCE(_instance_number)

    I don't know how to replace NRF_DRV_UART_INSTANCE(0) with the already created instance. I'm not using easy dma, so the call would be:

    nrf_uart_hwfc_pins_set(????, NEW_RTS_PIN, NEW_CTS_PIN);

    EDIT: Think i found how: nrf_uart_txrx_pins_set(m_serial_uart.instance.uart.p_reg, LCD_TX_PIN_NUMBER, LCD_RX_PIN_NUMBER);

Reply
  • How would you go along using that but while using the Serial Port Library?  I  have my serial define in: NRF_SERIAL_UART_DEF(m_serial_uart, 0);

    And m_serial_uart.instance was made by the macro: .instance = NRF_DRV_UART_INSTANCE(_instance_number)

    I don't know how to replace NRF_DRV_UART_INSTANCE(0) with the already created instance. I'm not using easy dma, so the call would be:

    nrf_uart_hwfc_pins_set(????, NEW_RTS_PIN, NEW_CTS_PIN);

    EDIT: Think i found how: nrf_uart_txrx_pins_set(m_serial_uart.instance.uart.p_reg, LCD_TX_PIN_NUMBER, LCD_RX_PIN_NUMBER);

Children