http://stm32f4-discovery.com/2015/01/properly-set-clock-speed-stm32f4xx-devices/

I see that you have problems with your devices when you don’t know even

(and you don’t even ask) on which speed your device is actually running.

Speed of your device depends on PLL settings or clock source you have selected for system core clock.

In most cases system core clock’s source is PLL output.

To get proper value, you check ALWAYS first these settings when something is not working.

Because I’m tired of questions that something is not working but then your MCU clock is totally failed.

STM32F4xx series MCUs have ALL 16MHz RC oscillator inside which can be used for PLL input clock.

It is not so accurate but it works just well if you don’t have connected external clock.

External clock is probably your crystal you have connected.

In this example we will talk in case that you have external crystal connected.

If your clock is not properly set, then you have problems with everything.

USB not working, USART baudrate failed, timer’s clock not OK…

This content has only sense, if you use Standard Peripheral Drivers and not HAL drivers from ST!

To be able to get your MCU to full speed, you have to do the following changes:

  • In file stm32F4xx.h set HSE_VALUE to match your crystal frequency (In Hz)

    • In case of any STM32F4xx Discovery board, select HSE_VALUE =8000000
    • In other case, you can set this to your crystal
    • If you have an option for global defines in your compiler, then addHSE_VALUE=8000000 to your defines.
    • If you don’t use external crystal or clock, then you don’t need to change anything
  • In file system_stm32f4xx.c set PLL_M value to match your crystal frequency (In MHz)
    • In case of any STM32F4xx Discovery board, select PLL_M = 8
    • This will divide input clock with 8 to get 1MHz on the input for PLL
    • If you don’t use external clock, then this value MUST be set to 16,
      because internal RC will be used for PLL
  • Now you can expect top speed for your device.

Some informations about Nucleo boards:

  • Nucleo boards don’t use external clock by default,
    but they have pins for adding external crystal.
  • In case you don’t add external crystal or clock, then set PLL_M value to 16
  • I have at home set F401 Nucleo board with external capacitor 8MHz
    (so PLL_M is set to 8 and HSE_VALUE set to 8000000) and
    F411 without external capacitor (PLL_M set to 16)

STM32F4xx Clocks

Proper PLL settings to get maximum clocks
(except of PLL_M parameter everything should be already defined in system_stm32f4xx.c file).

SystemCoreClock = (( INPUT_CLOCK (HSE_OR_HSI_IN_HZ) / PLL_M) * PLL_N) / PLL_P

STM32F4xx MAX CLOCK
in MHz
APB1 CLOCK
in MHz </2>
APB2 CLOCK
in MHz </1>
PLL_M PLL_N PLL_P
STM32F401 84 42 84 Must match input frequency in MHz (HSE or HSI) 336 4
STM32F411 100 50 100 Must match input frequency in MHz (HSE or HSI) 400 4
STM32F405 168 42 84 Must match input frequency in MHz (HSE or HSI) 336 2
STM32F407 168 42 84 Must match input frequency in MHz (HSE or HSI) 336 2
STM32F415 168 42 84 Must match input frequency in MHz (HSE or HSI) 336 2
STM32F417 168 42 84 Must match input frequency in MHz (HSE or HSI) 336 2
STM32F427 180 45 90 Must match input frequency in MHz (HSE or HSI) 360 2
STM32F429 180 45 90 Must match input frequency in MHz (HSE or HSI) 360 2
STM32F437 180 45 90 Must match input frequency in MHz (HSE or HSI) 360 2
STM32F439 180 45 90 Must match input frequency in MHz (HSE or HSI) 360 2
STM32F446 180 45 90 Must match input frequency in MHz (HSE or HSI) 360 2

Settings for STM32F4xx boards

This settings should be used in case of any STM32F4xx boards used.

STM32F4xx MAX CLOCK
in MHz
APB1 CLOCK
in MHz
APB2 CLOCK
in MHz
DEFAULT PLL
INPUT CLOCK
PLL_M PLL_N PLL_P
STM32F401
-Discovery
84 42 84 HSE 8MHz 8 336 4
STM32F411
-Discovery
100 50 100 HSE 8MHz 8 400 4
STM32F4
-Discovery
168 42 84 HSE 8MHz 8 336 2
STM32F429
-Discovery
180 45 90 HSE 8MHz 8 360 2
Nucleo F401 84 42 84 HSI 16MHz HSE_VALUE / 1MHz in case
of external crystal or 
16 in case of internal
HSI RC oscillator
336 4
Nucleo F411 100 50 100 HSI 16MHz HSE_VALUE / 1MHz in case
of external crystal or 
16 in case of internal
HSI RC oscillator
400 4

How to properly set clock speed for STM32F4xx devices的更多相关文章

  1. IPC,Hz(Hertz) and Clock Speed

    How do we measure a CPU's work? Whether it's fast or not depends on three factors: IPC, Hz, Clock sp ...

  2. STM32F4XX devices vector table for EWARM toolchain.

    ;/******************** (C) COPYRIGHT 2015 STMicroelectronics ******************** ;* File Name : sta ...

  3. stm32F4各个库文件的作用分析

    system_stm32f4xx.c:This file contains the system clock configuration for STM32F4xx devices. /** **** ...

  4. get back to the slower clock rate that allows it to save more power

    http://www.howtogeek.com/177790/why-you-cant-use-cpu-clock-speed-to-compare-computer-performance/ Wh ...

  5. simulation clock gen unit (推荐)

    //Normal Clock Block always begin:clk_blk clk <=; # clk<=; #; end //Improved Clock Block, impr ...

  6. RFID 读写器 Reader Writer Cloner

    RFID读写器的工作原理 RFID的数据采集以读写器为主导,RFID读写器是一种通过无线通信,实现对标签识别和内存数据的读出和写入操作的装置. 读写器又称为阅读器或读头(Reader).查询器(Int ...

  7. [ZZ] GTX 280 GPU architecture

    http://anandtech.com/show/2549 Now that NVIDIA’s has announced its newest GPU architecture (the GeFo ...

  8. Debugging JTAG Connectivity Problems

    2013-12-04 22:34:26 转自:http://processors.wiki.ti.com/index.php/Debugging_JTAG_Connectivity_Problems ...

  9. RFID Reader 线路图收集

    This 125 kHz RFID reader http://www.serasidis.gr/circuits/RFID_reader/125kHz_RFID_reader.htm http:// ...

随机推荐

  1. git的权威指南

    CHENYILONG 博客 git的权威指南 全屏 © chenyilong.本站由Postach.io 博客

  2. 第13月第25天 ios11 uitableview reloaddata contentsize

    1. [tableView reloadData]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_ ...

  3. 第10月第10天 git

    1. 已经用 git commit  提交了代码. 此命令可以用来回退到任意版本:git reset --hard  commitid https://www.cnblogs.com/qufanblo ...

  4. sql 循环语句几种方式(变量循环,游标循环,事务)

    --第一   ) ,),Orders )) declare @n int,@rows int --select @rows=count(1) from pe_Orders select @rows = ...

  5. JQuery插件autocomplete使用说明文档

    项目中有时会用到ajax自动补全查询,就像Google的搜索框中那样,输入汉字或者字母的首个字母,则包含这个汉字或者字母的相关条目会显示出来供用户选择,该插件就是实现这样的功能的.autocomple ...

  6. 关于USBHID协议以及鼠标键盘描述符的解释【转】

    转自:https://blog.csdn.net/jiujiujiuqiuqiuqiu/article/details/47277685 一.HID设备识别 前面有提到关于SCSI协议的USB设备实现 ...

  7. mysql 获取当月日期天数

    本月总共天数:SELECT  TIMESTAMPDIFF(day,CURDATE(),(DATE_add(CURDATE(),INTERVAL 1 month)))

  8. ajax请求成功但不执行success-function回调函数的问题

    在success:function(data){}下面加个error:function(){},看看是不是出错了走了error.如果是,说明返回值类型不符合要求. 比如:下面代码返回String类型. ...

  9. UE没法远程修改文件

    UE没法远程修改文件修改ftp和sftp修改方式都没有作用,考虑可能是防火墙的作用,关闭防火墙可以.于是在控制面板->防火墙->修改策略中将UE的公用网络打开.

  10. fedroa20中将ssh,ssl升级到当前最新版本

    Fedroa20下手工安装openssh-server 本例以Fedroa20为例,需要下载:zlib-1.2.8.tar.openssl-1.0.2e.tar. openssh-7.1p1.tar. ...