Queue receive used from a Task

anandakumarb wrote on Monday, April 18, 2011:

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

rtel wrote on Monday, April 18, 2011:

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

Regards.

anandakumarb wrote on Monday, April 18, 2011:

Thanks for your quick reply…

For your information… our application has the kernel & Max_Syscall priority as follows:
#define configKERNEL_INTERRUPT_PRIORITY                    255
#define configMAX_SYSCALL_INTERRUPT_PRIORITY      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.?

rtel wrote on Monday, April 18, 2011:

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.

anandakumarb wrote on Tuesday, April 19, 2011:

I am using STM32 microcontroller(Medium density VL) for our project and
For the 1st ISR,
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 192;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

for the 2nd ISR,
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 193;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

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

Regards,
Ananda

woops_ wrote on Tuesday, April 19, 2011:

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.

tacadia wrote on Monday, April 25, 2011:

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  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