Page 1 of 1

Im trying to print the real time delay results of vTaskDelay .... is this code and the results ok?

Posted: Mon Sep 12, 2022 11:44 pm
by vanvan
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
void app_main(void)
{
float mesurment;
int first_time;
int second_time;
for (int i = 10; i < 150; i+=10)
{
printf("\n===========\ntime accuracy for %d miliseconds delay\n",i);
first_time=esp_timer_get_time();
vTaskDelay(i/portTICK_RATE_MS);
second_time=esp_timer_get_time();
mesurment=second_time-first_time;
printf("Real mesured time results for %dms delay is: %fms\n===========",i, mesurment/1000);
}
}

Re: Im trying to print the real time delay results of vTaskDelay .... is this code and the results ok?

Posted: Tue Sep 13, 2022 7:09 am
by chegewara
is this code and the results ok?
Yes, and probably not.
Assuming you are using default menuconfig values, you probably have freertos scheduler is running with 100Hz.
Try this:

Code: Select all

printf("Real mesured time results for %dms delay is: %fms\n===========",i, mesurment / portTICK_RATE_MS);
Also there is one more thing. printf and other UART functions are time consuming and adding additional delay in your code. For that reason most of them cant be used inside ISR.