Code execution time is very slow

Hello everyone, I have a core board of F401CCU6. In the first test, I lighted three rgb leds.

The interval time is 1000ms,.
but after I upload the program, the interval between the two colors is about 2000ms.
This is much slower than in my code.

  #include "Arduino.h"
  int red = 0; 
  int green = 1; 
  int blue = 2; 


  void setup()

  {

  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
  pinMode(blue, OUTPUT);
  }

  void loop()

  {
  digitalWrite(red, LOW); 

  delay(1000); 

  digitalWrite(red, HIGH); 
  digitalWrite(green, LOW); 

  delay(1000); 

  digitalWrite(green, HIGH); 
  digitalWrite(blue, LOW); 

  delay(1000); 

  digitalWrite(blue, HIGH); 

  }

Compilation results:

    Processing blackpill_f401cc (platform: ststm32; board: blackpill_f401cc; framework: arduino)
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Verbose mode can be enabled via `-v, --verbose` option
    CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/blackpill_f401cc.html
    PLATFORM: ST STM32 (12.0.0) > BlackPill F401CC
    HARDWARE: STM32F401CCU6 84MHz, 64KB RAM, 256KB Flash
    DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, stlink)
    PACKAGES: 
    - framework-arduinoststm32 4.10900.200819 (1.9.0) 
    - framework-cmsis 2.50501.200527 (5.5.1) 
    - toolchain-gccarmnoneeabi 1.90201.191206 (9.2.1)
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 18 compatible libraries
    Scanning dependencies...
    No dependencies
    Building in release mode
    Compiling .pio/build/blackpill_f401cc/src/main.cpp.o
    Linking .pio/build/blackpill_f401cc/firmware.elf
    Building .pio/build/blackpill_f401cc/firmware.bin
    Checking size .pio/build/blackpill_f401cc/firmware.elf
    Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
    RAM:   [          ]   1.4% (used 892 bytes from 65536 bytes)
    Flash: [          ]   4.1% (used 10876 bytes from 262144 bytes)

截屏2021-03-16上午12.41.01

What text is on the crystal or what does the board manifufacturer say the crystal frequency is? 25 MHz?

It could be wrong clock settings to a wrong final operating frequency of the chip.

Is the behavior the same with board = genericSTM32F401CC in the platformio.ini instead of blackpill_f401cc?

Hey,The crystal is 12mhz.
I also tried to set board = blackpill_f401cc, but the flashing time became faster, about 500ms apart

Can you please use the platformio.ini

[env:genericSTM32F401CC]
platform = ststm32
board = genericSTM32F401CC
framework = arduino
build_flags = 
   -D HSE_VALUE=12000000U

and retry.

OK,thank your suggest.