nRF52832 UART Blocking mode and DWM1001

FormerMember
FormerMember

Hello,

I am using the DWM1001 board and would like to receive some bytes over UART to the nRF52832.

I want the device to wait for a certain number of bytes from UART and only then continue execution.

In the Documentation it says for the function  "nrf_drv_uart_rx":

If an event handler was provided in the nrf_drv_uart_init() call, this function returns immediately and the handler is called when the transfer is done. Otherwise, the transfer is performed in blocking mode, i.e. this function returns when the transfer is finished.

This seems to achieve what I am looking for. When calling nrf_drv_uart_init(), I provide no event handler (rather, I give '0' as parameter). This however does not work, nrf_drv_uart_rx() does not wait for UART data but instead continues execution. Is it wrong to provide '0' as parameter for event handler? How would I go about not providing an event handler to nrf_drv_uart_init()? 

I thought that something like this would work:

nrf_drv_uart_init(&app_uart_inst, &NRF_DEFAULT_CONFIG, 0);
nrf_drv_uart_rx_enable(&app_uart_inst);
nrf_drv_uart_rx(&app_uart_inst, rx_msg_check, UART_MSG_LEN);

while(!nrf_drv_uart_rx_ready(&app_uart_inst)){
nrf_drv_uart_rx(&app_uart_inst, rx_msg_check, UART_MSG_LEN);
}

However, the device never receives any data. I would appreciate any tips that might help.

Thank you.

 

 

Parents
  • Hi,

    The driver workes like you write, if you pass NULL (which is 0), the driver will work in non-blocking mode.

    Looking at your code snippet, you don't check any return values. The first thing you should do is to do that. Perhaps one of the calls fail for some reason, you just don't know it? I am also not sure about the logic of it, but perhaps I just see too little of your code.

    Note that if you just want a very simple API for reading and writing characters on UART, then the UART module may also be worth considering. It is demonstrated in the UART example.

Reply
  • Hi,

    The driver workes like you write, if you pass NULL (which is 0), the driver will work in non-blocking mode.

    Looking at your code snippet, you don't check any return values. The first thing you should do is to do that. Perhaps one of the calls fail for some reason, you just don't know it? I am also not sure about the logic of it, but perhaps I just see too little of your code.

    Note that if you just want a very simple API for reading and writing characters on UART, then the UART module may also be worth considering. It is demonstrated in the UART example.

Children
Related