cancel
Showing results for 
Search instead for 
Did you mean: 

Task execution time in freertos

Rsrma.1
Associate III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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

View solution in original post

2 REPLIES 2
TDK
Guru

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
Associate III

Thanks, Probably this could be the reason.