ktownsend wrote on Tuesday, September 15, 2009:
I’ve been trying to get **FreeRTOS 5.4.2** working with **Crossworks 2.0.3** and an LPC2148. When I have two simple tasks running incrementing a counter, everything works as expected … the tick counter increments, and the tasks are divided more or less equally. As soon as I add **vTaskDelay** or anything causing a delay, though, it crashes. Normally the problem for this is the the tick ISR isn’t working, but in this case it definately does work so I’m not really sure why the delay is causing a problem.
Has anyone had any luck getting FreeRTOS working in Crossworks 2.0?
If it helps clear anything up, here’s the tick ISR (which seems to work):
void vTickISR( void ) __attribute__((naked));
void vTickISR( void )
{
/* Save the context of the interrupted task. */
portSAVE_CONTEXT();
/* Increment the RTOS tick count, then look for the highest priority
task that is ready to run. */
vTaskIncrementTick();
#if configUSE_PREEMPTION == 1
vTaskSwitchContext();
#endif
/* Ready for the next interrupt. */
T0_IR = portTIMER_MATCH_ISR_BIT;
VIC_VectAddr = portCLEAR_VIC_INTERRUPT;
/* Restore the context of the new task. */
portRESTORE_CONTEXT();
}
and the config settings
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ((unsigned portLONG) 48000000) // =12.0000MHz xtal multiplied by 4 using the PLL.
#define configTICK_RATE_HZ ((portTickType) 100)
#define configMAX_PRIORITIES ((unsigned portBASE_TYPE) 4)
#define configMINIMAL_STACK_SIZE ((unsigned portSHORT) 128)
#define configTOTAL_HEAP_SIZE ((size_t) (16 * 1024))
#define configMAX_TASK_NAME_LEN (8)
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
and the preprocessor settings in Crossworks:
GCC_ARM7
SUPERVISOR_START
VECTORED_IRQ_INTERRUPTS
PACK_STRUCT_END=__attribute__((packed))
ALIGN_STRUCT_END=__attribute__((aligned(4)))
And last of all the tasks (sorry for the monster post but at least this way everything is clear from the start) … if I remove the delay everything works fine:
static int task1, task2;
static portTASK_FUNCTION(vTestTask, pvParameters __attribute__((unused)))
{
task1 = 0;
char *ptr;
for (;
{
// Task code goes here
task1++;
// if (uart1GetChar ((signed portCHAR *) ptr++, 0))
// uart1PutChar(*ptr, 0);
}
}
static portTASK_FUNCTION(vUART1Task, pvParameters __attribute__((unused)))
{
task2 = 0;
for (;
{
task2++;
uart1PutChar(‘1’, 0);
/* Block for 500ms. */
const portTickType xDelay = 500 / portTICK_RATE_MS;
vTaskDelay(xDelay);
}
}
int main(void)
{
cpuSetupHardware();
uart1Init(9600, 80);
xTaskHandle xTestTaskHandle;
xTaskCreate (vTestTask, (const signed portCHAR * const)"Test",
configMINIMAL_STACK_SIZE,
NULL,
(tskIDLE_PRIORITY + 2),
&xTestTaskHandle);
xTaskHandle xUART1TaskHandle;
xTaskCreate (vUART1Task, (const signed portCHAR * const)"UART1",
configMINIMAL_STACK_SIZE,
NULL,
(tskIDLE_PRIORITY + 2),
&xUART1TaskHandle);
vTaskStartScheduler();
return 0;
}