<?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>uart async api notifys fewer bytes than it has received.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/90964/uart-async-api-notifys-fewer-bytes-than-it-has-received</link><description>I use CONFIG_UART_ASYNC_API feature of NCS v2.0 with nRF52840DK, but when UART_RX_RDY event triggered, evt-&amp;gt;data.rx.len is smaller than the number of bytes it has received. I use dslogic tool to analysis uart signal, and print out evt-&amp;gt;data.rx.len+2 bytes</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 Jun 2024 14:56:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/90964/uart-async-api-notifys-fewer-bytes-than-it-has-received" /><item><title>RE: uart async api notifys fewer bytes than it has received.</title><link>https://devzone.nordicsemi.com/thread/487153?ContentTypeID=1</link><pubDate>Mon, 03 Jun 2024 14:56:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f19c68c9-968c-43bf-a846-23a548a94d9f</guid><dc:creator>lanwer</dc:creator><description>&lt;p&gt;In that case, I would&amp;nbsp;recommend using the UART Async Api with hardware counting feature enabled: it basically uses&amp;nbsp;a hardware timer in counter mode to count received bytes. I had also a similar issue, and with the configs below, everything started working as a charm. &lt;br /&gt;&lt;br /&gt;This feature is&amp;nbsp;necessary for the reliability. To activate, set the following configs &lt;span&gt;(adjust for the correct instances):&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_UART_0_NRF_HW_ASYNC_TIMER=2
CONFIG_UART_0_NRF_HW_ASYNC=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;See my ticket here for more info:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/110657/modbus-missing-rx-bytes-at-high-baud-rate-460800"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/110657/modbus-missing-rx-bytes-at-high-baud-rate-460800&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Another related ticket:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/85128/uart-wrong-offset-after-buffer-overflow"&gt;Link&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart async api notifys fewer bytes than it has received.</title><link>https://devzone.nordicsemi.com/thread/417607?ContentTypeID=1</link><pubDate>Mon, 27 Mar 2023 09:02:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1eb751d-3a89-4eda-9907-2c4f36a6dbb4</guid><dc:creator>C.Thilo</dc:creator><description>&lt;p&gt;One thing I just found out is, when I possibly received not enough bytes, disabling Uart triggers RX Ready with the missing bytes.&lt;br /&gt;This works as workaround with a uart enable in the uart callback UART_DISABLED part. So uart is directly reenabled when disabling it, caused by missing bytes.&lt;/p&gt;
&lt;p&gt;Hope this helps!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart async api notifys fewer bytes than it has received.</title><link>https://devzone.nordicsemi.com/thread/417597?ContentTypeID=1</link><pubDate>Mon, 27 Mar 2023 08:13:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e60e5763-57cb-439b-b91b-40eb6c09aaef</guid><dc:creator>C.Thilo</dc:creator><description>&lt;p&gt;Hi srocky&lt;/p&gt;
&lt;p&gt;Could you solve your problem anyhow?&lt;br /&gt;We experience exactly the same problem. At some point, RX Ready reports just 1 Byte but there are 6 or so received. At least is the signal on the wire corretly. And when there is more received, the missing bytes will be received.&lt;br /&gt;&lt;br /&gt;But the count of bytes later received needs always to be received with other data.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Our uart callback is very slim, so should not be a problem :(....&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Thilo&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart async api notifys fewer bytes than it has received.</title><link>https://devzone.nordicsemi.com/thread/381810?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2022 13:50:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dec33d15-b339-4272-bccf-e30454bc11a3</guid><dc:creator>Pedro</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi srocky,&lt;/span&gt;&lt;/p&gt;
[quote userid="118572" url="~/f/nordic-q-a/90964/uart-async-api-notifys-fewer-bytes-than-it-has-received/381777"]If the reason is I do too&amp;nbsp;many&amp;nbsp;operations in the interrupt handler, what expects to happen is that data would get lost when flow control not used?[/quote]
&lt;p&gt;&lt;span&gt;When using a&lt;/span&gt;&lt;span&gt;sync UART API, data is transferred through DMA, so no data would be lost, but counters of number of received bytes of&amp;nbsp;API can be affected.&lt;/span&gt;&lt;/p&gt;
[quote userid="118572" url="~/f/nordic-q-a/90964/uart-async-api-notifys-fewer-bytes-than-it-has-received/381777"]In my case data is still there, but delayed.[/quote]
&lt;p&gt;&lt;span&gt;Same happened to me. Data was in buffer but API showed less bytes that in fact received. It was in the next data ready event when the delayed data was revealed.&lt;/span&gt;&lt;/p&gt;
[quote userid="118572" url="~/f/nordic-q-a/90964/uart-async-api-notifys-fewer-bytes-than-it-has-received/381777"]And one more thing, this also happened when there was not too much data,&amp;nbsp;&amp;nbsp;I sent data by clicking button, 45 bytes a time.[/quote]
&lt;p&gt;&lt;span&gt;For me it was depending on the size of the assigned buffer. Have you tried to increase buffer size?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Be careful to do not assign a buffer size greater than 2^(RXD.MAXCNT number of bits), because there is no software check and the value is just assigned to the register. For me (nRF52832) was 8 bits, so when I defined 256 as buffer size, that is -&amp;gt; 0b1 0000 0100, the value written to&amp;nbsp;RXD.MAXCNT (buffer size) was in fact 0b0000 0100 (4 bytes buffer).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I hope you find the solution soon!&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Pedro.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart async api notifys fewer bytes than it has received.</title><link>https://devzone.nordicsemi.com/thread/381777?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2022 12:28:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0bf1259-5383-4558-8bb3-e4912d6efba7</guid><dc:creator>srocky</dc:creator><description>&lt;p&gt;Hi Pedro,&lt;/p&gt;
&lt;p&gt;Thanks for your&amp;nbsp;solution, I may try this later. But I think there must be something wrong in lower level logic. I tried three&amp;nbsp;types of uart API before I found what happened, I thought it must be my fault because UART&amp;nbsp;is a quite common tech, and nordic has sold quite a lot of chips and NCS has released many versions. But I got the same results in all three ways. In two other ways I&amp;nbsp;could/did not&amp;nbsp;test internal buffer and just&amp;nbsp;could not get enough data.&lt;/p&gt;
&lt;p&gt;If the reason is I do too&amp;nbsp;many&amp;nbsp;operations in the interrupt handler, what expects to happen is that data would get lost when flow control not used? In my case data is still there, but delayed. And one more thing, this also happened when there was not too much data,&amp;nbsp;&amp;nbsp;I sent data by clicking button, 45 bytes a time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart async api notifys fewer bytes than it has received.</title><link>https://devzone.nordicsemi.com/thread/381714?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2022 08:57:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a4e4d54-e909-4544-bbcd-71cbe00990ce</guid><dc:creator>Pedro</dc:creator><description>&lt;p&gt;Hi srocky,&lt;/p&gt;
&lt;p&gt;I had a similar problem and solved it reducing to minimum operations done in the uart callback. Notice that this is an interrupt handler and must be careful with operations done inside.&lt;/p&gt;
&lt;p&gt;I removed all&amp;nbsp;LOG_ and malloc functions and worked. Try removing&amp;nbsp;ilog and&amp;nbsp;hex_dump2 calls. You can copy data to a buffer and then print it outside the interrupt handler.&lt;/p&gt;
&lt;p&gt;Hope it works!&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Pedro.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart async api notifys fewer bytes than it has received.</title><link>https://devzone.nordicsemi.com/thread/381652?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2022 02:56:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82e6d6c3-be38-490a-9a02-ecd65ceedbf8</guid><dc:creator>srocky</dc:creator><description>&lt;p&gt;Thank you for your reply:) I tried your sample and was able to reproduce:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1660615753014v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;It was OK&amp;nbsp;for the&amp;nbsp;first few times, and then the last char &amp;#39;9&amp;#39; was delayed until next data arrival, from then on, the last byte was delayed for many times. And then this may be corrected:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1660618368681v3.png" /&gt;&lt;/p&gt;
&lt;p&gt;Or things may become worse:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1660618586030v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: uart async api notifys fewer bytes than it has received.</title><link>https://devzone.nordicsemi.com/thread/381644?ContentTypeID=1</link><pubDate>Mon, 15 Aug 2022 23:43:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d7c73ea-e291-4103-8480-1fa52caecfe5</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2844.uart_5F00_async.zip"&gt;devzone.nordicsemi.com/.../2844.uart_5F00_async.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not able to reproduce this. Could you test the sample above and see if you&amp;#39;re able to reproduce the issue?&lt;/p&gt;
&lt;p&gt;I used the attached sample with NCS v2.0.0 and nRF52840 DK.&lt;/p&gt;
&lt;p&gt;You can test the sample by open a serial terminal and send commands (uart0 is used for async uart). Then you can open an RTT viewer (RTT logging is enabled) to see how many bytes were received (length of &lt;span&gt;evt-&amp;gt;data.rx.len is printed&lt;/span&gt;).&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simojn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>