# FreeRTOS - STM32-  Data in queue not processed fast enough

**URL:** <https://forums.freertos.org/t/freertos-stm32-data-in-queue-not-processed-fast-enough/7623>\
**Category:** Kernel\
**Created:** [January 14, 2019, 11:03am UTC](https://forums.freertos.org/t/freertos-stm32-data-in-queue-not-processed-fast-enough/7623 "2019-01-14T11:03:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 14, 2019, 11:03am UTC](https://forums.freertos.org/t/freertos-stm32-data-in-queue-not-processed-fast-enough/7623/1 "2019-01-14T11:03:57Z")

</div>

**[stevend](https://sourceforge.net/u/stevend/)** wrote on [Monday, January 14, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/697b3370d5/#fe0b):

Hello,

I’m new to FreeRTOS and I’ve been working on this for 2 days, that’s the reason i’m asking for your help.

I have three tasks running. One is used to communicate with a bluetooth device, and the 2 others are used for TX and RX over USB (UART). My app works fine when I send or receive data to my bluetooth device but when I command my bluetooth device to enter discover mode, there is so much data incoming that I can’t process everything. My queue used for bluetooth data management gets full and my app won’t respond to any command I send.

Priorities used in my app :

- Task creation :
  - USB\_MANAGER\_SENDER (7U)
  - USB\_MANAGER\_RECEIVER (8U)
  - USB\_DRIVER\_PRIORITY (9U)
  - BLE\_TASK\_PRIORITY (6U)

- Interrupt priorities :
  - BLE\_UART\_INTERRUPT\_PRIORITY (7U)
  - FTDI\_UART\_INTERRUPT\_PRIORITY (5U)

(configMAX\_SYSCALL\_INTERRUPT\_PRIORITY set to 4)

I can send a code sample if it helps understanding my problem.

If you have any tips that would be nice, thanks 🙂

I’m using a STM32F4, FreeRTOS V9.0.0, and IAR

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [January 14, 2019, 5:07pm UTC](https://forums.freertos.org/t/freertos-stm32-data-in-queue-not-processed-fast-enough/7623/2 "2019-01-14T17:07:56Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, January 14, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/697b3370d5/#fe0b/b92c):

Can you please show how you are creating and using the queue. Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 15, 2019, 2:42am UTC](https://forums.freertos.org/t/freertos-stm32-data-in-queue-not-processed-fast-enough/7623/3 "2019-01-15T02:42:20Z")

</div>

**[richarddamon](https://sourceforge.net/u/richarddamon/)** wrote on [Tuesday, January 15, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/697b3370d5/#86bb):

If you are using the queue as a simple character fifo, it is quite possible to overload your system, as is well described in the documentation and examples. There is a LOT of over head for each character. A stream buffer or message buffer might be more efficient, or some method where you build up a buffer of data for a message, and just send a buffer address through a queue.

You also may need a much larger queue to be big enough to hold the amount of data you need, and have some form of dealing with overrun.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 15, 2019, 1:45pm UTC](https://forums.freertos.org/t/freertos-stm32-data-in-queue-not-processed-fast-enough/7623/4 "2019-01-15T13:45:26Z")

</div>

**[stevend](https://sourceforge.net/u/stevend/)** wrote on [Tuesday, January 15, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/697b3370d5/#c99a):

Here is some code from my project. I hope this files are clear. Thanks in advance for your feedback and your help on my code. As i said, any help is appreciated 🙂

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [January 15, 2019, 2:36pm UTC](https://forums.freertos.org/t/freertos-stm32-data-in-queue-not-processed-fast-enough/7623/5 "2019-01-15T14:36:53Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Tuesday, January 15, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/697b3370d5/#c99a/1ab8):

Really I was hoping for just a cut down piece of code that showed how  
the queue in question was being used. Looks like there are quite a lot  
of queues in the code you posted.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 15, 2019, 4:01pm UTC](https://forums.freertos.org/t/freertos-stm32-data-in-queue-not-processed-fast-enough/7623/6 "2019-01-15T16:01:11Z")

</div>

**[stevend](https://sourceforge.net/u/stevend/)** wrote on [Tuesday, January 15, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/697b3370d5/#3400):

yeah sorry about that 😕  
I tought it would be interesting for you guys to have it all, so you can see everything and tell me if i’m doing something really wrong…  
I will post something shorter 🙂

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [January 22, 2019, 9:09am UTC](https://forums.freertos.org/t/freertos-stm32-data-in-queue-not-processed-fast-enough/7623/7 "2019-01-22T09:09:16Z")

</div>

**[stevend](https://sourceforge.net/u/stevend/)** wrote on [Tuesday, January 22, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/697b3370d5/#edd6):

Hello again, it’s been a week and i’m still working on this, it’s kind of an annoying feeling… I found some minor mistakes in my code and I hope it would fixed the problem but it did not. After that I tried to implement a few things that did not worked ( stopping dma stream, changing task priorities, adding a mutex, …)

I also have been reading the practical guide to master FreeRtos.

but still a few quetions came to my mind :

is it possible that fast interrupt starve task from process time and if yes how can I handle this from happening ?

I also thought my problem could come from the fact that my ble driver wait on a queue that receive from interrupt and from a task in communciationManager.

Just so you guys know, this code has not been written by me. I made a few corrections but as someone with few experiences I find it hard to work on someone else (big) project …

Guess i’ll be working on this for a while so any help is welcome 🙂
