<?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>Scheduler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68557/scheduler</link><description>Hello, 
 
 I receive a lot of data in my UART, like 256B non stop that I need to send it to a tablet through BLE. 
 I was thinking of using scheduler so I push the data and an event in the DATA_READY uart event and the main thread will process the pushed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Nov 2020 10:10:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68557/scheduler" /><item><title>RE: Scheduler</title><link>https://devzone.nordicsemi.com/thread/281999?ContentTypeID=1</link><pubDate>Thu, 26 Nov 2020 10:10:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e865d28a-4fca-43b1-8a34-a5e264075996</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you check what is returned by both&amp;nbsp;nrf_atfifo_alloc_put() and&amp;nbsp;&lt;span&gt;nrf_atfifo_get_free()?&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;Jared&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler</title><link>https://devzone.nordicsemi.com/thread/281546?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2020 12:41:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b21d2935-b584-45a8-8352-807a0eecf32b</guid><dc:creator>genzy9</dc:creator><description>&lt;p&gt;OK thank you, we will plan to migrate to this driver for next release.&lt;/p&gt;
&lt;p&gt;In the meantime could you help me with this issue:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In the uart handler, when I reaceive a buffer, I want to push it to a atfifo.&lt;/p&gt;
&lt;p&gt;A timer handler will get data from this fifo and will send it to the tablet. Here&amp;#39;s my current implementation:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;typedef struct{
    uint8_t au8_uart_to_ble_tx_buffer[UART_TX_BUF_SIZE]; 
}tStreamingData;

static tStreamingData gStreamingData = {0};

NRF_ATFIFO_DEF(sd_fifo, tStreamingData, 5);

static void uart_event_handle(app_uart_evt_t *p_event)
{
    static uint16_t index = 0;
    static uint8_t au8_rx_buffer[UART_RX_BUF_SIZE] = {0};            // Buffer reception for UART
    static size_t frameCounter = 0;
    uint8_t u8_rxbyte;
    
    switch (p_event-&amp;gt;evt_type)
    {
        case APP_UART_DATA_READY:
            UNUSED_VARIABLE(app_uart_get(&amp;amp;u8_rxbyte));    
            au8_rx_buffer[index] = u8_rxbyte;
            index++;
            if (u8_rxbyte == &amp;#39;\n&amp;#39;)
            {
                
                //check if stream header is present  
                if (index &amp;gt; 5 &amp;amp;&amp;amp; au8_rx_buffer[index-5] == 0x65 &amp;amp;&amp;amp; au8_rx_buffer[index-4] == 0x6E &amp;amp;&amp;amp; au8_rx_buffer[index-3] == 0x64 &amp;amp;&amp;amp; au8_rx_buffer[index-2] == 0x0A &amp;amp;&amp;amp; au8_rx_buffer[index-1] == 0x00)    //stream starts when end\n is encontered
                {
                    frameCounter++;
        
                    memcpy(gStreamingData.au8_uart_to_ble_tx_buffer , au8_rx_buffer, UART_TX_BUF_SIZE);
                    nrf_atfifo_alloc_put(sd_fifo, &amp;amp;gStreamingData, sizeof(tStreamingData), NULL);

                    index = 0;
                }

                if(index &amp;gt; UART_RX_BUF_SIZE)
                {
                    index = 0;
                }
            }
        break;
        case APP_UART_TX_EMPTY:
        break; 
        case APP_UART_FIFO_ERROR:
        break;
        case APP_UART_COMMUNICATION_ERROR:
        break;       
        default:
        break;
    }
}                   &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And in a timer handler I am just polling the fifo&amp;nbsp;&lt;/p&gt;
&lt;p&gt;tStreamingData localSd;&lt;/p&gt;
&lt;p&gt;nrf_atfifo_get_free(sd_fifo, &amp;amp;localSd, sizeof(tStreamingData), NULL);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But the fifo seems always empty.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I can not use logs since the code is embedded on a chip.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The atfifio has been definied globally using&amp;nbsp;NRF_ATFIFO_DEF(sd_fifo, tStreamingData, 5);&lt;/p&gt;
&lt;p&gt;and initialized in main using&amp;nbsp;NRF_ATFIFO_INIT(sd_fifo);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I know for sure the data in the uart handler is correct since I detect a packet header sent by another module so the data are not 0 it is jsut somehow I failed pushing/poping the fata from the fifo but I dont know why.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler</title><link>https://devzone.nordicsemi.com/thread/281435?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2020 06:38:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80b2c2a5-06d9-4322-aa47-81931b6b2c99</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In short, the libUARTE is a good driver to use for when you have to receive lots of data through UARTE. Features such as the usage of double buffering, events for synchronization, usage of PPI to connect events, and the option of hw flow control minimizes lost data.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler</title><link>https://devzone.nordicsemi.com/thread/281280?ContentTypeID=1</link><pubDate>Mon, 23 Nov 2020 10:18:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19a34b2e-867b-4c02-bc41-68dfcd18c467</guid><dc:creator>genzy9</dc:creator><description>&lt;p&gt;Hello Jared, thank you for your feedback.&lt;/p&gt;
&lt;p&gt;How libuarte could help?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Btw I just noticed UARTE and UART are enabled. So I will investigate which one is used.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Scheduler</title><link>https://devzone.nordicsemi.com/thread/281095?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2020 12:29:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28b57398-1d64-4510-a0d7-034fbf77086c</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]I am afraid that the fifo will be full pretty quick so maybe thats not the best design.[/quote]
&lt;p&gt;&amp;nbsp;Yes, this is also what I&amp;#39;m thinking. I think the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_libuarte.html?cp=7_1_3_28"&gt;LibUARTE library&lt;/a&gt;&amp;nbsp;would be better fit for your project. You find the example described&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/libuarte_example.html?cp=7_1_4_6_17"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>