<?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>Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48167/serial-comm-stops-after-8-10h</link><description>I have developed a custom board with NRF52810 (Rigado), a standalone CAN controller (500 kbaud) and serial communication (57600 baud). 
 The SW is based on the BLE_APP_UART from SDK 15.3.0, SoftDevice S112, modified with SPI support. The custom board</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 08 Jun 2019 08:44:19 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48167/serial-comm-stops-after-8-10h" /><item><title>RE: Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/thread/191729?ContentTypeID=1</link><pubDate>Sat, 08 Jun 2019 08:44:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2e77947-9206-4ce9-8b3b-8dcff2ebce7d</guid><dc:creator>Skols</dc:creator><description>&lt;p&gt;Preliminary conclusion:&amp;nbsp;&lt;span&gt;Changed the uart_default_config_priority back to the default config (6). Have tested several runs now. The application runs approximately rock steady. Got 5 comm errors on ~9 million bytes.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It seems clear that the issues I experienced was due to the fact that the application was not able to handle the uart communication load at comm speed above 38kbaud. I realize there are many tickets regarding the uart communication and the need for EasyDMA, but, as I see it, there are no good solutions yet.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have considered the experimental solution (libuarte), but my gut feeling is that I am not sure that will solve my need for running at 115kbaud (have to use 9 ppi&amp;#39;s and one timer on the nr52810) with SoftDevice.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have concluded on that I will add the max3107 uart in my hw. The max3107 have spi, 256 byte fifo and the possibility to config to give interrupt on LF as well as on timeout since last byte received.&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/thread/191305?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2019 10:49:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5140ec8-7b40-4eb6-919a-8f2e988e69ba</guid><dc:creator>Skols</dc:creator><description>&lt;p&gt;I am in a learning phase wrt nrf52 and, as far as I can understand, the app_ble_uart, which is the base for my SW, does not use PPI-instances. I assume memory allocations issues related to PPI can be ruled out.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/thread/191194?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 19:39:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90703d33-1468-4dd2-9c84-6b309a516df1</guid><dc:creator>Skols</dc:creator><description>&lt;p&gt;Hmm.... I guess I should have added &amp;quot;not that I am aware of&amp;quot;. I understand I have to check my use of PPI instances. Thanks a lot.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/thread/191192?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 19:20:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27b56c66-0578-4d0d-b4cb-e7566b9f1e6d</guid><dc:creator>Skols</dc:creator><description>&lt;p&gt;Update: I experienced a lot of&amp;nbsp;&lt;span&gt;app_uart_communication_error. Hundreds pr minute. Reason: &amp;quot;start bit received while previous data still lies in RXD&amp;quot;.&lt;br /&gt;&lt;br /&gt;Changed the uart_default_config_priority from 6 to 2, the app_irq_priority in app_uart_fifo_init() from lowest to low. Vent from hundreds of app_uart_communication_error pr. min to ~1&amp;nbsp;app_uart_communication_error pr minute.&lt;br /&gt;&lt;br /&gt;Reconfigured the GPS to only send the two nmea sentences in use, and could then reduce the baudrate from 57600 to 38400.&amp;nbsp; Rock steady now with zero&amp;nbsp;app_uart_communication_error.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I understand the ble_app_uart correctly, the app_uart_fifo uses easy dma of one byte only. I had to use a baudrate of&amp;nbsp;57600&amp;nbsp;to receive all nmea sentences from the GPS within 100ms. That resulted in an interrupt each ~174us and almost 100% duty cycle. By reducing to 38400 and reconfigure the GPS I got a duty cycle of 40% and an interrupt each 260us.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I am not sure if these performance&amp;nbsp;issues was the reason why the serial comm stopped. Have to let it run for ~10 hours to see...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/thread/191137?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 13:39:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c888c05b-b77e-4b74-bf52-243c154bdc65</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;Alright awesome. I was unaware that I was, but realized initializing a PPI channel allocates memory behind the scenes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/thread/191130?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 13:22:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e76afc57-e0a1-4529-990b-fe25d7fd0cc1</guid><dc:creator>Skols</dc:creator><description>&lt;p&gt;Thanks for your response.&lt;br /&gt;&lt;br /&gt;UART config as in ble_app_uart using app_uart_fifo:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  static volatile ret_code_t err_code;
    app_uart_comm_params_t static comm_params =
    {
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
    };
      
    comm_params.baud_rate = useBaudRate; 
    APP_UART_FIFO_INIT(&amp;amp;comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
    APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;UART event handler:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void uart_event_handle(app_uart_evt_t * p_event)
{
//    static uint8_t data_array[BLE_NUS_MAX_DATA_LEN];  //BLE_NUS_MAX_DATA_LEN ~244 bytes
    static uint8_t data_array[128];
    static uint8_t index = 0;
    
    uint8_t  indexLastReceived = 0;
    uint8_t  status            = _EMPTY;
    
    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index])); //typecast to void
            indexLastReceived = index;  //save current received
            index++;                    //prepare next char
            if (index &amp;gt;= sizeof(data_array))
            {
              index=0;
            }

            if (data_array[indexLastReceived] == &amp;#39;\n&amp;#39;)  
            {
                 //NRF_LOG_DEBUG(&amp;quot;GPS data received&amp;quot;);
                 index = 0; //prepare next char
                 data_array[indexLastReceived] = &amp;#39;\0&amp;#39;; //replace \n with \0 to make NULL-terminated received msg
                 if (sd_mutex_acquire(&amp;amp;p_GPSmutex)==NRF_SUCCESS) //allocate struct
                 {
                    //Read GPS data
                    status = gps_location(&amp;amp;gpsDataReader, data_array); //decode GPS data and parse to the shared static struct gpsDataReader
                    if (status == NMEA_GPGGA)
                    {
                        gpsDataUpdated = true;
                        timeoutCounter = 0;
                    }
                    sd_mutex_release(&amp;amp;p_GPSmutex);
                 } //end mutex
            } //endif data_array[indexLastUsed]
            break;

        case APP_UART_COMMUNICATION_ERROR:
            //APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
            app_uart_flush();
            index = 0;  //=&amp;gt; skip all received chars
            serialCommErrCounter++;
            break;

        case APP_UART_FIFO_ERROR:
            //APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
            app_uart_flush();
            index = 0; //=&amp;gt; skip all received chars
            break;

        default:
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;At error events, I (temporarily) call app_uart_flush() instead of the app_error_handler(). When debugging (using ses) with brake point at the app_uart_communication_error, I get to many overruns. I guess it is because the debugger have problems keeping up. The GPS device is continuously pushing data to the serial port (no flow control)...&lt;br /&gt;&lt;br /&gt;Have not verified with a scope yet that the GPS device stops pushing data, but I doubt that.&lt;br /&gt;&lt;br /&gt;Remains to capture the UART(E) registers when the serial comm stops.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/thread/191086?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 11:55:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0cfb303a-9417-497d-8ae7-5adc7d22d33f</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Do you get any error codes in the application when the serial interface stops working? Are you using app_uart_fifo, like it is used in ble_app_uart, or do you use another library/driver for UART?&lt;/p&gt;
&lt;p&gt;Can you provide the state of the registers in the UART(E) peripheral when the device is in the error state? Have you checked the UART lines with a logic analyzer, before and after the issue occurs, to see if there are any changes to the communication between the device?&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><item><title>RE: Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/thread/190957?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 06:15:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54dc4d7b-c937-4fff-a446-50e2514f639c</guid><dc:creator>Skols</dc:creator><description>&lt;p&gt;Thanks for the response. No, I am not using any dynamic memory allocation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial comm stops after 8-10h.</title><link>https://devzone.nordicsemi.com/thread/190926?ContentTypeID=1</link><pubDate>Tue, 04 Jun 2019 22:57:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00e0445d-540e-4060-933e-6b35b4641660</guid><dc:creator>Noah</dc:creator><description>&lt;p&gt;Are you using any dynamic memory allocation? I&amp;#39;m also developing firmware for a custom board built with the nRF52810. I had an error where after sending 39 packets exactly (using UART), the data being transmitted would remain exactly the same (I.E. packets 0 - 39 had variance, packets 40 - n = packet 39). Realized I had been forgetting to free a PPI instance I allocate at regular intervals, essentially causing segfault or undefined memory overflow behavior. Fixed the bug and application now works fine for as long as I want it to be running.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>