Task is not starting

barbart1 wrote on Thursday, June 03, 2010:

I managed to adapt the FreeRTOS demo to my board, deleted all the demo tasks and began to work on my own. My problem is that Parport initialization of the LED’s is working (they turn on before any tasks and scheduler)

int main( void )
	/* Setup any hardware that has not already been configured by the low
	level init routines. */
	xTaskCreate( vTestTaskB, "Hello",   configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1, NULL );
	/* We should never get here as control is now taken by the scheduler. */
  	return 0;

Parport test is within the prvSetupHardware() function. But the simple task doesn’t start. Is it possible something went wrong in the task code and the processor got an error from the RTOS? Here’s the code for the task:

static void vTestTaskB( void *pvParameters )
	AT91C_BASE_PIOA->PIO_SODR = (1<<17);
    /* Tasks must be implemented as continuous loops */

It should only turn one led off.

barbart1 wrote on Thursday, June 03, 2010:

It turned out I had to change the configTOTAL_HEAP_SIZE from 1024 to 4*24 and everything goes as it was planned. But can anyone tell why? And how can I calculate the minimal heap size for my program?

barbart1 wrote on Thursday, June 03, 2010:

4*1024 of course.

davedoors wrote on Thursday, June 03, 2010:

But can anyone tell why?

I can only speculate that 1024 is not big enough. You don’t say which CPU you are using or what configMINIMAL_STACK_SIZE is set to.

Did you check the return value of xTaskCreate()?

Did you check to see if vTaskStartScheduler() returned?

If you are using heap_1.c or heap_2.c then you can call xPortGetFreeHeapSize().

barbart1 wrote on Thursday, June 03, 2010:

I’m using Olimex SAM7-P64 board. My configMINIMAL_STACK_SIZE is set to 130. I did not check the return values of xTaskCreate(), nor vTaskStartScheduler. I’m using heap_2.c, but I don’t think I can debug the program, because it’s loaded into flash and for all I know, you can only add breakpoints if the program lies in ram. I’m sorry my questions can seem quite dumb, but I’m just starting my adventure with FreeRTOS and I’m trying to get to know it better. How are the return values related?