<?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 stalling on central based on NUS example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51425/uart-stalling-on-central-based-on-nus-example</link><description>Hi, 
 I am creating a central device with some similar services and code as the NUS example in the SDK. I posted with an issue here I was having earlier but I am writing this as a followup question. Basically, in my function that takes the data sent from</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 02 Sep 2019 08:44:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51425/uart-stalling-on-central-based-on-nus-example" /><item><title>RE: UART stalling on central based on NUS example</title><link>https://devzone.nordicsemi.com/thread/207308?ContentTypeID=1</link><pubDate>Mon, 02 Sep 2019 08:44:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5df8bd4-1ae0-474f-9eba-56395ec11de1</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Michael&lt;/p&gt;
&lt;p&gt;The code you sent looks fine, yes. Assuming the while loop ends the external HF clock should be running continuously.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Maybe you could try to send an empty &amp;#39;sync byte&amp;#39; of sorts at the start of every sample?&lt;/p&gt;
&lt;p&gt;You should have enough UART throughput for it if you are sending 20000 bytes of data pr second, and it should make it easier to spot what is happening.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART stalling on central based on NUS example</title><link>https://devzone.nordicsemi.com/thread/207222?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2019 23:32:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ba8c8d2-d3e5-4972-ada9-b5563946c7dc</guid><dc:creator>michael1</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="2116" url="~/f/nordic-q-a/51425/uart-stalling-on-central-based-on-nus-example/206756"]I assume a single lost byte would lead to the byte order being flipped, since the only thing you are sending over the UART is the 16-bit ADC samples?[/quote]
&lt;p&gt;This is correct even a single byte loss would flip the order since I am just sending 16bit ADC values that I get from the peripheral.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int main(void)
{
    ret_code_t       err_code;
    log_init();
    timer_init();
    leds_init();
    uart_init();
    power_management_init();
    ble_stack_init();
    gatt_init();
    db_discovery_init();
    ble_emg_service_init();

    err_code = sd_clock_hfclk_request();
    APP_ERROR_CHECK(err_code);
    uint32_t p_is_running = 0;
    while (!p_is_running)
    {
        sd_clock_hfclk_is_running(&amp;amp;p_is_running);
    }

    NRF_LOG_INFO(&amp;quot;BLE EMG.&amp;quot;);

    scan_start();

    bsp_board_led_on(CENTRAL_SCANNING_LED);

    for (;;)
    {
        idle_state_handle();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I tried requesting the HF clock and I didn&amp;#39;t see much of a difference (data still flipping). Can you take a look at this portion to see if I am requesting in the correct way that you were referring to?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Michael&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART stalling on central based on NUS example</title><link>https://devzone.nordicsemi.com/thread/206756?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2019 06:45:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7df8d09-9f6d-46fd-8fb5-a63ad4086992</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Michael&lt;/p&gt;
&lt;p&gt;One tip when using UART is to request the external HF clock at all times, to ensure that the baudrate is as accurate as possible. You could try to set your terminal to the actual baudrate as well, but this shouldn&amp;#39;t really be necessary as the deviation from the intended baudrate is very small (using the internal HF clock by comparison can lead to drift of 5% or more).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I assume a single lost byte would lead to the byte order being flipped, since the only thing you are sending over the UART is the 16-bit ADC samples?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART stalling on central based on NUS example</title><link>https://devzone.nordicsemi.com/thread/206715?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2019 17:52:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16d0cc0b-b615-47e1-8457-bf74039e62c5</guid><dc:creator>michael1</dc:creator><description>&lt;p&gt;I&amp;#39;m currently using a baud rate of&amp;nbsp;230400. I just tried upping the baud rate to 460800. When I increased baudrate, it seemed to stop stalling but there seems to be some sort of data loss or data corruption due to switching of the&amp;nbsp;byte order of data. I pasted an example I copied where this occurs below showing what should be the byte order at the start and then it flips. All of the values should be less than 2048 because they are values from the ADC.&lt;/p&gt;
&lt;p&gt;I noticed in the defines for the baudrate it gives an actual baudrate next to it. Should I be using this baudrate on my terminal program?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define UART_BAUDRATE_BAUDRATE_Baud460800 (0x075F7000UL) /*!&amp;lt; 460800 baud (actual rate: 470588) */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;. . .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;b&amp;#39;\xf0\xff&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-16&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;b&amp;#39;\xf0\xff&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-16&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;b&amp;#39;\xff\xf2&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-3329&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;b&amp;#39;\xff\xf2&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-3329&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;b&amp;#39;\xff\xf4&amp;#39;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-2817&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;. . .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART stalling on central based on NUS example</title><link>https://devzone.nordicsemi.com/thread/206327?ContentTypeID=1</link><pubDate>Tue, 27 Aug 2019 10:57:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09566748-c441-4bf3-af6a-72d9265bc00f</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Michael&lt;/p&gt;
&lt;p&gt;What is the baudrate of your UART?&lt;/p&gt;
&lt;p&gt;Have you scoped the UART lines to see if the data is being output on the UART as expected?&lt;/p&gt;
&lt;p&gt;It should be possible for the client on the central side to disable notification on the NUS service once the buffers reach a certain point, which would hold back the data updates from the peripheral side. Then you can re-enable the services again once the UART buffers clear to allow the peripheral to send more data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>