This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART DATA_READY events missing

I'm developing nFR52832 to communicate with the PC via UART. commands are sent to the nRF and for each command nRF responds with some data back to the PC via UART.

The UART event handler looks like below,

void uart_error_handle(app_uart_evt_t * p_event)
{

		if (p_event->evt_type == APP_UART_DATA_READY)
    {
				
				while (app_uart_get(&cr) != NRF_SUCCESS)
				{}

					if (cr == '\r')
					{
						local_buff_length = buff_idx;
						cmd = local_buff[0];
						UART_IN_FLAG = true;
						
						buff_idx = 0; //reset buff_idx for next UART packet

					}
				
					else
					{
						local_buff[buff_idx] = cr;
						buff_idx++;
						
					}    	
	
    }
		
		else if (p_event->evt_type == APP_UART_FIFO_ERROR)
    {
			//do nothing
			
		}
		
		else if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
    {
			//do nothing
			
		}
		
		else if (p_event->evt_type == APP_UART_TX_EMPTY)
    {
			//do nothing	
		}

}

but sometimes the APP_UART_DATA_READY events are missing. since i'm transmitting some data back to PC via UART, can APP_UART_TX_EMPTY event and the next APP_UART_DATA_READY event interfere with each other ? when i debug, the handler goes to the APP_UART_TX_EMPTY event instead of the APP_UART_DATA_READY event when a command is sent from PC to nRF.

Parents
  • Hi,

    The RX and TX UART are running of different clocks (asynchronous), so if you are running full speed for a period of time, it may be that one overrun the buffer (equal missing bytes). Are you using hardware flow control here? If you are only receiving bytes (disable TX) do you see the same? Do you have other interrupts occurring here (e.g. BLE link) that may prevent handling of bytes for a period of time? Is it the same if you start the HFCLK and/or reduce baudrate? You are not writing which SDK you are using and if you have enabled EasyDMA.

    Best regards,
    Kenneth

Reply
  • Hi,

    The RX and TX UART are running of different clocks (asynchronous), so if you are running full speed for a period of time, it may be that one overrun the buffer (equal missing bytes). Are you using hardware flow control here? If you are only receiving bytes (disable TX) do you see the same? Do you have other interrupts occurring here (e.g. BLE link) that may prevent handling of bytes for a period of time? Is it the same if you start the HFCLK and/or reduce baudrate? You are not writing which SDK you are using and if you have enabled EasyDMA.

    Best regards,
    Kenneth

Children
Related