[STM32 study Note 1] Firmware Library-based mega_mdk Engineering Template

Source: Internet
Author: User

The article includes the introduction of the STM32 Firmware Library and the construction of engineering templates.

I. Introduction to STM32 Firmware Library

To create a project template, you must first understand the STM32 Firmware Library. You can download the STM32 firmware from the official ST website.

 

To better understand this folder, we can expand the Libraries folder, as shown in 2. The CMSIS folder provides support for Cortex M3 of STM32F10x series chips. Under documentation, A cmsis_core.htm file describes Cotex Microcontroller Software Interface Standard (CMSIS ). Two folders under the CM3 folder, in CoreSupport, are the general source file core_cm3.c for the M3 core located in the function layer of the CMSIS standard kernel device, and the header file core_cm3.h, their role is to provide an interface for chip peripherals designed by chip vendors that use Cortex-M3-core SOC to enter the M3 kernel, and the two files are the same in other companies. Another folder contains the file STM32F10x. h of the DPAL header file of the device access layer written for the stm32f10x family MCU and the file system_0000fx.h of the dpals System of the device access layer.

(1) stm32f10x. h

Stm32f10x. h Includes all the peripheral register definitions and bit definitions of the STM32F10x series processor and memory ing of different capacities of STM32F10x. Here, we emphasize that if you use a peripheral library for programming, you must write STM32F10X_HD and USE_STDPERIPH_DRIVER in the Define Of The PreProcessor Symbols of the compiler, because it is in stm32f10x. h has two judgment statements. If not defined, an error is returned.

! Defined (STM32F10X_LD )&&! Defined (STM32F10X_LD_VL )&&! Defined (STM32F10X_MD )&&! Defined (STM32F10X_MD_VL )&&! Defined (STM32F10X_HD )&&! Defined (STM32F10X_HD_VL )&&! Defined (STM32F10X_XL )&&! Defined (STM32F10X_CL) "Please select first the target STM32F10x device used in your application (in stm32f10x. h file )"STM32F10X_HD! Defined USE_STDPERIPH_DRIVERUSE_STDPERIPH_DRIVER

(2) system_stm32f10x

System_stm32f10x.c is provided by ST and complies with CMSIS standards. The function of this file is to set the system clock and bus clock. System_stm32f10x.c uses the PLL when implementing the system clock. This requires the operation register, which is accessed by memory ing. Therefore, this file contains the stm32f10x. h.

(3) startup Folder

The startup Folder compiles the startup assembly code based on different compiling environments. These assembly files are differentiated based on chips with different memory capacities and selected based on their chips. The abbreviation of a file name is as follows:

Cl: interconnected product, stm32f105/107 Series

Vl: value-added products, stm32f100 Series

Xl: Ultra-high density (capacity) product, stm32f101/103 series

Ld: low-density product, FLASH less than 64 K

Md: medium density product, FLASH = 64 or 128

Hd: high-density product with FLASH greater than 128

(4) STM32F10x_StdPeriph_Driver folder

The Libraries \ STM32F10x_StdPeriph_Driver folder contains the inc (include abbreviation) and src (source abbreviation) folders, which both belong to the device peripheral function of CMSIS. The src contains drivers for each device's peripherals, which are added by chip manufacturers in the Cortex-M3 core.

To better understand the relationship between various files in the STM32F10xxx standard peripheral library, we plot its architecture, as shown in 3. The figure shows the links between different layers and specific files. Table 2 shows the specific functions of each file.

Ii. Build an STM32 Project template

  (1) create a folder

Create a folder Template and create four folders under the folder, as shown in 4.

(2) Copy database files

Copy the firmware library files described in section 1 to the folder shown in.

The method for creating a project is not described in detail. The key description file is added. 6. Right-click Target1 and Click Manage Componets. Change the Project name to Temp. in Groups, create three folders: Project, CORE, and FWLIB. add files to each folder ~ 9.

# Include main ((}Main

(5) EDIT Target Options

Click the magic wand, Select Output, and Select the OBJ Folder created in step 1 in Select Folder for Objects, as shown in figure 10.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.