Hardware design considerations for HuaDa MCU HC32F003/005 Add library program steps in MDK
[Copy link]
This post was last edited by Hot Ximixiu on 2021-3-28 09:50
1. The RESET pin can be reused as a GPIO digital input port with pull-up. It is recommended to retain the peripheral reset circuit;
2. P27 and P31 are set to SWD debugging function by default when powered on, and are always high level when not reused as GPIO ports;
3. P35 and P36 are the UART programming ports of the chip (cannot be changed). When the chip encryption is locked, the chip can be operated through UART. It is recommended to connect these two ports in the design;
4. After P35 is powered on, there is a high-level pulse of about 9.2ms. If this pulse affects the function of the product, it is recommended not to select this pin as output during design.
5. The remaining IO pins are in high impedance state after power-on and can be set to other modes during program initialization.
6. How to add library program to MDK
Through the previous learning, we have now mastered how to create a new project for the Huada MCU and how to download and debug the program. The following describes how to use the library functions officially provided by Huada for development. It is well known that library functions are a way to put functions in a library for others to use. The method is to compile some commonly used functions and put them in a file for different people to call. The rational use of library functions by developers will speed up development and reduce maintenance costs. The following describes how to add library functions to the established project.
1. Preparation
Copy the driver folder, common folder and ddl_device.h file in the corresponding model of Huada MCU to the project folder directory.
2. Specific operations
Open the previously established templat.uvprojx project. Right-click Source Group1 and select Manage Project Items in the pop-up menu...
In the Project Items pop-up window, click the New (Insert) item in the Groups item.
In the newly created box, enter driver. This Group is used to load the .c source program referenced in the program. Then click Add Files to select the .c source program to be loaded. In the pop-up dialog box, select the three files gpio.c, ddl.c and clk.c in the previous driver\src folder. After selection, it is shown in Figure 3 below. Then click OK to close the pop-up window.
Magic Wand->C/C++, click the button behind Include Paths, as shown below. This is used to specify the include path of the corresponding header file referenced in the program.
Follow the steps in the pop-up window.
Include the driver\inc folder, common folder, and the folder path where ddl_device.h is located.
Add the settings of the header file
Open the main.c file and rewrite the original file into the following content.
After compiling without any problems, you can perform simulation.
|