Lib to switch the clock speed of the ST Nucleo to 84MHz. The internal RC oscillator is multiplied with the PLL.

Dependents:   Nucleo_spi_master_20MHz Nucleo_vs_Arduino_Speed_Test DMA_I2S_Test MPU9150AHRS ... more

Not needed with actual mbed lib

You don't need this lib to speed up the cpu clock. The actual mbed lib is using 84 MHz cpu speed out of the box.

The ST Nucleo board is running on 16 MHz out of the box. To speed up the cpu to the maximum speed we have to change the clock setting. Simply add

          #include "ST_F401_84MHZ.h" 
          F401_init84 myinit(0); 

in front of your program. This should be the first line in main to ensure the frequency is changed before other objects are initialised.

This frequency is generated out of the internal RC oscillator. The frequency is not so stable like a crystal ! My board is fluctuate +- 40KHz at 84MHz at room temperature.

/media/uploads/dreschpe/cubemx1.png

If you need a more precise timing source, you have to add a external crystal. /media/uploads/dreschpe/oszillator.jpg

You need : X3 8MHz crystal , C33 and C34 18pF 0603 , R35 and R37 0R 0603 or you can simply use wire to short this two resistor pads. A call of SystemClock_Config_84MHz_external(); will config the pll to generate 84MHz out of the 8MHz crystal oscillator.

/media/uploads/dreschpe/cubemx2.png

Add

          #include "ST_F401_84MHZ.h" 
          F401_init84 myinit(1); 

in front of your code to use the external 8MHz crystal.

If you want to use a different crystal or frequency : the STM32CubeMX tool is your friend :-)

external crystal value

The mbed lib is using HSE_VALUE defined in the file stm32f4xx_hal_config.h to calculate SystemCoreClock, which is used for all timings : baudrate or wait() ... This value is the frequency of the external crystal. It is defined to 25MHz at the moment I have asked to change it to 8MHz default. You can set the variable SystemCoreClock to 84000000 to patch this . If you use the internal oscillator the calculated value is ok The value was changed to 8 MHz.

Committer:
dreschpe
Date:
Tue Apr 08 20:00:49 2014 +0000
Revision:
6:b9343c8b85ec
Parent:
5:f44655076466
DeInit PLL before setting new parameter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 5:f44655076466 1 /* mbed library for the ST NUCLEO board F401RE
dreschpe 5:f44655076466 2 * to change the CPU clock to 84 MHz
dreschpe 5:f44655076466 3 *
dreschpe 5:f44655076466 4 * Copyright (c) 2014 Peter Drescher - DC2PD
dreschpe 5:f44655076466 5 * Released under the MIT License: http://mbed.org/license/mit
dreschpe 5:f44655076466 6 *
dreschpe 5:f44655076466 7 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dreschpe 5:f44655076466 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dreschpe 5:f44655076466 9 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
dreschpe 5:f44655076466 10 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dreschpe 5:f44655076466 11 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
dreschpe 5:f44655076466 12 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
dreschpe 5:f44655076466 13 * THE SOFTWARE.
dreschpe 5:f44655076466 14 */
dreschpe 0:e54167eaccc6 15 #ifndef MBED_ST_F401_84MHZ_H
dreschpe 0:e54167eaccc6 16 #define MBED_ST_F401_84MHZ_H
dreschpe 0:e54167eaccc6 17
dreschpe 5:f44655076466 18 /** Setup speed to 84 MHz
dreschpe 5:f44655076466 19 *
dreschpe 5:f44655076466 20 * @code
dreschpe 5:f44655076466 21 * #include "mbed.h"
dreschpe 5:f44655076466 22 * #include "ST_F401_84MHZ.h"
dreschpe 5:f44655076466 23 *
dreschpe 5:f44655076466 24 * // place the init before other code to ensure right timing of other objects !
dreschpe 5:f44655076466 25 * F401_init84 myinit(0); // use the internal oscillator
dreschpe 5:f44655076466 26 *
dreschpe 5:f44655076466 27 */
dreschpe 5:f44655076466 28
dreschpe 5:f44655076466 29 class F401_init84
dreschpe 5:f44655076466 30 {
dreschpe 5:f44655076466 31 public:
dreschpe 5:f44655076466 32 /** Create a F401_init84 object to change the clock
dreschpe 5:f44655076466 33 * @param external = 0 use internal oscillator
dreschpe 5:f44655076466 34 * @param external = 1 use external 8 MHz crystal - you have to add some comonents to the pcb !
dreschpe 5:f44655076466 35 */
dreschpe 5:f44655076466 36 F401_init84(unsigned int external);
dreschpe 5:f44655076466 37
dreschpe 5:f44655076466 38 protected:
dreschpe 5:f44655076466 39 // do the magic ;-)
dreschpe 5:f44655076466 40 void SystemClock_Config_84MHz_internal(void);
dreschpe 2:e5c1060ec62d 41 void SystemClock_Config_84MHz_external(void);
dreschpe 5:f44655076466 42 };
dreschpe 0:e54167eaccc6 43
dreschpe 0:e54167eaccc6 44 #endif