<?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>High Speed 1 MBaud Async UART with Zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116210/high-speed-1-mbaud-async-uart-with-zephyr</link><description>Hello everyone, 
 
 I am working with nrf connect sdk toolchain v2.6.1. 
 
 My project requirements are as follows: 
 
 1 MBaud UART Async API 
 Two Modes for UART RX
 
 fill buffer rx buffer with fix len 
 timeout after 200 &amp;#181;s after last byte received</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 17 Nov 2024 18:49:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116210/high-speed-1-mbaud-async-uart-with-zephyr" /><item><title>RE: High Speed 1 MBaud Async UART with Zephyr</title><link>https://devzone.nordicsemi.com/thread/510809?ContentTypeID=1</link><pubDate>Sun, 17 Nov 2024 18:49:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58aaad3a-844c-43ba-8be0-ecc78d4375fb</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="MarkusF"]This is unrelated to the actual UART topic but it would be great to find a list of KConfigs settings for each driver in the future.[/quote]
&lt;p&gt;unfortunately we are limited to either search in the menuconfig or if you know exactly which driver is in use then you can look into&amp;nbsp;modules/hal/nordic/drivers/ and its respective driver KConfig. But I understand what you are saying here,&amp;nbsp;my struggle is not just with the driver config but to find their dependencies.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Speed 1 MBaud Async UART with Zephyr</title><link>https://devzone.nordicsemi.com/thread/510699?ContentTypeID=1</link><pubDate>Fri, 15 Nov 2024 13:20:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cf036b3-40bb-4922-ad68-851e198bee06</guid><dc:creator>MarkusF</dc:creator><description>&lt;p&gt;Thank you for providing some guidance! I will take into account your suggestions.&lt;/p&gt;
&lt;p&gt;This is unrelated to the actual UART topic but it would be great to find a list of KConfigs settings for each driver in the future.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High Speed 1 MBaud Async UART with Zephyr</title><link>https://devzone.nordicsemi.com/thread/509860?ContentTypeID=1</link><pubDate>Mon, 11 Nov 2024 11:24:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c225e1c-b853-4ddf-8916-122824dd5dfa</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I normally do not have a good feeling about using that high baudrate on UART where the CPU has other tasks to do.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To answer your questions&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;Nordic doesn’t have a dedicated guide specifically for pushing the UART Async API to 1 MBaud on the nRF52840. The closest resources are the general UART documentation in Zephyr and Nordic’s guidance around high-throughput UART applications, but these mostly assume lower rates and may not cover high-baud scenarios thoroughly. Achieving reliable UART at 1 MBaud on Nordic devices is possible, though it may require some adjustments for the interrupt handling and DMA settings to handle data at this speed reliably. Developers typically rely on insights shared in forums and DevZone posts, though these tend to vary in accuracy and applicability as SDK versions evolve.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div dir="auto"&gt;
&lt;div&gt;
&lt;div&gt;
&lt;p&gt;For your second question, I agree that KConfig options for high-speed UART setups on Nordic devices can be frustratingly inconsistent, especially in the context of Zephyr configurations. The KConfig settings most relevant here would include CONFIG_UART_ASYNC_API, CONFIG_UART_0_ASYNC, CONFIG_UART_0_NRF_HW_ASYNC, and potentially CONFIG_UART_0_BAUDRATE for setting 1 MBaud directly. CONFIG_UART_0_NRF_FLOW_CONTROL can also be essential if you’re using hardware flow control. Settings like CONFIG_SERIAL_SUPPORT_INTERRUPT and CONFIG_UART_RX_TIMEOUT play a role in configuring the data-handling responsiveness and flow. That said, DevZone posts do become outdated, and Nordic’s nRF Connect SDK release notes are sometimes the only reliable way to confirm current, valid KConfig options.&lt;/p&gt;
&lt;p&gt;On whether to use the Zephyr UART API versus the Nordic nrfx driver at 1 MBaud, I generally leans towards recommending the Zephyr API, especially if you’re working within Zephyr’s async context. The Zephyr UART API aligns better with the broader system, making it more adaptable for projects with expanding features like BLE. However, for specific high-performance needs—particularly when you’re seeing throughput issues with the Async API—using nrfx directly can sometimes give more control over the hardware specifics (like DMA and interrupt prioritization). But, this does come at the cost of some portability and integration simplicity within Zephyr. Nordic generally suggests sticking with Zephyr’s API where possible, especially for maintainability&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Few things to keep in mind&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;With high-speed UART, even small delays in handling incoming data can lead to buffer overruns or missed bytes. When you add BLE later, the BLE and UART interrupts will compete, so you’ll need to carefully prioritize them. For now, ensure UART has high priority in handling interrupts.&lt;/li&gt;
&lt;li&gt;At 1 MBaud, it’s best to offload some of the work to the hardware. EasyDMA in Nordic’s chips allows for efficient data transfer without bogging down the CPU. This reduces software overhead by using hardware to manage the byte counting and buffer filling, which is critical at these speeds.&lt;/li&gt;
&lt;li&gt;High-speed communication works best with buffers big enough to handle the data burst and a properly set timeout that triggers processing right after data stops flowing. You’re aiming for a balance here—large enough to avoid overflows, but small enough to ensure timely data processing.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The changes to prj.conf can be something like below&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_UART_ASYNC_API=y               
CONFIG_UART_0_ASYNC=y                 
CONFIG_UART_0_NRF_HW_ASYNC=y          
CONFIG_UART_0_NRF_HW_ASYNC_TIMEOUT=200
CONFIG_UART_0_NRF_HW_ASYNC_RX_BUFFER_SIZE=256 
CONFIG_UART_LINE_CTRL=y               
CONFIG_SERIAL=y                        
CONFIG_SERIAL_SUPPORT_INTERRUPT=y      
CONFIG_UART_RX_TIMEOUT=1               
CONFIG_UART_0_BAUDRATE=1000000        
CONFIG_UART_0_NRF_FLOW_CONTROL=y      
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You need to make sure that you add hardware flow control to the uart instance, the example below shows adding hardware flow control to uart instance number 0&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;uart0 {
    ...
    ...  // other settings you have
    hw-flow-control;
};
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>