F401CCU6 Clock too slow

Post here first, or if you can't find a relevant section!
Post Reply
leonardo
Posts: 18
Joined: Sat Mar 06, 2021 2:37 pm

F401CCU6 Clock too slow

Post 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 2690 times
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: F401CCU6 Clock too slow

Post 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
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: F401CCU6 Clock too slow

Post by fpiSTM »

Your code get each led OFF 2 second and ON 1s.
Is this expected ?
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

Re: F401CCU6 Clock too slow

Post 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.
leonardo
Posts: 18
Joined: Sat Mar 06, 2021 2:37 pm

Re: F401CCU6 Clock too slow

Post 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
leonardo
Posts: 18
Joined: Sat Mar 06, 2021 2:37 pm

Re: F401CCU6 Clock too slow

Post 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
Post Reply

Return to “General discussion”