Flow control is not working between nrf9160 and nrf5340

I am using 9160 as slave which communicates with nrf5340(master) over UART. with flow control disabled everything works but as soon as I enable the hardware flow control then the nf9160 is not able to send the data to nRF5340.

My configuration:

  • at 5340 side:

&uart0 {
status = "okay";
current-speed = <460800>;
pinctrl-0 = <&uart0_default>;
pinctrl-1 = <&uart0_sleep>;
pinctrl-names = "default", "sleep";
hw-flow-control;
};

uart0_default: uart0_default {
group1 {
psels = <NRF_PSEL(UART_RTS, 1, 12)>,
<NRF_PSEL(UART_CTS, 1, 13)>;
};
group2 {
psels = <NRF_PSEL(UART_TX, 0, 3)>,
<NRF_PSEL(UART_RX, 0, 5)>;
bias-pull-up;
};
};

uart0_sleep: uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 3)>,
<NRF_PSEL(UART_RX, 0, 5)>,
<NRF_PSEL(UART_RTS, 1, 12)>,
<NRF_PSEL(UART_CTS, 1, 13)>;
low-power-enable;
};
};

  • AT 9160 side:

&uart1 {
status = "okay";
hw-flow-control;
current-speed = <460800>;
pinctrl-0 = <&uart1_default>;
pinctrl-1 = <&uart1_sleep>;
pinctrl-names = "default", "sleep";
};

uart1_default: uart1_default {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 29)>,
<NRF_PSEL(UART_RTS, 0, 27)>,
<NRF_PSEL(UART_CTS, 0, 26)>,
<NRF_PSEL(UART_RX, 0, 28)>;
};
};

uart1_sleep: uart1_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 29)>,
<NRF_PSEL(UART_RX, 0, 28)>,
<NRF_PSEL(UART_RTS, 0, 27)>,
<NRF_PSEL(UART_CTS, 0, 26)>;
low-power-enable;
};
};

I have also verified in the peripheral that it says flow control is enabled at both the sides

Parents Reply Children
  • This is odd, so I have quite a few additional questions:

    1. Is the only difference flow control or not?
    2. Can you show the configuration you use without flow control as well, and plots showing both flow control and no flow control while attempting to send the same data?
    3. Perhaps also the code that does UART communication on both ends?
    4. Did you do any other changes when things stopped working than enable flow control?
    5. Can you verify that the flow control pins are properly connected physically? Physically, which pins did you connect to each other (particuarily the CTS and RTS pins)?
  • 1.) Yes, the only difference is Flow Control.

    2.) The only change is:
    &uart1 {
    status = "okay";
    //hw-flow-control;
    current-speed = <460800>;
    pinctrl-0 = <&uart1_default>;
    pinctrl-1 = <&uart1_sleep>;
    pinctrl-names = "default", "sleep";
    };

    4.) No other changes. 

  • Hi,

    I see. This shows you disabling flow control. Can you show how you have connected the pins between the nRF9160 and the nRF5340? And how the pins are configured? I ask becasue I wonder if there is an issue in the connection (RTS and CTS pins crossed, perhaps?)

  • nrf5340:

    Signetik with nrf9160:

    Tx code:

    bool Tx(uint8_t *txBuff, size_t numBytes)
    {
    bool ret = false;
    if (_LockTx())
    {
    if (CHECK_IF_OFF(GetCurrentPowerState()))
    {
    LOG_DBG("tried to tx when UART is off!\n");
    _UnlockTx();
    return false;
    }

    if (numBytes <= _txBufferSize)
    {
    int status = 0;

    status = uart_tx(_uartDevice, txBuff, numBytes, (int32_t)(_byteTime_us * numBytes));
    if (status == 0)
    {
    status = k_sem_take(&_txSemaphore, K_USEC(_byteTime_us * numBytes));
    if (status == 0)
    {
    LOG_DBG("successfully transmitted %u bytes\n", numBytes);
    ret = true;
    }
    else
    {
    LOG_ERR("tx timed out!\n");
    }
    }
    else
    {
    LOG_ERR("tx failed! code: %d\n", status);
    LOG_ERR("device name: %s\n", _uartDevice->name);
    }
    }
    else
    {
    LOG_ERR("tx failed! num bytes to tx (%u bytes) is larger than the UART buffer size (%u bytes)\n", numBytes, _txBufferSize);
    }

    _UnlockTx();
    }

    return ret;
    }

    The logic analyzer is connected at 5340 side where RTS pin is not toggling

  • We are using the following:

    • Zephyr: 3.6.99
    • nRF SDK version: 2.7
Related