# Queue receive used from a Task

**URL:** <https://forums.freertos.org/t/queue-receive-used-from-a-task/4022>\
**Category:** Kernel\
**Created:** [April 18, 2011, 10:07am UTC](https://forums.freertos.org/t/queue-receive-used-from-a-task/4022 "2011-04-18T10:07:36Z")\
**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:** [April 18, 2011, 10:07am UTC](https://forums.freertos.org/t/queue-receive-used-from-a-task/4022/1 "2011-04-18T10:07:36Z")

</div>

**[anandakumarb](https://sourceforge.net/u/anandakumarb/)** wrote on [Monday, April 18, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/af86cb6c/#11e9):

Hi,

Currently I’m working on a project that uses Cortex-M3 microcontroller and FreeRTOS.

Recently, I found a bug that causes a crash here:

## list.c file:

for( pxIterator = ( xListItem \* ) &( pxList-\>xListEnd ); pxIterator-\>pxNext-\>xItemValue \<= xValueOfInsertion; pxIterator = pxIterator-\>pxNext )  
{

}

When it is crashed at this point, the call stack shows likes this:

vListInsert  
vTaskPlaceOnEventList  
prvUnlockQueue  
TskHandler

In the task handler, xqueuereceive function is used to get the message which is posted based on the interrupt.

Can anyone tell, why this is crashed after calling xqueuereceive()?

Regards,  
Ananda

---

<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:** [April 18, 2011, 10:30am UTC](https://forums.freertos.org/t/queue-receive-used-from-a-task/4022/2 "2011-04-18T10:30:42Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, April 18, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/af86cb6c/#6758):

From experience of answering this question, I would say it is almost certain that you have your interrupt priorities and configuration set incorrectly.

See the documentation page for the port you are using, the descriptions of configKERNEL\_INTERRUPT\_PRIORITY and configMAX\_SYSCALL\_INTERRUPT\_PRIORITY in the customisation section of the web site and in the Cortex-M3 edition of the FreeRTOS tutorial book, and item three here: [http://www.freertos.org/FAQHelp.html](http://www.freertos.org/FAQHelp.html)

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 18, 2011, 5:07pm UTC](https://forums.freertos.org/t/queue-receive-used-from-a-task/4022/3 "2011-04-18T17:07:50Z")

</div>

**[anandakumarb](https://sourceforge.net/u/anandakumarb/)** wrote on [Monday, April 18, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/af86cb6c/#4e18):

Thanks for your quick reply…

For your information… our application has the kernel & Max\_Syscall priority as follows:  
#define configKERNEL\_INTERRUPT\_PRIORITY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 255  
#define configMAX\_SYSCALL\_INTERRUPT\_PRIORITY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 191

And i am using two interrupt service routine, which has the interrupt priority level set to 192 & 193 respectively for ISR1 & ISR2. These two ISRs will call “FromISR” API.

But with the above priority settings, still i see the crash is happening at the infinite for loop  
for( pxIterator = ( xListItem \* ) &( pxList-\>xListEnd ); pxIterator-\>pxNext-\>xItemValue \<= xValueOfInsertion; pxIterator = pxIterator-\>pxNext )  
{

}

Can you please tell me whether the above ISRs interrupt priority is proper or not.?

---

<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:** [April 18, 2011, 5:55pm UTC](https://forums.freertos.org/t/queue-receive-used-from-a-task/4022/4 "2011-04-18T17:55:45Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, April 18, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/af86cb6c/#3638):

Which microcontroller are you using (I know it’s a Cortex-M3, but which).

Do you have the priority grouping set such that all the priority bits are set as being pre-emption priority, and not sub-priority?

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 19, 2011, 3:41am UTC](https://forums.freertos.org/t/queue-receive-used-from-a-task/4022/5 "2011-04-19T03:41:52Z")

</div>

**[anandakumarb](https://sourceforge.net/u/anandakumarb/)** wrote on [Tuesday, April 19, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/af86cb6c/#8b70):

I am using STM32 microcontroller(Medium density VL) for our project and  
For the 1st ISR,  
&nbsp; NVIC\_InitStructure.NVIC\_IRQChannelPreemptionPriority = 192;  
&nbsp; NVIC\_InitStructure.NVIC\_IRQChannelSubPriority = 0;

for the 2nd ISR,  
&nbsp; NVIC\_InitStructure.NVIC\_IRQChannelPreemptionPriority = 193;  
&nbsp; NVIC\_InitStructure.NVIC\_IRQChannelSubPriority = 0;

This is how the pre-emption priority & sub priority were initialized in our project.

Regards,  
Ananda

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 19, 2011, 3:54pm UTC](https://forums.freertos.org/t/queue-receive-used-from-a-task/4022/6 "2011-04-19T15:54:06Z")

</div>

**[woops\_](https://sourceforge.net/u/woops_/)** wrote on [Tuesday, April 19, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/af86cb6c/#3ea3):

Do you call NVIC\_PriorityGroupConfig( NVIC\_PriorityGroup\_4 ) in your set up routine. That sets how many bits are used for each before you set actual interrupts like in your code. As well, there are only 4 upper bits so 192 and 193 will end with the same priority.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [April 25, 2011, 3:42am UTC](https://forums.freertos.org/t/queue-receive-used-from-a-task/4022/7 "2011-04-25T03:42:48Z")

</div>

**[tacadia](https://sourceforge.net/u/tacadia/)** wrote on [Monday, April 25, 2011](https://sourceforge.net/p/freertos/discussion/382005/thread/af86cb6c/#c9bc):

Hi,

Just to chime in … I’ve gotten stuck here before when using FreeRTOS v6.1.0 on an RX62N. The reason for being stuck in&nbsp; the infinite loop here was there one of my tasks was not allocated enough stack space.

You might want to check the memory map of your Task just in case.

Cheers,  
Ivan
