PlatformIO FreeRTOS is slower

Hi

I have observed something strange.
I have a small blinky project running on a Nucleo-H723ZG made with STM32CubeIDE and they copied to PlatformIO and the project made with PlatformIO (and using PlatformIO STM32 support) is running slower that the one in STM32CubeIDE.
I guess that the only possibility is that somehow vTaskDelay() is not working properly!
Since vTaskDelay is uses TIM6 I wonder if the Timer driver on the PlatformIO is different…

Any ideas for this?

void dmodTask (void *argument)
{
	uint32_t i=0;

	while (1)
	{
		if ( i %10 == 0 )
		HAL_GPIO_TogglePin ( LED_RED_GPIO_Port   , LED_RED_Pin    );
		if ( i %17 == 0 )
		HAL_GPIO_TogglePin ( LED_GREEN_GPIO_Port , LED_GREEN_Pin  );
		if ( i %33 == 0 )
		HAL_GPIO_TogglePin ( LED_YELLOW_GPIO_Port, LED_YELLOW_Pin );

		vTaskDelay(30);
		i++;

		if ( i % 166 == 0 )
		{
			HAL_GPIO_WritePin ( LED_RED_GPIO_Port   , LED_RED_Pin   , GPIO_PIN_RESET );
			HAL_GPIO_WritePin ( LED_GREEN_GPIO_Port , LED_GREEN_Pin , GPIO_PIN_RESET );
			HAL_GPIO_WritePin ( LED_YELLOW_GPIO_Port, LED_YELLOW_Pin, GPIO_PIN_RESET );
			vTaskDelay(1000);
		}
	}
}

PlatformIO will be using its default stm32h7xx_hal_conf_template.h which says

(see copy in C:\Users\<user>\.platformio\packages\framework-stm32cubeh7\Drivers\STM32H7xx_HAL_Driver\Inc\stm32h7xx_hal_conf_template.h)

but STM32CubeMX shows the clock config for the Nucleo board as

notice the 8MHz HSE in STM32CubeMX vs the default 25MHz HSE as the default value.

Without proper configuration via either making PlatformIO use the explicitly generated STM32Cube HAL config file (set board_build.stm32cube.custom_config_header = yes as per builder script) or explicitly setting the HSE_VALUE, the code will think it’s running on a 25MHz input clock (before PLL) when it’s actually running on a slower 8MHz clock. Thus it’s perflectly understandable that it runs 3.125 times as slow.

The easiest way to fix this is to add the macro definition in the build flags, as e.g.

build_flags =
   -DHSE_VALUE=8000000UL

(along with other possibly previously existing build flags in the list) in the platformio.ini.