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

UART communication

Hi,I am using the nRF52840 development board, S140 and SDK16.0, I have some questions about  data transmission on the UART.

I am trying to make a central device that is similar to the NUS central example in the SDK. 

It receives data from the peripheral once every 204 bytes, stores the data (4080botes) received 20 times in a prepared buffer, and then transmits the data via UART.

static void ble_nus_chars_received_uart_print(uint8_t * p_data, uint16_t data_len)
{
    ret_code_t ret_val;
	uint32_t i;
	int16_t data;
	static int n;

	for(i = 0; i < data_len; i++)
	{
		if(n < 4080){
			uart_buff[n] = p_data[i];
			n++;
		}
	}
	
	if(n >= 4080){
		for (n = 0; n < 4080; n++)
		{
			do
			{
				ret_val = app_uart_put(uart_buff[n]);
				if ((ret_val != NRF_SUCCESS) && (ret_val != NRF_ERROR_NO_MEM))
				{
					NRF_LOG_ERROR("app_uart_put failed for index 0x%04x.", i);
					APP_ERROR_CHECK(ret_val);
				}
			} while (ret_val == NRF_ERROR_NO_MEM);
		}
		n = 0;
	}
}

static void uart_init(void)
{
    ret_code_t err_code;

    app_uart_comm_params_t const comm_params =
    {
        .rx_pin_no    = RX_PIN_NUMBER,
        .tx_pin_no    = TX_PIN_NUMBER,
        .rts_pin_no   = RTS_PIN_NUMBER,
        .cts_pin_no   = CTS_PIN_NUMBER,
        .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
        .use_parity   = false,
        .baud_rate    = UART_BAUDRATE_BAUDRATE_Baud115200
    };

    APP_UART_FIFO_INIT(&comm_params,
                       UART_RX_BUF_SIZE,
                       UART_TX_BUF_SIZE,
                       uart_event_handle,
                       APP_IRQ_PRIORITY_LOWEST,
                       err_code);
	
    APP_ERROR_CHECK(err_code);
}
	

However, looking at the data sent to the UART, there is only 2080 bytes and the data is dropping.
It is missing even if UART communication is performed every time BLE is received (104 bytes per time).
It is confirmed that the communication data between BLE can be received without being lost. (Dumped to csv file and confirmed)

Probably because the UART communication is slow.
Changing the baud rate was meaningless.

Is there any solution? Please help to resolve.
Also, since the app_uart_put function sends 1 byte at a time,
Is there a function that can send a large amount at one time?

Finally, I think that  myEnglish is a little strange, but please forgive me.

Thanks in advance.

Parents Reply Children
No Data
Related