当前位置:网站首页>Blue Bridge Cup embedded_ STM32_ New project file_ Explain in detail
Blue Bridge Cup embedded_ STM32_ New project file_ Explain in detail
2022-07-06 01:44:00 【Moqim Flourite.】
notes : This learning is based on the wildfire learning video , It is recommended to watch all videos before the firmware library , To lay a good foundation . See Wildfire Forum .
( Because it still needs some foundation of wildfire , I will first write it according to the logic I understand , Students who don't understand recommend finishing the video about register to firmware library )
Guess firmware library
According to what we have learned 51 Single chip microcomputer , You can infer which files will be included in the firmware library .
( The following conjecture comes from Wildfire )
1、 Compile the startup file
Starup_stm32f10x_hd.s: Set stack pointer 、 Set up PC The pointer 、 Initialize interrupt vector table 、 Configure the system clock 、 call C Library function _main Finally go to C The world of ;
2、 Clock configuration file
system_stm32f10x.c: Put the external clock HSE=8M, after PLL Frequency doubling is 72M;
3、 Peripheral related
stm32f10x.h: Implement the register mapping of peripheral devices outside the kernel ;
xxx:GPIO、USRAT、I2C、SPI、FSMC;
stm32f10x_xx.c: Peripheral driver library file ;
stm32f10x_xx.h: The initialization structure used to store peripherals , The peripheral initializes the parameter list of structure members , Declaration of peripheral firmware library function ;
4、 Kernel dependent
CMSIS - Cortex Microcontroller software interface standard ;
core_cm3.h: Implement the register mapping of peripherals in the kernel ;
core_cm3.c;
NVIC( Nested vector interrupt controller )、SysTick( System ticking timer )
misc.h;
misc.c;
5、 Configuration file of header file
stm32f10x_conf.h: Header file of header file ( Header file that contains all peripheral header files );
6、 Dedicated to storing interrupt service functions C file
stm32f10x_it.c;
stm32f10x_it.h;
Understand the firmware library
Open the firmware library file in the match point resource package ——
There's a path on it ( In fact, it was a folder at the beginning , Just click crazy ).
After opening, we can see four folders ——
( picture source : Wildfire )
In the first folder are several icons , Don't worry about him ;
The second folder is the library source code and startup files , The library file we want to call is right here ;
In the third folder is the routine of the official evaluation version , We can copy the configuration code inside , By modifying parameters to achieve the functions we need , It is convenient for us to quickly configure code ;
The fourth file is the library usage help document , You can look at it , But he is all English .
understand Libraries Folder
Open the second folder Libraries——
There are two folders in it :CMSIS,STM32F10x_StdPeriph_Driver.
Through the name, we can know that the first one is the kernel file , The second is the peripheral driver file .
(CMSIS - Cortex Microcontroller software interface standard )
(Peripheral peripherals ,Driver The driver )
understand CMSIS Folder
Let's open it first CMSIS Folder ——
Other documents are useless , Let's continue to drive CM3 Folder ——
( It's useless because ... Ah, this , How to put it? , These files cannot be called in the program , If you are interested, just take a look )
Here is a brain diagram .( Brain map is made with reference to wildfire )
Select ARM Because we are ARM As the core board ;
choose md The startup file is because the Blue Bridge Cup is STM32F103RBT6 The board of ,R yes 64 One pin ,B yes 128K,T yes QFR encapsulation ,6 Is the operating temperature -40-85 Centigrade .
For details, please refer to this blog @chiaixian2107-STM32F103RBT6 Model description .
( I'm not referring to this blog , I remember it before )
( source : Chapter 1 of Chinese version of reference data 1.2 The glossary )
According to the official explanation , We knew we should choose md Medium capacity .
understand STM32F10x_StdPeriph_Driver Folder
Next let's see STM32F10x_StdPeriph_Driver The folder .
There are only two folders ( that HTML Never mind the document ),
among inc Express include, Inside is the header file of each peripheral ;
So the corresponding ,src The inside is for each peripheral .c The file .
Here is attached .c Diagram of file , You can read the header file by yourself .
understand Project Folder
open Project Folder ——
By name , We can know ——
The first is the peripheral routine file , There are routines for each peripheral , The program we write later can be copied directly here ;
The second is the template file , Similar to what the government gave us LCD Template file , There are some drivers in the just Libraries Not in the file , We can copy it here .
open STM32F10x_StdPeriph_Template file ——
Inside stm32f10x_conf.h、stm32f10x_it.c、stm32f10x_it.h We need to join our project later .
open STM32F10x_StdPeriph_Examples file ——
Inside are the routines of various peripherals , We can use it when we officially start learning programs .
Start new project
New folder
OK, After understanding the library file , We officially started the new project .
First , Create a new folder , Then create the following folders in the folder ——
( This is what I learned from Wildfire )
first Doc Folder , Put on a readme.txt file , It is used to write the function of the program and some small remarks ;
the second Libraries Folder , It is used to hold the files we will copy from the library later ;
Third Output Folder , The generated file used to install the program ;
The fourth one Project Folder , Used for Engineering , We build the project in this ;
The fifth one User Folder , Used to hold our own writing .c and .h file .
Add library file
First add the entire library to Libraries In the folder .
CMSIS Folder
As we said before , Only keep the framed files , Delete everything else , And put them all in CMSIS, Instead of staying CMSIS In the folder ( Otherwise, adding header files later is troublesome )——
STM32F10x_StdPeriph_Driver Folder
This one will be moved over , After all, this is the driver file of all peripherals ——
STM32F10x_StdPeriph_Template Folder
This is the official routine file , We just put the inside stm32f10x_conf.h、stm32f10x_it.c、stm32f10x_it.h Just join our project ——
Configuration Engineering
New project documents
Then open the Keil4, Click new project , Select chip type as stm32f103rb——
Add project folder
And then click on this “ product ”——
Add the following folders ——
( Double click that name to change it , To add, press the dotted box on the left of the Red Cross )
Add files
Then configure the folders in the project according to the following figure ——
Setup project
Click on this magic wand ——
Debug and build
Tick the following three ——
( The first is debugging information , The second is generation hex file , The third is browsing information , Click a function to jump to its definition or declaration )
Then change the address of the generated file ——
Same page , Click the button below ——
And then choose Output Folder , Then click OK ——
Configure preprocessor declaration
In my picture, it has been configured , Now let's see why we need to configure it like this ( All in stm32f10x.h In file )——
STM32F10X_MD
The first paragraph :Library_configuration_section Library configuration
The second paragraph :Uncomment the line below according to the target STM32 device used in you application According to the target used in the application stm32 Uncomment the line below the device
( Explain that we need to choose our equipment , As we said before, our equipment is medium capacity , So choose STM32F10X_MD)
The third paragraph :To avoid modifying this file each time you need to switch between these devices, you can define the device in your toolchain compiler preprocessor.
To avoid modifying the file device every time you need to switch between these files , You can define devices in the toolchain compiler preprocessor .
( So we need to take STM32F10X_MD Defined in the preprocessor )
Then why do you have to configure it ?
Let's talk about , If you don't define this device type ,“Please select first the target STM32F10x device used in your application (in stm32f10x.h file)”(“ Please first select the target to use in your application STM32F10x equipment ( stay STM32F10x .h In file )”).
USE_STDPERIPH_DRIVER
Comment the line below if you will not use the peripherals drivers.
In this case, these drivers will not be included and the application code will be based on direct access to peripherals registers
If you do not use peripheral device drivers , Please comment on the following line .
under these circumstances , These drivers will not be included , The application code will be based on direct access to external registers .
in other words , If you don't define this USE_STDPERIPH_DRIVER , Then we can't use peripherals . So of course we have to define .
Same as above , For convenience , Also define it in the preprocessor .
Be careful , Separated by commas , Don't use semicolons and other symbols !
Add the header file path
I believe everyone is familiar with this , Just put a piece of my path as a reference ——
Configure debugging tools
We are choosing CooCox Debugger——
Then click the next settings——
The first two choose according to this , The third one doesn't matter .
Generally, if the board is inserted , You have selected the model of the board that will be displayed on the right , If not, restart the project ,JTAG Sometimes it's like this ——
Then click Flash Download——
spot Add, Then find the model I have added below , Just add ( Because we are RBT6 Well ,B Namely 128K)——
This last , Uncheck the circle on the right ( Selected by default , If selected , The left circle cannot be changed ), Then select the circle on the left CooCox Debugger That's it ——
test
stay main.c
The file contains one of the simplest
#include <stm32f10x.h>
int main(){
return 0;
}
then , function !
If the following figure is shown ,
It means that the project file is configured !
If you feel useful, please give me a compliment , thank you ~
边栏推荐
- Huawei Hrbrid interface and VLAN division based on IP
- Leetcode1961. Check whether the string is an array prefix
- [Jiudu OJ 09] two points to find student information
- [Yu Yue education] Liaoning Vocational College of Architecture Web server application development reference
- 【Flask】官方教程(Tutorial)-part2:蓝图-视图、模板、静态文件
- A picture to understand! Why did the school teach you coding but still not
- Docker compose configures MySQL and realizes remote connection
- 【Flask】响应、session与Message Flashing
- 1. Introduction to basic functions of power query
- Luo Gu P1170 Bugs Bunny and Hunter
猜你喜欢
Leetcode skimming questions_ Invert vowels in a string
Electrical data | IEEE118 (including wind and solar energy)
leetcode刷题_平方数之和
Force buckle 9 palindromes
Huawei Hrbrid interface and VLAN division based on IP
3D vision - 4 Getting started with gesture recognition - using mediapipe includes single frame and real time video
Mathematical modeling learning from scratch (2): Tools
[solved] how to generate a beautiful static document description page
You are using pip version 21.1.1; however, version 22.0.3 is available. You should consider upgradin
【已解决】如何生成漂亮的静态文档说明页
随机推荐
Leetcode skimming questions_ Verify palindrome string II
NLP fourth paradigm: overview of prompt [pre train, prompt, predict] [Liu Pengfei]
Huawei converged VLAN principle and configuration
Reasonable and sensible
National intangible cultural heritage inheritor HD Wang's shadow digital collection of "Four Beauties" made an amazing debut!
Redis list
Ali test open-ended questions
Unity VR resource flash surface in scene
Force buckle 9 palindromes
TrueType字体文件提取关键信息
3D视觉——4.手势识别(Gesture Recognition)入门——使用MediaPipe含单帧(Singel Frame)和实时视频(Real-Time Video)
Idea sets the default line break for global newly created files
[flask] official tutorial -part1: project layout, application settings, definition and database access
500 lines of code to understand the principle of mecached cache client driver
2022 PMP project management examination agile knowledge points (8)
Leetcode sum of two numbers
Force buckle 1020 Number of enclaves
【Flask】响应、session与Message Flashing
Folio. Ink is a free, fast and easy-to-use image sharing tool
Huawei Hrbrid interface and VLAN division based on IP