Opps… I just read the comments, it tells me what might be the problem… the GDB window was small and I didn’t look…
/* *** NOTE ***********************************************************
If you find your application is crashing here then likely causes are:
1) Stack overflow -
see http://www.freertos.org/Stacks-and-stack-overflow-checking.html
2) Incorrect interrupt priority assignment, especially on Cortex-M3
parts where numerically high priority values denote low actual
interrupt priorities, which can seem counter intuitive. See
configMAX_SYSCALL_INTERRUPT_PRIORITY on http://www.freertos.org/a00110.html
3) Calling an API function from within a critical section or when
the scheduler is suspended, or calling an API function that does
not end in "FromISR" from an interrupt.
4) Using a queue or semaphore before it has been initialised or
before the scheduler has been started (are interrupts firing
before vTaskStartScheduler() has been called?).
See http://www.freertos.org/FAQHelp.html for more tips, and ensure
configASSERT() is defined! http://www.freertos.org/a00110.html#configASSERT
**********************************************************************/
Using STM32F4 with FreeRTOS 8.1, and trying to dynamically switch frequency.
Background: I can setup the target to run at any desired frequency and the target runs fine. In particular I am using 12 and 48 MHz. Selecting either of those two frequencies and doing a cold boot, the target runs fine. However if I switch frequency, the target runs for only a brief time and fails. Note that at either frequency I keep the peripheral bus clock constant at 12MHz, to avoid having to reconfigure peripherals.
I created a non-FreeRTOS build and used the same frequency switching code, and the target works fine. Note that this build is very simplified, no tasks, and no interrupts, but it does use the uart for debugging (similar to the FreeRTOS build).
The frequency switching implementation looks like this,
taskENTER_CRITICAL();
// run the switch frequency code here
taskEXIT_CRITICAL();
The STM32 has a clock management library, and I use the HAL
RCCClockConfig() api to switch frequencies. This api also manages the systick, to keep it at 1ms.
Failure: After the frequency switch, the target “runs” for a brief time before it seems to halt. After the frequency switch, the target has all tasks blocked waiting for an event. If I press a button, or send a command thru uart, that event will partially process before the target halts. Sometimes the target will actually process more than one event before the halt.
Using GDB I can pause the target, and it shows that the target is in an infinite loop at this line, from list.c, vListInsert(), line 159.
for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */
{
/* There is nothing to do here, we are just iterating to the
wanted insertion position. */
}