<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Get the available space of the UART tx buffer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72653/get-the-available-space-of-the-uart-tx-buffer</link><description>Hello, 
 I have a application on a nRF52840DK as central. The code is based on the ble_app_uart_c example. 
 I need to send a lot of data through UART into the serial port of my pc (~120 kBit/s). I want to make sure that the tx buffer of the UART does</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 11 Mar 2021 13:48:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72653/get-the-available-space-of-the-uart-tx-buffer" /><item><title>RE: Get the available space of the UART tx buffer</title><link>https://devzone.nordicsemi.com/thread/299299?ContentTypeID=1</link><pubDate>Thu, 11 Mar 2021 13:48:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37332b3e-545d-49fd-810f-f2a9cf724cb1</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you are using the unmodified ble_app_uart_c example with app_uart_fifo for sending data over UART, you should get a&amp;nbsp;NRF_ERROR_NO_MEM return code from&amp;nbsp;app_uart_put when the FIFO TX buffer configured for app_uart is full. The FIFO is not available outside of the library, but you can create a function to return the available size like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint32_t app_uart_get_tx_fifo_size(void)
{
    return (m_tx_fifo.buf_size_mask + 1) - FIFO_LENGTH(m_tx_fifo);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that app_uart transmits a single byte over UART at a time. If you need to transfer large amounts of data over UART quickly, you may be better off with using the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__uarte.html"&gt;UARTE driver&lt;/a&gt; with EasyDMA support, or the new &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_libuarte.html"&gt;libUARTE library&lt;/a&gt;. These allows you to send larger chunks of data over UARTE (up to 65535 bytes for nRF52840) directly from RAM, without any CPU intervention.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>