Library 40- Output clocks from STM32F4

STM32F4 has capability to output different clocks on specific 2 pins. You are able to output clocks in original frequency (no prescaler) and also with prescaler values 2, 3, 4 and 5.

2 pins are used to output different frequencies. They are not able to output the same clocks. You can output:

  • MCO1
    • HSI: High Speed Internal oscillator, 16MHz RC
    • HSE: High Speed External oscillator, or External User clock
    • LSE: Low speed, 32768Hz oscillator or ceramic resonator
    • PLLCLK: Output clock from PLL
      • Differ between settings for PLL
  • MCO2
    • SYSCLK: System core clock output
    • PLLI2SCLK: Accurate clock for high-quality audio performance in I2S and SAI interfaces
    • HSE: High Speed External oscillator, or External User clock
    • PLLCLK: Output clock from PLL
      • Differ between settings for PLL

Each clock can be output with no prescaler, or value between 2 – 5.

Library

Features

  • Output different system clocks from STM32F4
  • 2 output pins supported

Depedencies

  • CMSIS
    • STM32F4xx
    • STM32F4xx RCC
    • STM32F4xx GPIO
  • TM
    • TM GPIO
    • defines.h
STM32F4xx MCOx Description
PA8 MCO1 MCO1 output pin
PC9 MCO2 MCO2 output pin

Functions and enumerations

Example

Example below outputs:

  • HSI clock on pin MCO1 (PA8) with prescaler 2 = 16MHz / 2 = 8MHz
  • SYSCLK clock on pin MCO2 (PC9) with prescaler 4
    • On STM32F4-Discovery = 168MHz / 4 = 42MHz
    • On STM32F429-Discovery = 180MHz / 4 = 45MHz
    • On Nucleo F401RE = 84MHz / 4 = 21MHz

Project is available on Github, download library below.

tilz0R

Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!