using vTaskDelayUntil questions

xintersecty wrote on Wednesday, November 04, 2009:

I am trying a simple delay into my simple program so I can control the rate of delay to flash an LED on/off.  Here is the code:

    int i;
    portTickType xLastWakeTime;
    const portTickType xFrequency = 10000;

LATBbits.LATB2 = 1; // Set LAT register to turn on LED
    xLastWakeTime = xTaskGetTickCount();

        vTaskDelayUntil(&xLastWakeTime, xFrequency);
        //for(i=0; i<0xFFFF; i++);
        //for(i=0; i<0xFFFF; i++);
        //for(i=0; i<0xFFFF; i++);

    LATBbits.LATB3 = ~LATBbits.LATB3; // Set LAT register bit 3 to turn on LED

When I use the function vTaskDelayUntil the code does not work, but If I comment out my busy wait loops, those work well.  I know the delayUntil function is a better way to go, as the processor might go to sleep in the idle task (hopefully a correct assumption)

I followed the debugger into the code, I can see the task get placed into the wait queue, but it’s really  hard to see when the task is released from the wait queue.   

Any suggestion?

edwards3 wrote on Wednesday, November 04, 2009:

Check the tick interrupt is running. If not then the task will never leave the delay.

10000 is potentially a long delay too, 10 seconds if the tick frequency is 1KHz, 100 seconds if the tick frequency is 100Hz.

xintersecty wrote on Wednesday, November 04, 2009:

You are correct, the tick interrupt is not running.  I changed my code to this:
        xLastWakeTime = xTaskGetTickCount();
        vTaskDelayUntil(&xLastWakeTime, xFrequency);

I set a debug break on the vTaskDelayUntil line to read the value xLastWakeTime.  The value read zero every time, i looped through the application. 

Thinking I had the right option I turned on

    #define configUSE_TICK_HOOK 1

That resulted into a compile error:
Source\tasks.c:1362: undefined reference to `vApplicationTickHook’

I am using a PIC24F16KA102 for my chip.  So I know the scheduler is started as I call  vTaskStartScheduler(); and that starts the task interrupt.

The suggestion was spot on, but I really don’t know how to make sure the tick interrupt is really working.

xintersecty wrote on Thursday, November 05, 2009:

I really now know that the scheduler is giving control to my function but the interrupt tick is not working.  I added an extra task to send a character on the UART.  The uartTask and my ledTask (flasher) does not work together.  At least I am not seeing a context switch between the two.  So I have a configuration issue with my code,  any more suggestions?