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

Use app_uart_put() to send data

After I add uart function to ble_example, I use app_uart_put()to send data,but data only one byte.What can I do?My board is nRF52-DK.SDK is nRF5_SDK_11.0.0_89a8197.This is my code main.c

  • There is no other way in Nordic UART driver then using app_uart_put() function and flush bytes to UART Tx stream one by one. You have it on many instances of your code so I suppose you do it properly. One way how streamline this is to use UART with FIFO module which simply adds all Tx and Rx bytes to the queue and in case of outgoing transfer it handles UART events such as NRF_DRV_UART_EVT_TX_DONE and outputs next byte (until end of current queue depth is reached). I believe nrf_log module is using it y default if you go with UART and not RTT...

    Or does your "but data only one byte" means that you never get more than one byte on the other side of UART regardless how many times you call app_uart_put()? That would indicate rather problem with the interpretation on receiver's side (is that some Terminal program on PC and using UART to USB serial convertor or something similar?)

  • Hi,endnode.app_uart_put() is called sendBeacon_data() in the timeout_timeout_handler(). I use peripheral uart_example , this uart config as same as uart config in the main.c,but peripheral uart_example can console to Putty.

  • Still not sure I do understand the problem. There are only one UART peripheral on nRF5x chips so you can only have one app_uart instance. Is there any problem with seeing data which you send by app_uart_put() function byte by byte on terminal side? If so then what exact problems you see?

  • Hi,

    This is caused by a known bug in SDK 11, where the UART is only logging one character. See the what are SDK 11.0.0 known issues post for a list of known bugs in SDK 11.

    The fix is to replace app_uart.c with app_uart_fifo.c. You will also need to add app_fifo.c and add the path(..\..\..\..\..\..\components\libraries\fifo) to the "Include Paths" in the "Options for target.." settings.

  • Hi Sigurd,

    I have followed the steps you have shared to fix this bug. My app_uart_put function goes into the app_uart_fifo file and i have added the app_fifo.c file and the path that you have mentioned. But still I am unable to send multiple bytes of data using app_uart_put function no matter how many times I call it.

    I am only able to see 1 byte of data.

    Is there anything I am missing out?

    Kindly let me know if anything is left out

    Thanks & Regards

    Sudeep R J

Related