Skip to main content
Rsrma.1
Associate III
August 26, 2020
Solved

Task execution time in freertos

  • August 26, 2020
  • 2 replies
  • 2213 views

I'm using freertos on stm32f407vg Discovery board. I'm running system at 150MHz.

I want to calculate time taken by a task for that below is the code snippet.

 TickType_t initial_time = 0, end_time = 0,diff = 0;
	initial_time = xTaskGetTickCount();
 
	while(1)
	{
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_SET);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_SET);
		vTaskDelay(1000);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_RESET);
		HAL_GPIO_WritePin(GPIOD, GPIO_PIN_14, GPIO_PIN_RESET);
 
		end_time= xTaskGetTickCount();
		diff = end_time - initial_time;
	}

I'm getting difference value = 1000 , which is the value of delay. So should I understand that freertos don't count time taken by a other instructions or I'm missing something. Please clarify.

This topic has been closed for replies.
Best answer by TDK

Ticks are in increments of 1ms. Likely the other code is executing in way less than 1ms and so doesn't make an impact.

2 replies

TDK
TDKAnswer
Super User
August 26, 2020

Ticks are in increments of 1ms. Likely the other code is executing in way less than 1ms and so doesn't make an impact.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Rsrma.1
Rsrma.1Author
Associate III
August 27, 2020

Thanks, Probably this could be the reason.