<?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 RX, App UART Fifo Not Calling  Event Handler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58971/uart-rx-app-uart-fifo-not-calling-event-handler</link><description>Dear All, 
 I am using the example UART in Peripherals 
 I can send data easily but have problem in receiving data. When I try to receive data the UART Fifo Event handler is never called... I tried many things but it seems nothing is working..Looking</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 13 Mar 2020 16:02:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58971/uart-rx-app-uart-fifo-not-calling-event-handler" /><item><title>RE: UART RX, App UART Fifo Not Calling  Event Handler</title><link>https://devzone.nordicsemi.com/thread/239783?ContentTypeID=1</link><pubDate>Fri, 13 Mar 2020 16:02:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be1bd9c5-53f2-41ed-80d6-70098ea2933c</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What buffer size do you have? If you small buffers and no hw flow control the application won&amp;#39;t be able to empty the buffers, as the BLE protocol will have higher priority tasks. please consider using hw flow control if possible.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART RX, App UART Fifo Not Calling  Event Handler</title><link>https://devzone.nordicsemi.com/thread/239408?ContentTypeID=1</link><pubDate>Wed, 11 Mar 2020 18:33:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8ffa4fe-7154-4217-aaf0-332a1c92019d</guid><dc:creator>Nadeem</dc:creator><description>&lt;p&gt;The update on this is. Now i got to work but when i implement the same thing on the ble appp blinky example..i keep getting overrun errorwhen i send data too it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The baud rate is same on both sides&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART RX, App UART Fifo Not Calling  Event Handler</title><link>https://devzone.nordicsemi.com/thread/239304?ContentTypeID=1</link><pubDate>Wed, 11 Mar 2020 10:47:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4668623-bb6d-46a9-9e7e-2c71c4033e05</guid><dc:creator>Nadeem</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**
 * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
/** @file
 * @defgroup uart_example_main main.c
 * @{
 * @ingroup uart_example
 * @brief UART Example Application main file.
 *
 * This file contains the source code for a sample application using UART.
 *
 */

#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;quot;app_uart.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;SEGGER_RTT_Conf.h&amp;quot;
#if defined (UART_PRESENT)
#include &amp;quot;nrf_uart.h&amp;quot;
#endif
#if defined (UARTE_PRESENT)
#include &amp;quot;nrf_uarte.h&amp;quot;
#endif


#define ENABLE_LOOPBACK_TEST  /**&amp;lt; if defined, then this example will be a loopback test, which means that TX should be connected to RX to get data loopback. */

#define MAX_TEST_DATA_BYTES     (30U)                /**&amp;lt; max number of test bytes to be used for tx and rx. */
#define UART_TX_BUF_SIZE 256                         /**&amp;lt; UART TX buffer size. */
#define UART_RX_BUF_SIZE 256                         /**&amp;lt; UART RX buffer size. */


/**@brief Function for initializing logging. */
static void log_init(void)
{
    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}


void uart_error_handle(app_uart_evt_t * p_event)
{
   ret_code_t err_code;
   static uint8_t data_array[256];
	static uint8_t index = 0;
    if (p_event-&amp;gt;evt_type == APP_UART_COMMUNICATION_ERROR)
    {
         NRF_LOG_ERROR(&amp;quot;Communication error occurred while handling UART: %08X&amp;quot;, p_event-&amp;gt;data.error_communication );
            if( p_event-&amp;gt;data.error_communication &amp;amp; UART_ERRORSRC_BREAK_Msk )
            {
                NRF_LOG_ERROR(&amp;quot;   Break&amp;quot;);
            }
            if( p_event-&amp;gt;data.error_communication &amp;amp; UART_ERRORSRC_FRAMING_Msk )
            {
                NRF_LOG_ERROR(&amp;quot;   Framing&amp;quot;);
            }
            if( p_event-&amp;gt;data.error_communication &amp;amp; UART_ERRORSRC_PARITY_Msk )
            {
                NRF_LOG_ERROR(&amp;quot;   Parity&amp;quot;);
            }
            if( p_event-&amp;gt;data.error_communication &amp;amp; UART_ERRORSRC_OVERRUN_Msk )
            {
                NRF_LOG_ERROR(&amp;quot;   Overrun&amp;quot;);
            }
        APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
    }
    else if (p_event-&amp;gt;evt_type == APP_UART_FIFO_ERROR)
    {
        APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
    }
     else if (p_event-&amp;gt;evt_type == APP_UART_DATA_READY)
    {
      nrf_gpio_pin_set(16);
       UNUSED_VARIABLE(app_uart_get(&amp;amp;data_array[index]));
			index++;
      nrf_gpio_pin_clear(16);
			
   
    }
}


#ifdef ENABLE_LOOPBACK_TEST
/* Use flow control in loopback test. */
#define UART_HWFC APP_UART_FLOW_CONTROL_ENABLED

/** @brief Function for setting the @ref ERROR_PIN high, and then enter an infinite loop.
 */
static void show_error(void)
{

    bsp_board_leds_on();
    while (true)
    {
        // Do nothing.
    }
}


/** @brief Function for testing UART loop back.
 *  @details Transmitts one character at a time to check if the data received from the loopback is same as the transmitted data.
 *  @note  @ref TX_PIN_NUMBER must be connected to @ref RX_PIN_NUMBER)
 */
static void uart_send()
{
    uint8_t * tx_data = (uint8_t *)(&amp;quot;Abcdefghijklmnopqrstuvw&amp;quot;);
 
     nrf_gpio_pin_set(19);
     nrf_delay_ms(100);
 
    // Start sending one byte and see if you get the same
    for (uint32_t i = 0; i &amp;lt; MAX_TEST_DATA_BYTES; i++)
    {
        
        uint32_t err_code;
         
        while (app_uart_put(tx_data[i]) != NRF_SUCCESS);
        nrf_delay_ms(10);

    }
       nrf_gpio_pin_clear(19);
       nrf_delay_ms(50);
    return;
}


 
#else
/* When UART is used for communication with the host do not use flow control.*/
#define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED
#endif


/**
 * @brief Function for main application entry.
 */
int main(void)
{
    uint32_t err_code;

//    bsp_board_init(BSP_INIT_LEDS);
    log_init();
       NRF_LOG_INFO(&amp;quot;Uart Sample&amp;quot;); 
       nrf_delay_ms(1000);
        nrf_gpio_pin_clear(19);
       
    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
           APP_UART_FLOW_CONTROL_DISABLED,
          false,
#if defined (UART_PRESENT)
          NRF_UART_BAUDRATE_19200
#else
          NRF_UARTE_BAUDRATE_115200
#endif
      };

    APP_UART_FIFO_INIT(&amp;amp;comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);

    APP_ERROR_CHECK(err_code);
   nrf_gpio_cfg_output(19);
  //  nrf_gpio_cfg_output(16);
 //  nrf_gpio_cfg_input(4,NRF_GPIO_PIN_PULLDOWN);
 //  nrf_gpio_pin_clear(19);
#ifndef ENABLE_LOOPBACK_TEST
  printf(&amp;quot;A&amp;quot;);

    while (true)
    {
        uint8_t cr;
        while (app_uart_get(&amp;amp;cr) != NRF_SUCCESS);
        while (app_uart_put(cr) != NRF_SUCCESS);
        nrf_delay_ms(500);
          
        if (cr == &amp;#39;q&amp;#39; || cr == &amp;#39;Q&amp;#39;)
        {
            printf(&amp;quot; \r\nExit!\r\n&amp;quot;);

            while (true)
            {
                // Do nothing.
            }
        }
    }
#else
 
    // This part of the example is just for testing the loopback .
    while (true)
    {
        
    
        //nrf_delay_ms(500);
    }
#endif
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>