<?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>Printf over UART at high rate</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85118/printf-over-uart-at-high-rate</link><description>Hi Nordic, 
 
 I am using the SDK 17, s140 and the nrf52840 , with a modified multilink NUS central example. The intention is to print over UART as fast as possible all data received from the BLE. But I get sometimes errors on the UART transmission -</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 03 Mar 2022 12:50:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85118/printf-over-uart-at-high-rate" /><item><title>RE: Printf over UART at high rate</title><link>https://devzone.nordicsemi.com/thread/356041?ContentTypeID=1</link><pubDate>Thu, 03 Mar 2022 12:50:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7767660-93f0-4a37-a474-04c5a3aad56d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Not sure how that could happen.&amp;nbsp;nrf_libuarte_async_tx() will start a transfer, and you won&amp;#39;t be able to start a new one until the previous is done, that will only return NRF_ERROR_BUSY. You need to post the code you use to send the data to give some more context to what is happening.&lt;/p&gt;
&lt;p&gt;Are you sure that the issue is on the transmitter side and not on the receiver side? Have you checked with a logic analyzer that this is also what is output on the UART lines?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Printf over UART at high rate</title><link>https://devzone.nordicsemi.com/thread/355106?ContentTypeID=1</link><pubDate>Fri, 25 Feb 2022 19:55:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc28d10e-8baf-447e-8e74-85c00b519748</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;You won&amp;#39;t be able to achieve that with the SDK. &amp;nbsp;Use the &lt;a href="https://github.com/IOsonata/IOsonata"&gt;IOsonata library&lt;/a&gt;. &amp;nbsp;The driver implementation is much faster. &amp;nbsp;The UART drive non DMA version already 10% faster than DMA version of the nrfx. &amp;nbsp;DMA version is 20% faster. &amp;nbsp;It is also a lot simpler to use. &amp;nbsp;There are no 10000 defines to set. &amp;nbsp;UART printf is builtin as well. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;usage exemple :&amp;nbsp;&lt;a href="https://github.com/IOsonata/IOsonata/blob/master/exemples/uart/uart_prbs_tx.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/exemples/uart/uart_prbs_tx.cpp&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Use printf :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In C : UARTprintf(&amp;amp;g_UartDev, ...);&lt;/p&gt;
&lt;p&gt;In C++ object : g_Uart.printf(...);&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There is also a UART BLE Central example code :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/exemples/UartBleCentralDemo.cpp"&gt;https://github.com/IOsonata/IOsonata/blob/master/ARM/Nordic/exemples/UartBleCentralDemo.cpp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Printf over UART at high rate</title><link>https://devzone.nordicsemi.com/thread/355105?ContentTypeID=1</link><pubDate>Fri, 25 Feb 2022 19:06:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee1b0d7b-aa7a-4e3e-915b-d7b6441536f8</guid><dc:creator>User1321</dc:creator><description>&lt;p&gt;I only do TX, i don&amp;#39;t receive anything via UART.&lt;/p&gt;
&lt;p&gt;I configured the initialization to only use the app_timer since I&amp;#39;m using the RTC and TIMER to some other applications. At the beginning, when it was not properly configured, i got compilation errors+ fatal errors but once configured properly, i could use it without any compile-test issues.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_LIBUARTE_ASYNC_DEFINE(libuarte,
		0,  //_uarte_idx
		1, //_timer0_idx: TIMER instance used by libuarte for bytes counting
		NRF_LIBUARTE_PERIPHERAL_NOT_USED, //2, //_rtc1_idx: RTC instance used for timeout:If NRF_LIBUARTE_PERIPHERAL_NOT_USED then RTC instance is used or app_timer
		NRF_LIBUARTE_PERIPHERAL_NOT_USED, //_timer1_idx  TIMER instance used for timeout
		255,  //rx_buf_size Size of single RX buffer
		3); 
		

....

static void uart_init(void)
{
    uint32_t                     err_code;

    nrf_libuarte_async_config_t nrf_libuarte_async_config = {
            .tx_pin     = TX_PIN_NUMBER,
            .rx_pin     = RX_PIN_NUMBER,
            .baudrate   = UARTE_BAUDRATE_BAUDRATE_Baud1M,
            .parity     = NRF_UARTE_PARITY_EXCLUDED,
            .hwfc       = NRF_UARTE_HWFC_DISABLED,
            .timeout_us = 100,
            .int_prio   = APP_IRQ_PRIORITY_HIGH
    };

    err_code = nrf_libuarte_async_init(&amp;amp;libuarte, &amp;amp;nrf_libuarte_async_config, uart_event_handler, (void *)&amp;amp;libuarte);

    APP_ERROR_CHECK(err_code);

    nrf_libuarte_async_enable(&amp;amp;libuarte);

    static uint8_t text[] = &amp;quot;Start Example\r\n&amp;quot;;
    static uint8_t text_size = sizeof(text);

    err_code = nrf_libuarte_async_tx(&amp;amp;libuarte, text, text_size);
    APP_ERROR_CHECK(err_code);
}
		&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The issue that I&amp;#39;m having is that some lines are corrupted, for example, if i should get in the terminal something like:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;what i actually get is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;A B C D EA B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D EA B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
A B C D E F G H 
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And This affects badly my file parsing. I basically need to print something like this at a high rate, every ~2-5ms. At 1Mbps the speed seems to be enough, but the problem is that line not printed complete. It seems like a pattern, like it cuts the buffer at some point. Any idea?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Printf over UART at high rate</title><link>https://devzone.nordicsemi.com/thread/355095?ContentTypeID=1</link><pubDate>Fri, 25 Feb 2022 16:47:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d2be33f-cd26-49f7-90fe-64b66e486d77</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The library should be able to handle throughputs up to 1M baud if configured correctly, but this depends on buffer sizes and CPU availability in the application.&lt;/p&gt;
&lt;p&gt;Can you post the code you used to initialize and use the library?&lt;/p&gt;
&lt;p&gt;Are you only seeing issues with TX operations, or are you also having issues with RX operations?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Printf over UART at high rate</title><link>https://devzone.nordicsemi.com/thread/355028?ContentTypeID=1</link><pubDate>Fri, 25 Feb 2022 12:58:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6340b8a-3521-4e96-a7ae-4fcab28a75a1</guid><dc:creator>User1321</dc:creator><description>&lt;p&gt;Hi Jorgen, thank you for your reply.&lt;/p&gt;
&lt;p&gt;I used the library but still don&amp;#39;t get good uart transmissions.&lt;/p&gt;
&lt;p&gt;I changed the uart speed to 1Mbps and increased the timeout to 1ms to test if this could bring better results but no. &lt;br /&gt;I also constantly get the NRF_LIBUARTE_ASYNC_EVT_ERROR error.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using the nrf_libuarte_async_tx() fcn to transmit the messages.&lt;/p&gt;
&lt;p&gt;Is there something else that i need to change?&amp;nbsp; what&amp;#39;s the maximum Throughput that we can obtain with that library?&lt;/p&gt;
&lt;p&gt;Thanks in advance!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Printf over UART at high rate</title><link>https://devzone.nordicsemi.com/thread/354870?ContentTypeID=1</link><pubDate>Thu, 24 Feb 2022 16:14:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c78df44a-be41-4348-9cb7-db83fdb662d5</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;app_uart (which is used by printf with RETARGET_ENABLED) is not the best library to use if you need high throughput. app_uart will only send/receive a single byte at a time, meaning the CPU will be very busy handling all the interrupts from the UART(E) peripheral when sending/receiving much data. The app_uart library was originally written for nRF51, which did not have support for EasyDMA, meaning there was always a need to update the data pointer for each byte being transmitted/received anyways. App_uart also does not implement any timeouts, meaning you would see delays in receiving data chunks if larger buffers are used.&lt;/p&gt;
&lt;p&gt;I would rather recommend you to switch to using the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_libuarte.html"&gt;libUARTE library&lt;/a&gt;, which can handle larger buffers, automatic buffer swapping, and timeouts. I posted a modified version of ble_app_uart in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/71665/nrf-52832-uart-high-speed-communication/294686#294686"&gt;this ticket&lt;/a&gt;, which replaces app_uart with libUARTE.&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>