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

What "nrf_drv_uart_rx" actually means?

I'm developing uart program to communicate with arduino with nrf52840. And I'm working on s140 sdk.

First, I tried this code. It works, but first byte that send from arduino to nrf52840 was actually received at last. 

case NRF_DRV_UART_EVT_RX_DONE:

    uint8_t buf;
    char temp_buf;
    
    //buf = p_event->data.rxtx.p_data;
    len = p_event->data.rxtx.bytes;
    
    nrf_drv_uart_rx(uart_instance, uart_data_read_buffer[++uart_read_buffer_idx], len);

I read nrf_drv_uart.h and I found that nrf_drv_uart_event_t  includes p_data which is used in transfering by uart instance.

So I changed code to this and problem is solved. Every Uart data bytes aligned perfect.

case NRF_DRV_UART_EVT_RX_DONE:
    
    uint8_t buf;
    char temp_buf;
    
    buf = p_event->data.rxtx.p_data;
    len = p_event->data.rxtx.bytes;
    
    temp_buf = *buf;    //I need to handle character data
    uart_data_read_buffer[uart_data_read_buffer_idx] = *buf;
    uart_data_read_buffer_idx++;
    nrf_drv_uart_rx(uart, buf, len);

And Here's my questions.

1. Why the problme is solved? 

2. What acatually function "nrf_drv_uart_rx()" does? 

Thanks.

Parents Reply Children
No Data
Related