I know this appears to be a common problem, but we've tripple checked and don't seem to be doing anything that is listed in the FAQ's regarding this problem.
We get our code up and running, and then anywhere from a few seconds to a few minutes, the program hangs on
for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext )
We've monitored our stacks and they have plenty of room. The high watermark doesn't vary over time and we don't get close to the end, so we are pretty sure that is not it.
We've set our priorities appropriately
// configKERNEL_INTERRUPT_PRIORITY sets the interrupt priority used by the kernel itself.
#define configKERNEL_INTERRUPT_PRIORITY 255 /* equivalent to 0xff, or priority 15. */
// configMAX_SYSCALL_INTERRUPT_PRIORITY sets the highest interrupt priority
//from which interrupt safe FreeRTOS API functions can be called.
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xb0, or priority 11. */
All of our ISRs have a priority level of
#define INT_PRI_SPI1 (12 << 4)
#define INT_PRI_SPI2 (12 << 4)
#define INT_PRI_SPI3 (12 << 4)
#define INT_PRI_EXT_SPI1 (15 << 4)
#define INT_PRI_UART1 (13 << 4)
#define INT_PRI_UART2 (12 << 4)
#define INT_PRI_UART3 (13 << 4)
#define INT_PRI_UART4 (13 << 4)
#define INT_PRI_UART5 (13 << 4)
#define INT_PRI_UART6 (13 << 4)
#define INT_PRI_TIMER_1 (14 << 4)
#define INT_PRI_TIMER_2 (14 << 4)
#define INT_PRI_TIMER_3 (14 << 4)
#define INT_PRI_TIMER_4 (14 << 4)
#define INT_PRI_TIMER_5 (14 << 4)
#define INT_PRI_TIMER_6 (14 << 4)
#define INT_PRI_TIMER_7 (14 << 4)
#define INT_PRI_TIMER_8 (14 << 4)
#define INT_PRI_TIMER_9 (14 << 4)
#define INT_PRI_TIMER_10 (14 << 4)
#define INT_PRI_TIMER_11 (14 << 4)
#define INT_PRI_TIMER_12 (14 << 4)
#define INT_PRI_TIMER_13 (14 << 4)
#define INT_PRI_TIMER_14 (14 << 4)
#define INT_PRI_I2C1 (15 << 4)
#define INT_PRI_I2C2 (15 << 4)
#define INT_PRI_I2C3 (15 << 4)
#define INT_PRI_ADC (15 << 4)
I've checked through all my code and I do not have any API calls that run during a "critical" period. I never suspend the scheduler.
The code hangs on this code..
xQueueReceive(spi1_que_handle, (void*)&msg_ptr, WAIT_FOREVER);
This code has successfully executed thousands of times before it hangs. I've check to see that spi1_que_handle is not corrupted and does not change.
I don't know where to start....
I also checked my SCB_AIRCR Register, and my Priority group is 011 = 4 bits of priority, no bits of sub.
“I don't know where to start....”
Well it sounds like you have done a lot already, so it is more a question of what to do next, than starting.
I was going to mention the priority groups, but it looks like you have that covered too.
Which function are you using to set the interrupt priorities? You have priorities set using definitions like:
“#define INT_PRI_SPI1 (12 << 4)”
Some Cortex-M3 libraries want interrupt priorities to be passed to them like this. Some want it to be passed in un-shifted (so 12 in this case). This could be a problem.
The Cortex-M3 has one of the most complex interrupt schemes known to the embedded universe!
Looks like you were correct! Checked and all the interrupts were zero. Everything was double shifted. Thanks for helping me zero in on the problem.
I'm checking the other interrupts and I wanted to verify that
PendSV should be 15 (Lowest)
SysTick should be 15 (Lowest)
SVCall should be 0 (highest)
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.