Ah. The STM32HAL needs to know your HSE speed too. So you need
[env:genericSTM32F303CC]
platform = ststm32
board = genericSTM32F303CC
framework = arduino
lib_deps = stm32duino/STM32duino FreeRTOS@^10.3.2
build_flags =
-fexceptions
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
; -D USBD_USE_CDC
-D HAL_PCD_MODULE_ENABLED
; change from default 8MHz to 32MHz
-DHSE_VALUE=32000000