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

vanvan
Posts: 1
Joined: Mon Sep 12, 2022 11:33 pm

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

Postby vanvan » Mon Sep 12, 2022 11:44 pm

#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);
}
}

chegewara
Posts: 2376
Joined: Wed Jun 14, 2017 9:00 pm

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

Postby chegewara » Tue Sep 13, 2022 7:09 am

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.

Who is online

Users browsing this forum: No registered users and 60 guests