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
  • 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
  • Hi,

    The flow control signals are active low, so here the CTS is low for most of the time (meaning the other device can send data). Could it be that you have swapped the RTS and CTS lines? Does swapping them help?

    That aid, I notice that the CTS pin in this plot is high for every byte, meaning flow control is used for some reason. Could it be that you have set up single byte UART buffers, and that explains it? Can you double check and if so, increase UART buffer sizes?

    If that is not it, I would suggest testing on two DKs if you have them and if you can reproduce there as well, I can have a look at the code and tets on my end. If you can only reproduce on your HW, we need to look more closely at that.

Related