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

[SDK 13] [UART_APP_FIFO] Problem with FIFO flush.

Hello.

I notice a problem with app_uart_flush function, which is calling app_fifo_flush function and in this we have a:

uint32_t app_fifo_flush(app_fifo_t * p_fifo)
{
    p_fifo->read_pos = p_fifo->write_pos;
    return NRF_SUCCESS;
}

With that when I check m_tx_fifo and m_rx_fifo in app_uart_fifo.c file after some time before block I got a next values:

image description

How it's possible when in app_fifo_put function we have a macro to check fifo length ?

uint32_t app_fifo_put(app_fifo_t * p_fifo, uint8_t byte)
{
    if (FIFO_LENGTH() <= p_fifo->buf_size_mask)
    {
        fifo_put(p_fifo, byte);
        return NRF_SUCCESS;
    }

    return NRF_ERROR_NO_MEM;
}

After some changes in app_fifo_flush:

 uint32_t app_fifo_flush(app_fifo_t * p_fifo)
{
    p_fifo->read_pos = 0;
    p_fifo->write_pos = 0;
    return NRF_SUCCESS;
}

UART seem work properly.

It's correct solution, or I should do this on another way ?

BR, Kamil

Parents
  • Hi,

    What is the problem with the values you have in m_tx_fifo and m_rx_fifo?

    In both cases the FIFO_LENGTH() is 0 (the difference between read and write position), and you will not get NRF_ERROR_NO_MEM based on the picture you posted.

    You should not change the app_fifo_flush() function.

    It should look like this:

    uint32_t app_fifo_flush(app_fifo_t * p_fifo)
    {
        p_fifo->read_pos = p_fifo->write_pos;
        return NRF_SUCCESS;
    }
    
Reply
  • Hi,

    What is the problem with the values you have in m_tx_fifo and m_rx_fifo?

    In both cases the FIFO_LENGTH() is 0 (the difference between read and write position), and you will not get NRF_ERROR_NO_MEM based on the picture you posted.

    You should not change the app_fifo_flush() function.

    It should look like this:

    uint32_t app_fifo_flush(app_fifo_t * p_fifo)
    {
        p_fifo->read_pos = p_fifo->write_pos;
        return NRF_SUCCESS;
    }
    
Children
No Data
Related