I’m rather new to FreeRTOS and I have a problem.
I’m using an atmega328p with FreeRTOS 8.3.2. with 16MHz and 1000 ticks per second.
All my delays are like (x / portTICK_PERIOD_MS) where x is the delay in ms.
But when I lower the tick value, e.g. to 100 ticks per second, everything runs much faster.
I’ve read some topics about tick timing but I’m still not sure what’s wrong here.
Can you help me?
Thanks a lot
The tick frequency can only be changed at compile time. If you use the pdMS_TO_TICKS or portTICK_PERIOD_MS macros for all timing then you should be good for tick speeds up to 1KHz.
the ARDUINO_START() and ARDUINO_END() macros disable and enable the scheduler. that’s what I found as recommendation.
strange thing is that when I change to:
Its possible you are simply getting a numeric overflow as it is likely
your tick count value is only 16-bits. You could set
configUSE_16_BIT_TICKS to 0 in FreeRTOSConfig.h, which will then make
the ticks 32-bit, at some processing overhead expense as you only have
an 8-bit device.
Also, try declaring a const variable that has the delay you need, then
you will see what the value actually is. Also it will be more efficient
as the pdMS_TO_TICKS() macro will only evaluate once, rather than each
time you call vTaskDelay().
I get the correct number, e.g. 1000 with 1000 ticks per second and 100 with 100 ticks per second. but the loop speed is still faster the less ticks I have per second.
With 1000 ticks the timing is right, also in other projects.
If it helps I can upload the project as an AVR Studio solution.