nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs

Peripheral UART, rx timeout and notification size

Hi,

I'm running the sample "peripheral_uart" on an nRF52dk. It has a config called CONFIG_BT_NUS_UART_RX_WAIT_TIME, which is set to 50. The comment says the unit is milliseconds. That value is sent into function uart_rx_enable(). When I read about that function (docs.zephyrproject.org/.../uart.html, it is said that the unit is microseconds. Which is correct?

What is the behaviour if two bytes are sent on UART to the DK right after each other? That is, the first bit of the second byte comes immediately after the first byte is finished. If communicating at 115200 it takes about 70 microseconds for a byte to be transmitted. If having the timeout set to 50 (supposing the unit is microseconds), will the timer expire before the byte is completed? Or how does the timer work?

What is a good value to have on the timer if communicating at 115200?

The sample handles long UART messages by splitting them into several 40-byte parts before they are supposed to be sent on BLE. But if a message is more than 21 bytes, I get the following warnings (in this case the UART message was 22 bytes):

<wrn> bt_att: No ATT channel for MTU 24
<wrn> bt_gatt: No buffer available to send notification
<wrn> peripheral_uart: Failed to send data over BLE connection

There is a maximum of 23 bytes (CONFIG_BT_L2CAP_TX_MTU) for notifcations. Is it meant that each programmer should solve this? If splitting, for instance, the UART-data into 20-byte parts instead of 40 bytes, it works fine.

Best regards,
Lars

  • Hi Edvin,

    When I run Peripheral UART, 50 microseconds is selected. I have adjusted UART_BUF_SIZE (CONFIG_BT_NUS_UART_BUFFER_SIZE) from 40 to 20 to deal with the size limit for notifications. When I send 100 bytes contiuously on UART to the nRF, it works fine to send them as notifications.

    I have taken the UART-part from Peripheral UART and added it to my own BLE-application. Then it works sometimes with 50 microseconds, but quite often it doesn't work. And the 100 byte data sending never works. But adjusting from 50 to 100 microseconds, it works. I don't know why there is a difference, perhaps things are drawn to their limits, and one implementation happens to work, while the other doesn't.

    Best regards,

    Lars

  • Hello Lars,

    It is difficult to know without knowing more details. What do you mean by "doesn't work"? Do you loose data? If so, where is it lost? Over BLE or do you loose it when receiving over UART? What are the "not working" symptoms that you are seeing?

    BR,

    Edvin

  • Hello Edvin,

    I got error messages saying something like "not able to allocate UART receive buffer". I try to repeat it now, but I don't get this error anymore... This message is printed from three places in the UART-code, and I don't remember from which I got the message. I have tried to use different versions of the SDK, but it always works with 50 microseconds. I guess I will try this later on to see if I can repeat it.

    BR,

    Lars

Related