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

debug data received on UART buffer

Hello,

I am using UART to receive data on a nRF52840 DK.

I have written some code using the Serial Port Library.

I have attached snippets of the code dealing with the Serial Port.

This is the header file

 

void init_rs485();
void serial_event_handler(struct nrf_serial_s const * p_serial,
		  nrf_serial_event_t event);
void send_rs485_message(char *buffer, size_t length);

// Setup UART0 for IPN
#define IPN_BAUDRATE 0x83F8
#define UNUSED_PIN 0xFFFFFFFF
#define RS485_TX_PIN     NRF_GPIO_PIN_MAP(0, 6)
#define RS485_RX_PIN     NRF_GPIO_PIN_MAP(0, 5)

NRF_SERIAL_DRV_UART_CONFIG_DEF(m_uart1_drv_config,
					RS485_RX_PIN, RS485_TX_PIN,
					UNUSED_PIN, UNUSED_PIN,
					NRF_UART_HWFC_DISABLED, NRF_UART_PARITY_EXCLUDED,
					IPN_BAUDRATE,
					UART_DEFAULT_CONFIG_IRQ_PRIORITY);

#define SERIAL_FIFO_TX_SIZE 64
#define SERIAL_FIFO_RX_SIZE 64

NRF_SERIAL_QUEUES_DEF(serial1_queues, SERIAL_FIFO_TX_SIZE, SERIAL_FIFO_RX_SIZE);

#define SERIAL_BUFF_TX_SIZE 1
#define SERIAL_BUFF_RX_SIZE 1

NRF_SERIAL_BUFFERS_DEF(serial1_buffs, SERIAL_BUFF_TX_SIZE, SERIAL_BUFF_RX_SIZE);

NRF_SERIAL_CONFIG_DEF(serial1_config, NRF_SERIAL_MODE_DMA,
                      &serial1_queues, &serial1_buffs, serial_event_handler, NULL);

NRF_SERIAL_UART_DEF(serial1_uart, 0);

This is the .C file

#include "rs485.h"

void init_rs485()
{
	NRF_LOG_DEBUG("init_rs485");
	// Init the Serial UART0 for IPN
	ret_code_t ret;
	ret = nrf_serial_init(&serial1_uart, &m_uart1_drv_config, &serial1_config);
	APP_ERROR_CHECK(ret);
}

void serial_event_handler(struct nrf_serial_s const * p_serial,
		  nrf_serial_event_t event)
{
	ret_code_t ret;
	char c;
	switch (event)
		{
		case NRF_SERIAL_EVENT_TX_DONE:
			break;
		case NRF_SERIAL_EVENT_RX_DATA:
			//NRF_LOG_DEBUG("in serial_event_handler...");
			//Read one char from queue at a time
			do{
				ret = nrf_queue_read(p_serial->p_ctx->p_config->p_queues->p_rxq, &c, sizeof(c));
				if (ret == NRF_SUCCESS) {
					//Echo char back to port
					NRF_LOG_DEBUG("%x ", c);
					ipn_process_event_byte(c);
				}
			} while(ret == NRF_SUCCESS);
			break;
		case NRF_SERIAL_EVENT_DRV_ERR:
			NRF_LOG_ERROR("in serial_event_handler %x", event);
			static uint8_t error_ctr = 0;
			if(error_ctr++ > 5)
				sd_nvic_SystemReset();
			break;
		case NRF_SERIAL_EVENT_FIFO_ERR:
			NRF_LOG_ERROR("in serial_event_handler %x", event);
			break;
		default:
			break;
		}
}

I want to see the data being received on the UART RX buffer. How can I see that on the Debug window?

If I add the buffer variable to the watch window, I get 'symbol not found'.

I have verified that I am receiving data on the Serial Bus using Realterm on the PC.

Please help,

Thanks

Parents Reply Children
No Data
Related