for( ; ; ) {
LED_Toggle(LED4);
vTaskDelay(1000);
}
}
This task is triggered every two seconds instead of one second (as intended by vTaskDelay(1000)). I did not make any changes to the code, configCPUCLOCKHZ is set as 1000.
Can anyone verify if this is true or point out the direction which I should be looking to check for sysTick rate?
Thanks
FreeRTOS tick interrupt not accurate
Hi,
I’m new to embedded RTOS and I have encountered an issue where vTaskDelay() is not accurate.
i’m running a “FreeRtos Sam Example” project on Atmel Studio (SAME70 Board) that blinks the LED at a fixed rate.
led task code as follows:
static void task_led(void *pvParameters)
{
UNUSED(pvParameters);
FreeRTOS tick interrupt not accurate
You code looks Ok.
So what you observe is a LED that is on for 2 seconds, and then off for 2 seconds?
I would check the clocks of the SAME70 at start-up: is it assuming a correct speed of the X-tal? Is the processor running at the expected speed?
FreeRTOS tick interrupt not accurate
The value of configCPUCLOCKHZ looks suspicious. Are you using the
SysTick clock to generate tick interrupts? If so I would expect it to
be in the MHz range, not 1Khz.
FreeRTOS tick interrupt not accurate
Maybe the following helps:
configCPU_CLOCK_HZ
is the clock rate of the CPU, up to 300 MHz for SAM E70
configSYSTICK_CLOCK_HZ
is the clock rate that feeds the systick, possibly the same as configCPU_CLOCK_HZ
configTICK_RATE_HZ
is the desired FreeRTOS tick rate, which you will put to 1000
For SAME70, the systick is initialised in portable/gcc/ARM_CM7/r0p1/port.c
in the function vPortSetupTimerInterrupt()
Could you check these defines and find-out the logic?
I think that:
~~~
define configCPUCLOCKHZ ( SystemCoreClock )
~~~ could you check or print the actual value ofSystemCoreClock
?
FreeRTOS tick interrupt not accurate
Thanks for the replies.
@RichardBarry my mistake, i meant configTICKRATEHZ = 1000.
@Hein Tibosch yes that is correct, the LED is on for 2 seconds then off for 2 seconds.
i ran a demo project without FreeRTOS (same board config settings) , no issue with tick timing. LED swtiched on for 1 second and off for 1 second.
same70_xplained.h
/#define BOARD_MCK 300000000UL
freeRTOSconfig.h
checking on the settings, i noticed that:
/#define configCPUCLOCKHZ (BOARD_MCK << 1UL)
seems like freeRTOSconfig.h defines the configCPUCLOCKHZ, in this case to 600MHz.
changing this value to 300MHz resulted in the correct tick rate.
I am not sure what is the reason for the left shift bit, can i assumed that it will be alright for me to just #define configCPUCLOCKHZ BOARD_MCK ?
just for fun (thinking why the rate will be slower at 600MHz), I tested it with 150MHz and it resulted in a faster tick rate (0.5s). Would you happen to have any explanation as to why lowering the CPU clock rate resulted in a faster tick rate?