vTaskDelay and vTaskDelayUntil on pic18f452

gmcapivara wrote on Sunday, March 07, 2010:

Hi. First I apologise for my poor english. Now I’m having a feel problems with the functions vTaskDelay and vTaskDelayUntil on pic18f452. They simply doesn’t work. I set
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
and when I use the functions on the example on website:

void vTaskFunction( void * pvParameters )
{
portTickType xLastWakeTime;
const portTickType xFrequency = 10;

     // Initialise the xLastWakeTime variable with the current time.
     xLastWakeTime = xTaskGetTickCount();

     for( ;; )
     {
         // Wait for the next cycle.
         vTaskDelayUntil( &xLastWakeTime, xFrequency );

         // Perform action here.
     }
}
the process block indefinitely. When I comment the function delay and put a for to make a delay and toggle a led the function work’s fine. It’s analogue when I use the example with vTaskDelay.

suggestions?

edwards3 wrote on Sunday, March 07, 2010:

Sounds like the tick interrupt is not executing as expected. Put a break point in the tick interrupt handler and see if it ever gets hit. Alternatively remove the call to vTaskDelay() and instead just loop round calling xTaskGetTickCount() to see if the value returned ever increases.

gmcapivara wrote on Thursday, March 18, 2010:

well…more news….
putting some break points I found this……the ticks are ok….but I think there is a problem with the memory allocation for the process….for example:

void toggleLed(int i)
{
int j;
TRISD = 0x00;
PORTD = 0x10;
for( j=0; j<i; j++) {}
PORTD = 0x00;
for( j=0; j<i; j++) {}
}

void vTaskCode( void * pvParameters )
{
int i;
for( ;; )
{
i = 10000;
toggleLed(i);
}
}

void main(void)
{
vPortInitialiseBlocks();
        for(;:wink: { toggleLed(10000); }
//xTaskCreate( vTaskCode, ( const char * const ) “Check”, configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
vTaskStartScheduler();
}

the code works fine….but when I comment the for in main and uncomment the xTaskCreate, putting a break point on the toggleLed(i) on the process, when I step into toggleLed the value of parameter “i”  becomes 0……

this is problem with memory allocation right?