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

nrf_serial_write don't work in blocking mode

Hi!

I'm working on the NRF52832. I'm using the function "nrf_serial_write()" to send data over uart. I want it to work in blocking mode. As I can read in the infocenter, if I put a time into the "timeout_ms" parameter, the function should work in blocking mode. But the function seems to work in nonblocking mode because without the delay of 50 ms, the "nrf_serial_uninit()" function stops the data transmission. There is my code:

              //Uart speed is 9600 bps
              //BUF_LEN = 26
              nrf_serial_write(&serial_uart, &buf, BUF_LEN, NULL, 1000); // Send byte over OW
              nrf_delay_ms(50);
              nrf_serial_uninit(&serial_uart);
*

*I send 26 bytes at 9600 bps. A timeout of 1000 ms should be enough.

I expect the problem is with the timer initialization of the uart timer. There is my code:

    ret_code_t ret;

    ret = nrf_drv_clock_init();
    APP_ERROR_CHECK(ret);
    nrf_drv_clock_lfclk_request(NULL);
    ret = app_timer_init();
    APP_ERROR_CHECK(ret);

What am I missing?

Thank you!

Parents
  • I realized that the function nrf_serial_write() is only in blocking mode when an array larger than the fifo size is passed in argument. The function stops blocking when there is equal byte to send than the size of the fifo. E.g. You have a fifo of 32 bytes and an array of 56 bytes is passed in argument. The function seems to block for the first 24 bytes then it stops blocking for the last 32 bytes. I patched this problem by using a delay "nrf_delay_ms()". Since I know the size of the array and the bauderate, I can estimate the delay.

Reply
  • I realized that the function nrf_serial_write() is only in blocking mode when an array larger than the fifo size is passed in argument. The function stops blocking when there is equal byte to send than the size of the fifo. E.g. You have a fifo of 32 bytes and an array of 56 bytes is passed in argument. The function seems to block for the first 24 bytes then it stops blocking for the last 32 bytes. I patched this problem by using a delay "nrf_delay_ms()". Since I know the size of the array and the bauderate, I can estimate the delay.

Children
No Data
Related