STM32 system_stm32f10x.c file analysis

Publisher:MysticalGardenLatest update time:2018-06-18 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In the startup_stm32f10x_md.s file, a function called SystemInit is called. This function is actually defined in system_stm32f10x.c. It is designed to initialize the system clock, initialize the external SRAM, and set the interrupt vector table address.


void SystemInit (void)
{
  /* Enable internal high-speed clock */
  RCC->CR |= (uint32_t)0x00000001;


#ifndef STM32F10X_CL
  RCC->CFGR &= (uint32_t)0xF8FF0000;
#else
  RCC->CFGR &= (uint32_t)0xF0FF0000;
#endif
  
  /* Disable PLL, disable initial clock detection, disable external high-speed clock */
  RCC->CR &= (uint32_t)0xFEF6FFFF;

  /* External 1-25M oscillator is not bypassed */
  RCC->CR &= (uint32_t)0xFFFBFFFF;

  /* USB prescaler PLL is not divided, PLL multiplier is 2, HSE is not divided, HSI/2 is used as PLL frequency */
  RCC->CFGR &= (uint32_t)0xFF80FFFF;


/* Disable clock interrupt register */

#ifdef STM32F10X_CL
  RCC->CR &= (uint32_t)0xEBFFFFFF;

  RCC->CIR = 0x00FF0000;

  RCC->CFGR2 = 0x00000000;
#elif defined (STM32F10X_LD_VL) || defined (STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
  RCC->CIR = 0x009F0000;

  /* Reset CFGR2 register */
  RCC->CFGR2 = 0x00000000;      
#else
  RCC->CIR = 0x009F0000;
#endif /* STM32F10X_CL */
    

/* 设置外部SRAM */
#if defined (STM32F10X_HD) || (defined STM32F10X_XL) || (defined STM32F10X_HD_VL)
  #ifdef DATA_IN_ExtSRAM
    SystemInit_ExtMemCtl(); 
  #endif /* DATA_IN_ExtSRAM */
#endif


 /* Configure system clock */
  SetSysClock();


/*Interrupt vector offset address setting*/

#ifdef VECT_TAB_SRAM
  SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
#else
  SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
#endif 
}


Keywords:STM32 Reference address:STM32 system_stm32f10x.c file analysis

Previous article:Learning STM8 SPI
Next article:STM32 clock configuration, the program required to configure different crystal oscillators

Recommended ReadingLatest update time:2024-11-23 15:14

STMicroelectronics launches industrial smart sensor evaluation kit
Accelerate application design based on IO-Link transceivers and STM32 MCUs China, December 15, 2021 - Featuring a slim 45.8mm x 8.3mm motherboard, the STMicroelectronics STEVAL-IOD04KT1 industrial sensor kit simplifies the development of compact IO-Link (IEC 61131-9) sensors for fieldbus-independent p
[sensor]
STMicroelectronics launches industrial smart sensor evaluation kit
What is the maximum input current and output drive current of the STM32 IO port?
The maximum output is 8mA and the input is 20mA, but the current entering the chip VDD must not exceed 150mA, and the current flowing out of VSS must not exceed 150mA. For details, please refer to the relevant content in the STM32 data sheet. For example, for the STM32F103 medium-capacity product, you need to refer
[Microcontroller]
What is the maximum input current and output drive current of the STM32 IO port?
Summary of problems in PWM wave generation of STM32
Using STM32F103RC Question: The calculation result of PWM duty cycle is correct, but the output is wrong. The motor of Xinxida cannot be unlocked because the function of register is not understood. #include "tim2_pwm.h" #include "stm32f10x_tim.h" void Init_GPIO(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB
[Microcontroller]
The location of interrupt source name and interrupt processing function name in stm32
The two files are respectively in stm32f4xx.h (interrupt name) CORE—startup_stm32f40_41xxx.s (interrupt function name) #if defined (STM32F40_41xxx)   CAN1_TX_IRQn = 19, /*! CAN1 TX Interrupt */   CAN1_RX0_IRQn = 20, /*! CAN1 RX0 Interrupt */   CAN1_RX1_IRQn = 21, /*! CAN1 RX1 Interrupt */   CAN1_SCE_IRQn = 22, / *!
[Microcontroller]
STM32 GPIO pin mode configuration
In the STM32 microcontroller, GPIO pins can be configured into more modes, which will be introduced in this article. 1. Input/Output Mode   2. Output Mode   In GPIO output mode, the differences in several speeds are: (1). GPIO pin speed:   There are three main GPIO pin speeds: 2MHz, 10MHz, and 50MHz.
[Microcontroller]
Simple implementation of STM32 SPI interface
Usually SPI is connected to external devices through 4 pins: ● MISO: Master input/slave output pin. This pin sends data in slave mode and receives data in master mode. ● MOSI: Master output/slave input pin. This pin sends data in master mode and receives data in slave mode. ● SCK: serial port clock, output of the
[Microcontroller]
STM32's understanding of priority setting NVIC_SetPriority()
The function for setting the module interrupt priority in the Systick module initialization configuration function (Systick_config) is: NVIC_SetPriority((SysTick_IRQn, (1 __NVIC_PRIO_BITS) - 1); The parameter SysTick_IRQn is the systick base address, there is nothing much to say about this The key is the paramet
[Microcontroller]
STM32 boot mode and IAP
When we play with ARM9, we usually debug the program in the memory, which is very fast. This can also be done with   STM32. Although the life of flash is very long now, debugging and burning programs in flash is still a very slow process. Sometimes a small change in the program takes several times longer to download t
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号