How to properly set clock speed for STM32F4xx devices
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的更多相关文章
- 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 ...
- STM32F4XX devices vector table for EWARM toolchain.
;/******************** (C) COPYRIGHT 2015 STMicroelectronics ******************** ;* File Name : sta ...
- stm32F4各个库文件的作用分析
system_stm32f4xx.c:This file contains the system clock configuration for STM32F4xx devices. /** **** ...
- 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 ...
- simulation clock gen unit (推荐)
//Normal Clock Block always begin:clk_blk clk <=; # clk<=; #; end //Improved Clock Block, impr ...
- RFID 读写器 Reader Writer Cloner
RFID读写器的工作原理 RFID的数据采集以读写器为主导,RFID读写器是一种通过无线通信,实现对标签识别和内存数据的读出和写入操作的装置. 读写器又称为阅读器或读头(Reader).查询器(Int ...
- [ZZ] GTX 280 GPU architecture
http://anandtech.com/show/2549 Now that NVIDIA’s has announced its newest GPU architecture (the GeFo ...
- Debugging JTAG Connectivity Problems
2013-12-04 22:34:26 转自:http://processors.wiki.ti.com/index.php/Debugging_JTAG_Connectivity_Problems ...
- RFID Reader 线路图收集
This 125 kHz RFID reader http://www.serasidis.gr/circuits/RFID_reader/125kHz_RFID_reader.htm http:// ...
随机推荐
- 【译】使用OpenVAS 9进行漏洞扫描
本文译自Vulnerability Scanning with OpenVAS 9 part 1: Installation & Setup系列,本文将融合目前已经发表的四个部分. Part ...
- C型USB能阻止危险充电器通过USB传播恶意软件
C型USB能阻止危险充电器通过USB传播恶意软件 C型USB设备(USB Type-C)的新型身份验证协议可以保护用户免受潜在的充电器损坏的风险,这种新型的USB还能减少被恶意软件的风险.基于密码的认 ...
- blockchain 名词解释
1.UTXO UTXO是比特币交易的基本单位UTXO(Unspent Transaction Outputs)是未花费的交易输出,它是比特币交易生成及验证的一个核心概念.交易构成了一组链式结构,所有合 ...
- Linux umount的device is busy问题
现象: [root@dbserver ~]# df -h文件系统 容量 已用 可用 已用%% 挂载点/dev/vda1 9.9G 3.9G 5.6G 41% /tmpfs 3.9G 100K 3.9G ...
- Gitlab & Github
windwos上Git的使用 软件下载地址:https://github.com/git-for-windows/git/releases/download/v2.15.1.windows.2/Git ...
- redis,nodejs,php,pub/sub 实战: 微信语音识别
2015年5月22日 20:20:20 星期五 效果: 这边对微信说话, 浏览器端及时显示语音识别的文字 注意: 在连接socket.io时, 按下浏览器f12, 如果一直有请求不断的刷, 说明so ...
- 环境变量GOPATH使用试验
Intel Core i5-8250U,Windows 10家庭中文版,Visual Studio Code 1.26.1 中午的时候,自己把环境变量GOBIN给清空了.刚刚继续工作时发生了异常:使用 ...
- 开源整理:Android App新手指引开源控件
开源整理:Android App新手指引开源控件 一个App第一次与用户接触或者发生大版本更新时,常常会用户进行新手引导,而一个好的新手指引,往往能够方便新用户快速了解操作你的应用功能.新手指引的重要 ...
- 测试开发之Django——No2.Django的安装以及项目创建
开发平台:Mac Python版本:3.7 Django版本:2.0.5 一.Django的安装 1.pip安装 输入命令pip install Django==2.0.5 说明:不指定版本,则安装的 ...
- Explain之key_len长度计算
以前我很好奇通过执行计划Explain去分析SQL的时候看到的key_len值有时很小,有时看到很大,那时也不知道它是怎么算出来的,现在终于搞懂了,嘻.因为网上对key_len的长度的计算的资料也很少 ...