HAL library 01- RCC for STM32Fxxx

This is first description for libraries in HAL section for STM32F4 and F7 lines using HAL drivers provided from ST for each section.

RCC (Reset and Clock Control) library is needed to set up clocks for running STM devices at high speed.

It sets up PLL parameters provided from user and enables internal or external high speed clock.

Library

Read more about new HAL libraries

Features

  • Works on STM32F0xx, STM32F4xx and STM32F7xx series
  • Enables HSE or HSI oscillator
  • Sets PLL parameters for high speed clock provided from user
  • Sets over-drive mode for devices where needed to achieve 180+ MHz clock
  • Enables Instruction and Data Cache for STM32F7xx lines

Dependencies

  • HAL
    • RCC
  • TM
    • STM32Fxxx HAL
    • defines.h

Required input parameters

In order to get library properly to work, you have to specify some parameters according to your board/settings you use in project. These settings are:

  • PLL parameters and
  • HSI or HSE clock which is used in your application

To specify parameters, I recommend you use defines.h file where you can put all your defines which are used in my libraries:

Example settings above can be used for STM32F429-Discovery board or any board which works on 180MHz clock and uses external 8MHz oscillator.

When running my examples in Keil uVision, you won’t see these settings in defines.h file. I’ve setup settings in Options for Target using global defines for each target!

Functions and enumerations

Example

There is no example for this library, because this library should be used in all project you use. This is main library and is important to set-up clock for your system.

Icon
TM STM32 Libraries

STM32 libraries based on STM32Fxxx HAL drivers.

tilz0R

Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

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!
  • Pingback: All STM32 HAL libraries - STM32F4 Discovery()

  • h.mehrabian

    Two question,
    1. In stm32f4xx_hal_rcc.h , in defgroup RCC_System_Clock_Source System Clock Source,
    I’ve understand the definition of RCC_SYSCLKSOURCE_PLLCLK, but confusing about RCC_SYSCLKSOURCE_PLLRCLK?
    2. What kind of registry is used for RCC_System_Clock_Type System Clock Type ?
    (System Clock Type and System Clock Source!!!!!???? )

    • Just calm down first. There is no need for so many question marks in questions.

      Some devices, F446 for examples, have additional PLLR parameter for other peripherals. This clock can also be selected as main clock.

      What are options for clk type?

      • h.mehrabian

        No, i mean what is the definition for RCC_CLOCKTYPE_PCLK1 and RCC_CLOCKTYPE_PCLK2?
        it’s for APB1 nad APB2?

  • h.mehrabian

    Hi, have seen a mistake in HAL library?

    I was evaluating HAL example for STM324x9I_EVAL in TIM_Prescaler_Selection,

    the Comment passage says that TIM3CLK = 4 * PCLK1.

    In my CubeMx soft. , PCLK1 can just multiply with 2 that this number is constant and Unchangeable. What’s my wrong?

    • I’m not using CubeMX because it is useless.
      TIM3 is connected to PCLK1 probably, so it’s clocking speed is 2* PCLK1 on F439-Eval boards.

      • h.mehrabian

        Good treatment, now i understand CubeMX has a bug.

        When u set the TIMPRE in RCC_DCKCFGR register, according to datasheet, the multiplication change to defined number. However, there is no changing in CubeMX .

        I’m just using this software for Clock configuration map.