Arduino Forum

Using Arduino => Microcontrollers => Topic started by: JLLL on Jun 18, 2019, 09:06 am

Title: STM32F411 Clock Speed
Post by: JLLL on Jun 18, 2019, 09:06 am
I am trying to program my STM32F411 with Arduino IDE.

I can make delay of 1s with this code, so what is my MCU clock speed?

Code: [Select]
void delayCycle(  )
{
 uint32_t cc = 20000000;
 while ( cc-- ){
   __asm( "nop" );
 }
}
Title: Re: STM32F411 Clock Speed
Post by: Idahowalker on Jun 18, 2019, 12:24 pm
Your clock speed is equal to entering into your favorite search engine the words "STM32F411 clock speed."

Why use a noop when a delay or millis() or, with freeRTOS a vTaskDelay( ), a god choice, or vTaskDelayUntill( ), the best choice would work with the STM32F411?

vTaskDelay and vTaskDelayUntill will give delays without stopping other code from running, under freeRTOS.
Title: Re: STM32F411 Clock Speed
Post by: TFTLCDCyg on Jun 18, 2019, 05:56 pm
Inside the core oficial of STM or with generic core's like te core of danieleff, you can get the clock speed in MHz whit this:

Code: [Select]
F_CPU/1000000

For example Core7XXI (F746IG)= 216 MHz, in this case with some overclock: 256 MHz

(http://www.mediafire.com/convkey/cf7b/w7d0bl3i9a9p5smzg.jpg)
Title: Re: STM32F411 Clock Speed
Post by: FantomT on Jun 19, 2019, 12:08 am
Try this:
Code: [Select]
  Serial.print(F("\n\tSys_clock: "));
  Serial.print((uint32_t) SystemCoreClock, DEC);
   
Title: Re: STM32F411 Clock Speed
Post by: JLLL on Jun 20, 2019, 03:19 am
Thanks guys.

I try to do this and the MCU delay for exactly 2 sec.

Meaning that the while loop itself take 5 clock cycles, i thought it just take 1 clock cycle.

Code: [Select]
void delayCycle(  )
{
 uint32_t cc = 20000000;
 while ( cc-- ){
   __asm( "nop" );

   __asm( "nop" );
   __asm( "nop" );
   __asm( "nop" );
   __asm( "nop" );
   __asm( "nop" );

 }
}
Title: Re: STM32F411 Clock Speed
Post by: westfw on Jun 21, 2019, 10:05 am
No ARM chip will loop in 1 cycle, afaik.  There's always a delay while the instruction pipeline refills.
Also, faster chips will tend to have wait states inserted when accessing flash memory (usually with a poor degree of predictability, due to cache and/or other "accelerators"....