PHiLIP
system_stm32f1xx.c File Reference

CMSIS Cortex-M3 Device Peripheral Access Layer System Source File. More...

#include "stm32f1xx.h"

Macros

#define HSE_VALUE   8000000U
 
#define HSI_VALUE   8000000U
 
#define VECT_TAB_OFFSET   0x00000000U
 

Functions

void SystemInit (void)
 Setup the microcontroller system Initialize the Embedded Flash Interface, the PLL and update the SystemCoreClock variable. More...
 
void SystemCoreClockUpdate (void)
 Update SystemCoreClock variable according to Clock Register Values. The SystemCoreClock variable contains the core clock (HCLK), it can be used by the user application to setup the SysTick timer or configure other parameters. More...
 

Variables

uint32_t SystemCoreClock = 72000000U
 
const uint8_t AHBPrescTable [16U]
 GENERATED BY STMCUBE. More...
 
const uint8_t APBPrescTable [8U] = { 0, 0, 0, 0, 1, 2, 3, 4 }
 GENERATED BY STMCUBE.
 

Detailed Description

CMSIS Cortex-M3 Device Peripheral Access Layer System Source File.

Author
MCD Application Team
Version
V4.2.0
Date
31-March-2017
  1. This file provides two functions and one global variable to be called from user application:
    • SystemInit(): Setups the system clock (System clock source, PLL Multiplier factors, AHB/APBx prescalers and Flash settings). This function is called at startup just after reset and before branch to main program. This call is made inside the "startup_stm32f1xx_xx.s" file.
    • SystemCoreClock variable: Contains the core clock (HCLK), it can be used by the user application to setup the SysTick timer or configure other parameters.
    • SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must be called whenever the core clock is changed during program execution.
  2. After each device reset the HSI (8 MHz) is used as system clock source. Then SystemInit() function is called, in "startup_stm32f1xx_xx.s" file, to configure the system clock before to branch to main program.
  3. The default value of HSE crystal is set to 8 MHz (or 25 MHz, depending on the product used), refer to "HSE_VALUE". When HSE is used as system clock source, directly or through PLL, and you are using different crystal you have to adapt the HSE value to your own configuration.
Attention

© COPYRIGHT(c) 2017 STMicroelectronics

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

#define HSE_VALUE   8000000U

Default value of the External oscillator in Hz. This value can be provided and adapted by the user application.

#define HSI_VALUE   8000000U

Default value of the Internal oscillator in Hz. This value can be provided and adapted by the user application.

#define VECT_TAB_OFFSET   0x00000000U

< Uncomment the following line if you need to use external SRAM

< Uncomment the following line if you need to relocate your vector Table in Internal SRAM. Vector Table base offset field.

Function Documentation

void SystemCoreClockUpdate ( void  )

Update SystemCoreClock variable according to Clock Register Values. The SystemCoreClock variable contains the core clock (HCLK), it can be used by the user application to setup the SysTick timer or configure other parameters.

Note
Each time the core clock (HCLK) changes, this function must be called to update SystemCoreClock variable value. Otherwise, any configuration based on this variable will be incorrect.
- The system frequency computed by this function is not the real frequency in the chip. It is calculated based on the predefined constant and the selected clock source:
  • If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(*)
  • If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(**)
  • If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(**) or HSI_VALUE(*) multiplied by the PLL factors.

(*) HSI_VALUE is a constant defined in stm32f1xx.h file (default value 8 MHz) but the real value may vary depending on the variations in voltage and temperature.

(**) HSE_VALUE is a constant defined in stm32f1xx.h file (default value 8 MHz or 25 MHz, depending on the product used), user has to ensure that HSE_VALUE is same as the real frequency of the crystal used. Otherwise, this function may have wrong result.

  • The result of this function could be not correct when using fractional value for HSE crystal.
void SystemInit ( void  )

Setup the microcontroller system Initialize the Embedded Flash Interface, the PLL and update the SystemCoreClock variable.

Note
This function should be used only after reset.

Variable Documentation

const uint8_t AHBPrescTable[16U]
Initial value:
= { 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 6, 7,
8, 9 }

GENERATED BY STMCUBE.

uint32_t SystemCoreClock = 72000000U

< HSI Selected as System Clock source System Clock Frequency (Core Clock)