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:// ...
随机推荐
- HBase笔记之namespace
一.什么是namespace 在RDBMS中有database的概念,用来对table进行分组,那么在HBase中当表比较多的时候如何对表分组呢,就是namespace,可以简单的把namespace ...
- 《区块链100问》第13集:比特币和Q币有哪些不同?
比特币是一种去中心化的数字资产,没有发行主体.Q币是由腾讯公司发行的电子货币,类似于电子积分,其实不是货币. Q币需要有中心化的发行机构,Q币因为腾讯公司的信用背书,才能被认可和使用.使用范围也局限在 ...
- requests(三):json请求中中文乱码处理
最近收到一个问题:json格式请求数据中有中文,导致服务端签名失败. 问题详情: 一位同学在发送json格式的post请求时,请求数据中有中文内容: {"inputCodes":[ ...
- lucene简介——(一)
0.概念性东西 1.数据分类
- mysql学习------MySQL慢查询日志
一.什么是慢查询日志 1.当查询超过一定时间没有返回结果的时候,才会记录进慢查询日志 2.慢查询日志可以帮助dba找出执行效率缓慢的sql语句,为数据库的优化工作提供帮助 3.慢查询日志默认是不开启的 ...
- 2018-2019-2 网络对抗技术 20165301 Exp4 恶意代码分析
2018-2019-2 网络对抗技术 20165301 Exp4 恶意代码分析 实验内容 系统运行监控 使用如计划任务,每隔一分钟记录自己的电脑有哪些程序在联网,连接的外部IP是哪里.运行一段时间并分 ...
- Intellij IDEA Debug调试技巧
1.这里以一个web工程为例,点击图中按钮开始运行web工程. 2.设置断点 3.使用postman发送http请求 4.请求发送之后会自动跳到断点处,并且在断点之前会有数据结果显示 5.按F8 在 ...
- 【LOJ】#2108. 「JLOI2015」装备购买
题解 换成long double才过--出题人丧心病狂卡精度 只要按照费用排序从小到大排序,一个个插入线性基,插入的时候加上费用即可 代码 #include <bits/stdc++.h> ...
- ubantu下如何完全彻底卸载mysql(转)
ubantu下如何完全彻底卸载mysql https://blog.csdn.net/wszll_Alex/article/details/46277681 第1步 依次执行下面的语句 1 sud ...
- 关于Sql Server的一些知识点的定义总结
数据库完整性:是指数据库中数据在逻辑上的一致性.正确性.有效性和相容性 实体完整性(Entity Integrity 行完整性):实体完整性指表中行的完整性.主要用于保证操作的数据(记录)非空.唯一 ...