nRF52811 UART FIFO Communication Error

Hi,

I'm running a custom nRF52811 rev1 connected to a Quectel BC660K. I'm getting this error on RTT:

00> <info> app_timer: RTC: initialized.
00> 
00> <info> uart: Sending AT
00> 
00> <error> app: ERROR 4 [NRF_ERROR_NO_MEM] at src/bc660.c:124
00> 
00> PC at: 0x00019A4B
00> 
00> <error> app: End of error report

Here's the initialization:

#include "app_uart.h"
#include "app_error.h"
#include "custom_board.h"
#include "nrf_delay.h"
#include "system/timer.h"

APP_TIMER_DEF(RESPONSE_TIMER);

#define NRF_LOG_MODULE_NAME uart
#include "nrf_log.h"
NRF_LOG_MODULE_REGISTER();

#if defined (UART_PRESENT)
#include "nrf_uart.h"
#endif
#if defined (UARTE_PRESENT)
#include "nrf_uarte.h"
#endif
#define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED
#define UART_COMMAND_BUFFER_SIZE     (48U)                /**< max number of test bytes to be used for tx and rx. */
#define UART_TX_BUF_SIZE 256                         /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 256                         /**< UART RX buffer size. */

#define ENTER_KEY 0xA
#define CARRIAGE_RETURN_KEY 0xD

bool init_bc660()
{
	uint32_t err_code;
	
	const app_uart_comm_params_t comm_params =
	{
		MAIN_RX_PIN,
		MAIN_TX_PIN,
		NRF_UART_PSEL_DISCONNECTED,
		NRF_UART_PSEL_DISCONNECTED,
		UART_HWFC,
		false,
#if defined (UART_PRESENT)
		NRF_UART_BAUDRATE_115200
#else
		NRF_UARTE_BAUDRATE_115200
#endif
	};
	
	APP_UART_FIFO_INIT(&comm_params,
		UART_RX_BUF_SIZE,
		UART_TX_BUF_SIZE,
		uart_event_handle,
		APP_IRQ_PRIORITY_LOWEST,
		err_code);
	
	if (err_code != NRF_SUCCESS) APP_ERROR_HANDLER(err_code);
	
	app_timer_create(&RESPONSE_TIMER, APP_TIMER_MODE_SINGLE_SHOT, uart_timeout_handler);
	
	if(send_init_commands() != NRF_SUCCESS) return false;
	
	return true;
}

And the uart event handler:

void uart_event_handle(app_uart_evt_t * p_event)
{
	uint8_t input_char;
	ret_code_t err_code;
	
	switch (p_event->evt_type)
	{
		case APP_UART_DATA:
			NRF_LOG_ERROR("UART Error: APP_UART_DATA");
			break;
		case APP_UART_DATA_READY:
			err_code = app_uart_get(&input_char);
			
			if (err_code)
			{
				NRF_LOG_ERROR("Error %d getting new character", err_code);
				reset_uart_input();
				break;
			}
			
			if (char_ends_message(input_char) || readBufferIndex >= UART_COMMAND_BUFFER_SIZE - 1)
			{
				app_timer_stop(RESPONSE_TIMER);
				append_char_to_buffer('\0');
				
				// Action
				NRF_LOG_INFO("Received: %s", readBuffer);
				response = true;
				memcpy(responseBuffer, readBuffer, UART_COMMAND_BUFFER_SIZE);
				
				reset_uart_input();
			}
			else
			{
				if (input_char != CARRIAGE_RETURN_KEY && input_char != ENTER_KEY)
				{
					append_char_to_buffer(input_char);
				}
		  
				ignoreNextEnter = false;
			}
			break;
		case APP_UART_FIFO_ERROR:
			APP_ERROR_HANDLER(p_event->data.error_code);
			break;
		case APP_UART_COMMUNICATION_ERROR:
			APP_ERROR_HANDLER(p_event->data.error_communication);
			break;
		case APP_UART_TX_EMPTY:
			// TX done. Will be called after successfully writing 1 character
			break;
		default:
			NRF_LOG_ERROR("UART Error: Code %d", p_event->evt_type);
			break;
	}
}

src/bc660.c:124 refers to APP_UART_COMMUNICATION_ERROR. What could be wrong?

Parents Reply
  • It looks like you are missing some data after/while the error is being handled. I can see that you have disabled the HWFC and hence it is not abnormal that nRF UART and the peer go out of synch when there is a UART error. Please check the UART communication on the TX/RX pins using a  logic analyzer (or similar) to see if the data is being exchanged correctly. Also you need to know what error handling your application has done and also the cause for this error. 

Children
No Data
Related