stm32 is an arm cortex-m3 architecture chip. It can be used with library functions to realize various functions more conveniently, especially when combined with various bus development applications. Because the library functions have encapsulated many bus processing methods and drivers, directly calling the corresponding library functions can operate each bus. Compared with directly operating registers, operating I2C SPI CAN and other bus structures will be much simpler.
There are many development tools for stm32, such as MDK, ADS, AVR, etc. I use MDk, which can actually compile arm's keil. The interface is the same as keil. I have installed keil before. I can directly overwrite the original keil with MDK to support the development of 51 microcontrollers and arm chips.
MDK official website download address: https://www.keil.com/arm/demo/eval/arm.htm
stm32 V3.5.0 library file official website download: stm32f10x_stdperiph_lib.zip
stm32 related information: http://www.st.com/internet/mcu/product/164492.jsp
Regarding the question of whether to use library functions or directly operate registers when developing applications, I think there are many advantages to using library functions, especially when developing applications in a team. Each programmer has his or her own coding style. In addition, the complexity of operating registers makes development and maintenance difficult. Of course, if you want to have a deeper understanding of the principles of ARM, directly operating registers is certainly advisable. And when you are familiar with it to a certain extent, the code you write may be more efficient than library functions. However, general applications can be implemented using library functions. Library functions are very similar to the concept of frameworks in languages such as PHP, which is very helpful for development.
Firmware library settings
Many contents in the library function can be deleted. To reduce the size of the project, you can change the library function structure according to your own habits.
First, unzip the downloaded firmware library (keep a backup, you know)
_htmresc: The ST logo is completely useless and can be deleted.
Libraries: The more important files include STM32 system files and a large number of header files, that is, library files.
Project: Contains a large number of peripheral routines and evaluation version project templates for various software versions. KEIL corresponds to the project template under the MDK-ARM file. You can also use this project template to modify it and get your own project module. If it is not needed in development, you can delete it.
Utilities: These are the files related to the evaluation version: they will not be used and can be deleted.
You need to remove the read-only attribute of these four files first. After selecting the folder, right-click on the properties and check "Read-only".
The library function structure after I deleted it is as follows:
STM32 v3.5 library function actual file structure
Cmsis contains microcontroller peripheral access layer and kernel device access layer files;
Startup of course includes the startup file of stm32, which is related to the chip Flash capacity. See the manual for details.
Libraries contains the standard peripheral library driver source files (src folder) and (inc) standard peripheral library driver header files
User contains the project code and interrupt code
Project is used to contain a series of files generated during compilation, Output is used to place output files.hex.axf, and Listing is used to place Listing information
MDK Setup
Find the corresponding files in the library function compression package and allocate each file as shown above (refer to this article: stm32 firmware library using V3.5 ) and then proceed to the next step
Create a new project in Keil, for example, create TEST.uvproj, and save it in the Project folder. Select the STM32 chip you are using, for example, I use 103RB, just select that, after confirming, a window will pop up asking you whether to copy the startup code, select No, because we already have it in the library function, the previous preparation work is not in vain.
Then right-click TARGET 1, select Manage Ccmponents, add the files according to the library function file structure just now, create a new folder, and then add the corresponding files.
The set interface is as follows:
These folders under Keil will be virtual and may not correspond to existing folders.
Finally, right-click TARGET 1 and select Options for TARGET1. In the Listing, Output tab, click Select Folder for Objects... to set the corresponding output folder.
The Output settings are as follows:
In C/C++, you also need to set the Include Paths path. This path depends on your actual file directory structure:
After the settings are completed, you can compile and test that the library function can run normally.
Previous article:stm32 direct operation register development environment configuration
Next article:MCU reads EEPROM (AT24C02)
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- When using ALTium Designer to edit the PCB library, the pads placed are invisible. I don't know why.
- 【GD32F310G-START】Solve Error: Device not found and turn on the LED light
- [National Technology N32G457 Review] Install RT-Thread Studio
- FPGA chip power backflow problem
- Visit the MPS Core Cloud Exhibition Hall online to learn about the latest technologies and win gifts by simply passing levels!
- Real-time Signal Analyzer Based on TMS320VC5509A
- Case Study - Self-Powered Environmental Sensors for IoT Systems Using Energy Harvesting Technology
- Get it for free|Explore the NXP i.MX RT1020 evaluation kit worth 500 yuan
- How to make QC protocol output USB PD protocol? QC to PD protocol dedicated chip
- The principle of motor PWM speed regulation based on MSP430 microcontroller