UART FIFO SUPPORT

Hi,

I have stuck with uart read; I'm sending data from another device via uart. 

I could read only 16 bytes of data If enable FIFO SUPPORT, it reads only 1 byte data in callback or read api If FIFO SUPPORTdisabled.

I don't understand the FIFO SUPPORT, can someone help why and where we need to use it?

why I always read only 16bytes of data, how can I overcome this issue to read more bytes?

It would be helpful if there is documentation/ test codes available.

fsp_err_t err = R_SCI_UART_Read (&g_uart0_ctrl,g_dest, 64);
if (FSP_SUCCESS != err)
{
APP_ERR_PRINT ("\r\n** R_SCI_UART_Read API Failed **\r\n");
return err;
}
while (!UART_EVENT_RX_COMPLETE)
{

}

void uart_callback(uart_callback_args_t *p_args)
{
/* Logged the event in global variable */
g_uart_event = (uint8_t)p_args->event;

switch (p_args->event)
{
/* Read all data provided by user until enter button is pressed */
case UART_EVENT_RX_CHAR:
{

if (UART_DATA_BITS_8 >= g_uart0_cfg.data_bits)
{
g_temp_buffer[g_counter_var++] = (uint8_t)(p_args->data ;
g_data_received_flag = true;

}
else
{
uint16_t * p_dest = (uint16_t *) &g_temp_buffer[g_counter_var];
*p_dest = (uint16_t) p_args->data;
g_counter_var += 2;
}

break;
}
case UART_EVENT_RX_COMPLETE:
{
uart_receive_complete = 1;
break;
}
/* Transmit complete */
case UART_EVENT_TX_COMPLETE:
{
uart_transfer_complete = 1;
break;
}
case UART_EVENT_TX_DATA_EMPTY:
break;
case UART_EVENT_ERR_OVERFLOW:
break;

default:
break;
}

Thanks,

Tarun

Parents
  • Hi Taruni Dhara Rao Gandham,

    If FIFO support is enabled and supported by the SCI channel, its default depth is declared by default to 16 bytes, as you can see in bsp_feature.h file.

    #define BSP_FEATURE_SCI_UART_FIFO_DEPTH                      (16U)

    Assuming from your code that you read data only one time, that is why you read only 16 bytes with FIFO enabled.

    Let us know if it helped.

    AZ

  • Hi Az,

    Thanks for your answer.

    1. can I change fifo depth val value to accommodate 64 bytes or more?

    2. otherwise, can I clear fifo data after reading it, if yes, how can I do it so?

    3. If I don't want fifo support, I want to use circular buffer. I see only 1 byte can be read, how can read more bytes as I mentioned like 64 bytes or more, how can I achieve it? I tried example and sci read api with 64byte length but always read 1 byte in both sci_read api and callback function.

    Thanks

    Tarun 

  • Reception is implemented with either 1-stage register or 16-stage FIFO. If you have set MAX to Extra > Receive FIFO Trigger Level in Configurations tab, every time that FIFO is full, the callback function will be called and you can read new data.  You can also increase the default FIFO depth but the reception could become slower.

    Without FIFO support, you should read every time from Receive Data Register when a receive data full interrupt occurs.

    I hope it clears up.

    AZ

  • Hi Taruni Dhara Rao Gandham,

    I also encountered similar problems.

    I don't want to use FIFO support. I want to use circular buffer. How can I read more bytes, such as 64 bytes and above, as you mentioned, how can I achieve this?

    Did you find any solution to this issue?

    Thanks

    guurii

  • You can specify how many bytes you want to read in R_SCI_UART_Read:

    This will read the reveive register 64 times.

Reply Children
No Data