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

printf with UART - blocking way?

Hello,

I used the uart example to print text over serial communication from the SDK v11.

The problem is when I write lot of text consecutively, I don't receive all data on the terminal. (It clearly appears when I change the UART_TX_BUF_SIZE to a small value) I found that the file \sdk\components\libraries\uart\retarget.c implements the IO primitives. In the function _write, it appears that the FIFO memory is quiclky full.

int _write(int file, const char * p_char, int len) {
    int i;
    UNUSED_PARAMETER(file);

    for (i = 0; i < len; i++)
    {
        if (app_uart_put(*p_char++) == NRF_ERROR_NO_MEM)
		blinkErr(); // or return i; to allow printf to report error to application code
    }
    return len;
}

And it blinks. I also found that app_uart_put is a non-blocking call. It explains that I can fill the FIFO before it is empty.

According to this question, there was a bug (devzone.nordicsemi.com/.../) but it should be fixed in the SDK v11.

In any case, I am looking for a way to send data over UART synchronously (yes, 'A' is for asynchronous...) Do you have any ideas ? Make a loop, uart option ?

Thank you in advance !

Parents Reply Children
Related