<?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 priority</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17355/uart-priority</link><description>Hello,
I am facing many communication error with code 1 when using the UART.
Everything is working fine until my client reads long characteristics (in my case it is about 110 bytes long) from the server.
The read is fine on the Soft device side but</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Nov 2016 12:02:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17355/uart-priority" /><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66716?ContentTypeID=1</link><pubDate>Tue, 01 Nov 2016 12:02:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:666ec5e8-8cf1-431b-a22c-2548a1a37cec</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Great that you found a workaround. I agree. This was actually fixed in the SDK 12.0.0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66715?ContentTypeID=1</link><pubDate>Mon, 31 Oct 2016 15:26:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8340251e-3497-4697-ae4d-3bcfcdb54c2c</guid><dc:creator>jfDEVmoto</dc:creator><description>&lt;p&gt;I finally tested the higher UART priority and I got rid of those com errors.&lt;/p&gt;
&lt;p&gt;So of course, I have to change my application architecture to send my notifs out of my uart handler, which may include some latency in my system but this might not be highly critical to manage.
I am not using any SDK scheduler so maybe I will take this into consideration.&lt;/p&gt;
&lt;p&gt;If I may, in the file app_util_platform.h, the IRQ levels definitions are quite confusing&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#ifdef SOFTDEVICE_PRESENT
    APP_IRQ_PRIORITY_HIGHEST = _PRIO_SD_HIGH,
#else
    APP_IRQ_PRIORITY_HIGHEST = _PRIO_APP_HIGH,
#endif
    APP_IRQ_PRIORITY_HIGH    = _PRIO_APP_HIGH,
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;one may think that when soft device is present, the highest prio level to be used without damage would be _PRIO_SD_HIGH and _PRIO_APP_HIGH when no sot device is present. Looking t the values, shows that this is not the case. If no soft device is present, the priority level 0 would then never be used. why ?
Correct me if I am wrong, but here, HIGHEST must not be used at all when SD is present. Which is quite confusing.
I understand there might be good reasons for this and collaterals would not allow to change it easily, but my logic would have written those defs as follows. Don&amp;#39;t you agree ?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#ifdef SOFTDEVICE_PRESENT
    APP_IRQ_PRIORITY_HIGHEST = _PRIO_APP_HIGH, 
#else
    APP_IRQ_PRIORITY_HIGHEST = _PRIO_SD_HIGH, 
#endif
    APP_IRQ_PRIORITY_HIGH    = _PRIO_APP_HIGH,
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Whatever, thanks a lot for the support.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66718?ContentTypeID=1</link><pubDate>Mon, 31 Oct 2016 12:46:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80e9becc-06c6-40b0-8899-279acaafb42c</guid><dc:creator>jfDEVmoto</dc:creator><description>&lt;p&gt;OK, thanks, this is what I suspected.
Then If I want to test UART with higherpriority I will have to review some stuff in my architecture. Do you think it is worth ? would I then get rid of my uart errors ? can you confirm the performance gap comes from SD long reads ?
By the way, the issue might not be baudrate related but time between bytes related, so I suspect it to be different between device PC based emulator and real device...not tested yet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66717?ContentTypeID=1</link><pubDate>Mon, 31 Oct 2016 11:36:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:407c80aa-31d8-4447-8647-92652ed51baf</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;You cannot call sd_* functions from interrupt context 1. See &lt;a href="https://devzone.nordicsemi.com/question/22198/is-it-ok-to-call-sd_nvic_enableirq-in-an-interrupt-handler/"&gt;this&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66714?ContentTypeID=1</link><pubDate>Sun, 30 Oct 2016 15:45:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1b937bb-9f94-4674-a435-1af7b84fe88a</guid><dc:creator>jfDEVmoto</dc:creator><description>&lt;p&gt;about the Uart priority, I can check that when using _PRIO_APP_HIGH, then the function sd_ble_gatts_hvx would never return. I call this function from my UART receive handler, usually when the last expected byte was received and no other transfert is ongoing.
I will try to send my notifications from another handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66713?ContentTypeID=1</link><pubDate>Sat, 29 Oct 2016 19:05:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6279f91-b125-4e39-b057-464229824d40</guid><dc:creator>jfDEVmoto</dc:creator><description>&lt;p&gt;I will check deeper the priority thing, thanks for the link.
I have no control over the other device and baudrate choice. I can afford loosing data as far as my state machine flags it, but of course, this may affect my overall system performance.
However, I have not flagged in my handler that I do some bytewise treatment, not much heavy but  with a few function jumps to my state machine. I have to check whether this is a problem or not while this handler has low priority regarding soft device. On the SD side, I also have some memcopies to the characteristic, and maybe the lack of performance comes from here rather than on the long read.
In any case, if I can overcome this issue, and when I have checked that my code path are not too heavy, this is not a good sign for the performance of my system that should support more traffic in the future.
I must say I also have TWI, with another device, so I am afraid I will get such problems as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66712?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2016 12:46:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65958d8c-de4c-427b-ae15-ca003dedaae0</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;I think you have understood the error code correctly. You cannot use _PRIO_SD_HIGH (0), but _PRIO_APP_HIGH (1) might work, it crashes? Or do you get a reset? See &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;this&lt;/a&gt; for more info. Can you decrease the baud rate? Do you have any control over the device on the other side of the UART? Or is is just sending data whenever? Is it critical not to loose any data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66711?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 11:45:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:574a80cd-1518-42a2-9e90-9c26d4e9fc61</guid><dc:creator>jfDEVmoto</dc:creator><description>&lt;p&gt;more precisely , if I use priority highest, the application would hiccup upon startup. If I use high, it would crash after a few exchanges (don&amp;#39;t know where exactly, I am not good for embedded code debugging, strugglin with RTT...)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66710?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 10:45:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70cf8c61-8aef-4f6d-bf28-242452d4b061</guid><dc:creator>jfDEVmoto</dc:creator><description>&lt;p&gt;I get com error on the NRF51 side in the uat receive handler : (here is a simplified version)
I am not using flow control because my UART device does not support it.
When I use a higher interrupt, my application simply won&amp;#39;t start.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void uart_event_handle(app_uart_evt_t * p_event)
{
        switch (p_event-&amp;gt;evt_type)
      {
        case APP_UART_DATA_READY:
            //the normal byte receive path
               break;
case APP_UART_COMMUNICATION_ERROR:
            //evt_type 2 /**&amp;lt; An communication error has occured during reception. The error is 
            //stored     in app_uart_evt_t.data.error_communication field. */
            
            LOG_UART_COM_ERROR(p_event-&amp;gt;data.error_communication);
            
            //mostly log code 1
            //the error_communication code 1 seems to be due to slow byte flush , they mostly occur 
           //when serving long reads on BLE);      
            break;
        case APP_UART_TX_EMPTY:
            //evt_type 3    /**&amp;lt; An event indicating that UART has completed transmission of all 
           //available    data in the TX FIFO.
break;
default:
break;
}
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66709?ContentTypeID=1</link><pubDate>Thu, 27 Oct 2016 08:54:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f60232b1-3939-44c5-bcbf-41dca6bea0c9</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;Where do you get the error? On the nRF51? From what function? So you have a peripheral with a server, you are sending 102 bytes frames over UART to it, this normally works, but not when the central/client does a long read on it? Are you using flow control? What happens when you use higher interrupt priority?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART priority</title><link>https://devzone.nordicsemi.com/thread/66708?ContentTypeID=1</link><pubDate>Wed, 26 Oct 2016 17:16:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6693e51-3d95-4bc7-a560-27a7334812e3</guid><dc:creator>jfDEVmoto</dc:creator><description>&lt;p&gt;It seems that SDK 11 contains the bug explained herein as a response to another issue.
This may explain the two APP_UART_TX_EMPTY ?
Was this bug confirmed ?
&lt;a href="https://devzone.nordicsemi.com/question/80986/sending-uart/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I tested the fix and as a matter of fact the second notif is no more received. I will test further whether overall stability is improved or not,
but for sure I still do have priority issues with COM error 1 when serving long reads on BLE side.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>