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
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:
1 2 3 4 5 6 7 8 |
/* Defines for RCC settings for system */ /* I've added these defines in options for target in Keil uVision for each target different settings when using my examples */ #define RCC_OSCILLATORTYPE RCC_OSCILLATORTYPE_HSE /*!< Used to select system oscillator type */ #define RCC_PLLM 8 /*!< Used for PLL M parameter */ #define RCC_PLLN 360 /*!< Used for PLL N parameter */ #define RCC_PLLP 2 /*!< Used for PLL P parameter */ #define RCC_PLLQ 7 /*!< Used for PLL Q parameter */ #define RCC_PLLR 10 /*!< Used for PLL R parameter, available on STM32F446xx */ |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
/** * @defgroup TM_RCC_Typedefs * @brief RCC Typedefs used for RCC library for initialization purposes * @{ */ /** * @brief RCC result enumeration */ typedef enum { TM_RCC_Result_Ok = 0x00, /*!< Everything OK */ TM_RCC_Result_Error /*!< An error occurred */ } TM_RCC_Result_t; /** * @} TM_RCC_Typedefs */ /** * @defgroup TM_RCC_Functions * @brief RCC Functions * @{ */ /** * @brief Initializes system clocks * @note This function should be called on the start of main program * @note When STM32F7xx target is used, D and I caches are also enabled with this function * @param None * @retval RCC System status */ TM_RCC_Result_t TM_RCC_InitSystem(void); /** * @} */ |
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.
STM32 libraries based on STM32Fxxx HAL drivers.
Recent comments