Skip to main content
Rsrma.1
Associate III
Aug 26, 2020 1:03 PM UTC
Solved

Task execution time in freertos

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.
TDK
TDKBest answer
Aug 26, 2020 2:52 PM UTC

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""."

2 replies

TDK
TDKBest answer
Aug 26, 2020 2:52 PM UTC

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
Aug 27, 2020 4:41 AM UTC

Thanks, Probably this could be the reason.