vTaskDelay is to short

patrickecr wrote on Friday, December 09, 2011:

Hello

I’m new on FreeRTOS and started with a own simple project to test mukltitasking.

Now i’ve got the first problem. In the code below i call vTaskDelay to wait 500ms before toggeling the output. But when I measure the frequency with scope, I can see, that the delay is arround 50us. It doesn’t matter which time is entered, I always get the same delay. Any suggestions?

static portTASK_FUNCTION(vMainTask2, pvParameters) {
	const portTickType xDelay = 500/portTICK_RATE_MS;
	for(;;){
		vTaskDelay(xDelay);
		Bit3_NegVal();
	}	
}

The timertick works correct at 1ms. I’ve already changed the settings of portTICK_RATE_MS and it’s parameters to the right value.

I’m using the MCF52259 from Freescale, IDE: codewarrior 10.1 (Eclips version), FreeRTOS V7.0.2

Thanks for help!

Best regards
Patrick

rtel wrote on Friday, December 09, 2011:

The timertick works correct at 1ms. I’ve already changed the settings of portTICK_RATE_MS and it’s parameters to the right value.

That is not a user configurable value, please set it back to its default as it should be calculated automatically from the value of configTICK_RATE_HZ.  Only the values in FreeRTOSConfig.h are user configurable.  Note that portTICK_RATE_MS is only useful when configTICK_RATE_HZ is equal to or less than 1000.

Regards.

patrickecr wrote on Friday, December 09, 2011:

Thats right. I just wanted to say that i’ve configured configTICK_RATE_HZ in FreeRTOSConfig.h.
portmacro.h is at default-state.

Do you know this problem or any reason for that?

rtel wrote on Friday, December 09, 2011:

Please take a copy of the tick count both before and after the delay call as:

ulTimeBefore = xTaskGetTickCount();
vTaskDelay(xDelay);
ulTimeAfter = xTaskGetTickCount();

and then see what (ulTimeAfter - ulTimeBefore) is.

Regards.

patrickecr wrote on Monday, December 12, 2011:

The difference is always zero/one. So there is no delay by calling the vTaskDelay().

I also tried to call the function with different xDelay’s and watched the pin with scope. But there is no difference neither with 5 nor with 500. Togglefrequency of the pin is somewhere above 10kHz.

davedoors wrote on Monday, December 12, 2011:

If an interrupt vector is used to yield a task (a yield is done inside vTaskDelay()), have you installed the interrupt handler correctly in the vector table? Maybe the handler is just using a default handler that does nothing but return right away. Have you tried stepping through the vTaskDelay() function to see what happens? It is not a long function.

patrickecr wrote on Monday, December 12, 2011:

Yes i already debugged the vTaskDelay but didn’t see anything unuasual (except it doesn’t wait :slight_smile: ).

I use the internal PIT0 (programable interrupt timer) to generate the 1ms tick. This one i checked with the function vApplicationTickHook which works well.

So i’m confused that i have to configure a second int-vector?

Is it right that during PIT-int an new interrupt is set to change task after PIT-Int? Which function should be called with the second interrupt?

Thank you for helping me!

rtel wrote on Monday, December 12, 2011:

Please read the “Resources Used by the Kernel” section on one of the ColdFire V2 documentation pages, for example:
http://www.freertos.org/Free-RTOS-for-ColdFire-MCF5222x-using-CodeWarrior.html

Regards.

patrickecr wrote on Wednesday, December 14, 2011:

I’ve got the problem.

To make the vTaskDelay work, I had to initiaize and enable another (software)interrupt which calls the vPortYieldISR.  Without this it doesn’t work.

Thank to everybody of you for help!