1
\$\begingroup\$

I have an ADC task that uses 4 channels and uses the DMA for transfer. I also have a streaming client which streams the ADC data through the TCP socket. I made the ADS Task lower priority than the streaming client.

I'm sending an integer that selects which ADC channel is selected as a message queue to the streaming client.

The problem is I get queue overflow when sending that adc channel integer.

ADC TASK

  if(bufferSelect != BUFFERS_NOT_READY)
        {
            if(xQueueSend(g_adcQueue, &bufferSelect,  0) != pdPASS)
            {
                throwError(ERROR_MESSAGE_QUEUE_FULL);
                PRINTF("%s\r\n", getErrorMessage(ERROR_MESSAGE_QUEUE_FULL));
            }
            bufferSelect = BUFFERS_NOT_READY;
        }

Streaming client task

/* obtain next buffer ready event */
        if(xQueueReceive(g_adcQueue, &bufferSelect, 0) == pdFALSE)
        {
            g_stopStreaming = true;
            continue;
        }
\$\endgroup\$
  • \$\begingroup\$ Are you sure that every task is blocking at one point or another to give time to the other tasks? Is the streaming client task being executed at all? \$\endgroup\$ – filo May 25 '18 at 11:21
  • \$\begingroup\$ yes both tasks executed, but the queue buffer is overflowed \$\endgroup\$ – Ahmed Saleh May 25 '18 at 14:37
  • \$\begingroup\$ Then it simply means that the consumer task is not executed often enough. How often the produces puts items into the queue? How often the consumer takes them out from the queue? \$\endgroup\$ – filo May 25 '18 at 14:40
  • \$\begingroup\$ The produces gets the ADC from DMA sampeled at 125khz, the consumer is a streaming client, that just gets an integer from the producer. I don't know how much tasks are executed in FreeRtos \$\endgroup\$ – Ahmed Saleh May 25 '18 at 15:02
  • 1
    \$\begingroup\$ If you don't know how often your tasks are being executed then your already are in trouble (how do you know that you have spare CPU time?). Trace your system with a tool like SEGGER SystemView or at least save the tick count at the beginning of the task loop in the suspected task to an array and see. \$\endgroup\$ – filo May 25 '18 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.