Avoiding "Ring buffer overrun!" or "Hardware buffer overrun!"while using FreeRTOS uart example

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Avoiding "Ring buffer overrun!" or "Hardware buffer overrun!"while using FreeRTOS uart example

ソリューションへジャンプ
2,313件の閲覧回数
nkp
Contributor II

Hi!

I am trying to use the freertos_uart.c on my frdm-k22 board to read data from my GPS module (GPS module has tx and rx lines that keeps sending out information every second). 

Everytime I run the uart example I get four bytes (specified by recv_buffer[4]) of information after which I get "Ring buffer overrun!" Increasing the size of the recv_buffer doesn't seem to help. 

My question:

-How do I read the information from the ring buffer every time recv_buffer gets full? 

-Will reading the ring buffer solve the "ring buffer overrun" problem?

Thanks!

ラベル(1)
0 件の賞賛
返信
1 解決策
1,748件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi Niyanth

The example uses single instance of UART IP and writes string into, then reads back chars. After every 4B receives, these are sent back on UART.    

This example also showing that if the reading from ring buffer is slower than writing to it, buffer will overflow. To show this situation, data reading is slowed down by 1s delay.

In uart_task

    /* Send data */
    do
    {
        error = UART_RTOS_Receive(&handle, recv_buffer, sizeof(recv_buffer), &n);
        if (error == kStatus_UART_RxHardwareOverrun)
        {
            /* Notify about hardware buffer overrun */
            if (kStatus_Success !=
                UART_RTOS_Send(&handle, (uint8_t *)send_hardware_overrun, strlen(send_hardware_overrun)))
            {
                vTaskSuspend(NULL);
            }
        }
        if (error == kStatus_UART_RxRingBufferOverrun)
        {
            /* Notify about ring buffer overrun */
            if (kStatus_Success != UART_RTOS_Send(&handle, (uint8_t *)send_ring_overrun, strlen(send_ring_overrun)))
            {
                vTaskSuspend(NULL);
            }
        }
        if (n > 0)
        {
            /* send back the received data */
            UART_RTOS_Send(&handle, (uint8_t *)recv_buffer, n);
        }
        vTaskDelay(1000);

    } while (kStatus_Success == error);

 remark this line will solve this issue

//     vTaskDelay(1000);

Regards

Daniel

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
1,749件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi Niyanth

The example uses single instance of UART IP and writes string into, then reads back chars. After every 4B receives, these are sent back on UART.    

This example also showing that if the reading from ring buffer is slower than writing to it, buffer will overflow. To show this situation, data reading is slowed down by 1s delay.

In uart_task

    /* Send data */
    do
    {
        error = UART_RTOS_Receive(&handle, recv_buffer, sizeof(recv_buffer), &n);
        if (error == kStatus_UART_RxHardwareOverrun)
        {
            /* Notify about hardware buffer overrun */
            if (kStatus_Success !=
                UART_RTOS_Send(&handle, (uint8_t *)send_hardware_overrun, strlen(send_hardware_overrun)))
            {
                vTaskSuspend(NULL);
            }
        }
        if (error == kStatus_UART_RxRingBufferOverrun)
        {
            /* Notify about ring buffer overrun */
            if (kStatus_Success != UART_RTOS_Send(&handle, (uint8_t *)send_ring_overrun, strlen(send_ring_overrun)))
            {
                vTaskSuspend(NULL);
            }
        }
        if (n > 0)
        {
            /* send back the received data */
            UART_RTOS_Send(&handle, (uint8_t *)recv_buffer, n);
        }
        vTaskDelay(1000);

    } while (kStatus_Success == error);

 remark this line will solve this issue

//     vTaskDelay(1000);

Regards

Daniel

0 件の賞賛
返信