Page 1 of 1

F401CCU6 Clock too slow

Posted: Mon Mar 15, 2021 4:51 pm
by leonardo
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.

Code: Select all

#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

Code: Select all

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.png
截屏2021-03-16上午12.41.01.png (38.56 KiB) Viewed 2775 times

Re: F401CCU6 Clock too slow

Posted: Mon Mar 15, 2021 5:26 pm
by ag123
the code looks ok, among the things you may like to check if you are running at the expected system clock speeds for your board. that would have something to do with the crystal frequency

Re: F401CCU6 Clock too slow

Posted: Mon Mar 15, 2021 5:32 pm
by fpiSTM
Your code get each led OFF 2 second and ON 1s.
Is this expected ?

Re: F401CCU6 Clock too slow

Posted: Mon Mar 15, 2021 5:42 pm
by fredbox
Test delay() speed by blinking a single LED.
Also, keep in mind that your LED is on when the pin is low.

Chances are that your code is doing exactly what you have told it to do and there is no issue with timing.

Re: F401CCU6 Clock too slow

Posted: Tue Mar 16, 2021 12:34 am
by leonardo
ag123 wrote: Mon Mar 15, 2021 5:26 pm the code looks ok, among the things you may like to check if you are running at the expected system clock speeds for your board. that would have something to do with the crystal frequency
Hey,The crystal is 12mhz.
I also tried to set board = blackpill_f401cc, but the flashing time became faster, about 500ms apart

Re: F401CCU6 Clock too slow

Posted: Tue Mar 16, 2021 12:47 am
by leonardo
fpiSTM wrote: Mon Mar 15, 2021 5:32 pm Your code get each led OFF 2 second and ON 1s.
Is this expected ?
yeah,A total of three three-color leds.
When the pin is low, the LED will on.
Therefore, when one LED is turned on, the other two LEDs need to be kept off