I have a task that keeps printing some characters in an infinite loop and I have implemented a delay before each printing iteration using vTaskDelayUntil, but for some reason the delay isn’t working properly.
this is how I specify the vTaskDelayUnti parameters.
xTaskCreate(print, (const signed char*) "print", 1024, NULL, 3, &printH);
The screen shot below shows the output that I got. The characters do not follow the delay specified initially, and when it reaches the part where it looses the character E it starts to follow the delay specified.
Any idea for why the vTaskDelayUntil is not working in a propper way would be appreciated.
First, the code as written can’t be exactly what you are using, as print has the wrong from for a task function, and thus the xTaskCreate should throw an error, task functions MUST have the prototype like:
void taskfun(void* ptr)
but your print takes no parameters.
A second note is that you don’t show the context of how you declare and initialize your wakeTime variable. I can’t think of any way to have those two lines as shown be next to each other and work, except as part of the task function, but they are shown outside of it apparently as some global statement. The decleration could be a global (and if not inside the task function it would need to be), but the assignment can not.
One possible source of your issue would be if the assignment occured well before the task started, in which case the define properties of vTaskDelayUntil is to not delay until the loop ‘caught up’ to the right number of loops. Typically, the initialization of the wakeup time variable (and the decleration of it) is just before the loop itsef, inside the task.
How are you printing out the characters. In particular, is your
debugger set to use semihosting? If so that could be the problem. Try
with semihosting turned off. Also try removing the print statement
completely and instead just toggling an LED and measure the toggle
frequency to see if it is ok provided the print function is not called.
I am using a preprogrammed IDE, that was bought with the microprocessor we are working on and unfortunatly I can’t change toggle semihosting neither on or off.
I have also tried to toggle an LED with a delay of 5000 ticks, yet the toggle frequency is not ok.
I also want to add that a few days ago the taskDelayUntil() was working fine and I didn’t change any settings, all I did is turn off my laptop.
I am using a preprogrammed IDE, that was bought with the microprocessor we are working on and unfortunatly I can’t change toggle semihosting neither on or off.
I have also tried to toggle an LED with a delay of 5000 ticks, yet the toggle frequency is not ok.
I also want to add that a few days ago the taskDelayUntil() was working fine and I didn’t change any settings, all I did is turn off my laptop.
Can you tell exactly what you observe? Is it too slow, too fast, or irregular? How much too slow or fast? When does it become irregular?
well it starts very slow, but later on it goes into the expected delay period. The point where it changes and goes to the expected delay period is seen in the screen shot I provided (It is where a character gets missing).
Is your application only running a single task?
It is running a single task with the priority of 3 and a stack depth of 1024.
Can you tell what processor it is, and what kind of IDE?
processor is: ARM9 (AT91SAM9G20)
IDE: Eclipse Kepler Service Release 2
OS: freeRTOS v7.5.3
Fixed the quotation mess that I did. And sorry I am still new to this forum.
Can you tell exactly what you observe? Is it too slow, too fast, or irregular? How much too slow or fast? When does it become irregular?
well it starts very slow, but later on it goes into the expected delay period. The point where it changes and goes to the expected delay period is seen in the screen shot I provided (It is where a character gets missing).
Is your application only running a single task?
It is running a single task with the priority of 3 and a stack depth of 1024.
Can you tell what processor it is, and what kind of IDE?
processor is: ARM9 (AT91SAM9G20)
IDE: Eclipse Kepler Service Release 2
OS: freeRTOS v7.5.3