【AT32F421 Review】+ Environment Construction and Hello World
[Copy link]
This post was last edited by dmzdmz666666 on 2021-4-21 22:57
After receiving the development board and unpacking it, we can officially develop this open board. First, I will look for the official information to speed up our development. Let me add here that one of the major advantages of STM32 from foreign semiconductor manufacturer STMicroelectronics is that there are more abundant information and a better ecosystem in China. Of course, on the one hand, domestic development and use time is longer, and on the other hand, people have really put a lot of effort in localization. Domestic manufacturers have advantages in localization, so domestic manufacturers should not only improve the strength of their own products, but also work hard in the ecosystem to allow developers to get started faster. Fortunately, Arteli did not disappoint me in terms of information.
Enter the AT32 technical forum on the official website
Enter the second article
Here is a relatively complete data package (should be official) with the URL https://bbs.21ic.com/icview-3066948-1-1.html
The downloaded data package is as follows
The main development tools are BSP (board development package), Datasheet (data sheet), and Reference Manual (reference manual).
The rest are some tools or circuit diagrams , I will talk about them when I need them.
After downloading the data , I started to build the development environment. Here I chose the more familiar ARM company's MDK 5 for development. I won't talk much about software installation.
The first step is to install the corresponding chip device package to enable MDK 5 to support the development of Arteli's microcontroller. Find Pack, select Pack_Keil_AT32F4xx_V1.3.6.ZIP, and unzip it.
For MDK 5, select the first one, for KEIL 4, select the second one, and double-click to complete.
The second step is to install the corresponding driver of AT_LINK debugger, select Tool, find AT_Link_20210127_1.zip, and unzip it, as shown below,
Select the fourth one , and then follow the prompts to install. Here, Atria officially provides a user manual (UM0004_AT_Link_User_Manual_ZH_V1.0.8, pdf), which is very detailed. Thumbs up. After completing the necessary steps correctly , when the development board is connected to the computer, the following display will appear in Debug -> Settings on MDK 5, indicating that it has been correctly connected . At this point, the development environment has been set up.
Next , we will create a new Hello World project.
The first step is to create a new folder, here named AT32_Demo, and then create the following five subfolders in the folder:
BSP (stores at32_board.c and header files. Here I understand some common functions provided by the official board, such as delay function, onboard LED function, onboard button function, serial port printing function, etc.)
CMSIS (stores some files that comply with the CMSIS specification, such as M4 core peripheral access layer code, DSP library, security library, etc.)
FWLIB (stores AT32's internal and external device related library functions)
HARDWARE (stores some functions defined by users)
USER (stores the main function and at32f4xx_it.c and header files)
After the new creation , we put some files into the subfolder according to the regulations. We open the data package we downloaded before, open BSP -> AT32F4xx_StdPeriph_Lib_V1.3.0 (unzip) -> Libraries -> AT32F4xx_StdPeriph_Driver , and then copy the files in the folder to our subfolder FWLIB ; then copy the files in CMSIS parallel to AT32F4xx_StdPeriph_Driver to our subfolder CMSIS ; then open BSP -> AT32F4xx_StdPeriph_Lib_V1.3.0 (unzip) -> Project -> AT32_Board , and copy the files inside to our subfolder BSP ; open B SP -> AT32F4xx_StdPeriph_Lib_V1.3.0 (unzip) -> Project -> AT_START_F421-> Templates , copy at32f4xx_it.c and the corresponding header files to our subfolder USER, and add main.c to it. At this point, the project supporting files have been built (you can add them to different files as you wish, but a project must have all the files I mentioned above)
The second step is to open MDK 5 and create a new project according to the normal process. I will not go into details here, but here are some details. First, open the magic wand, open C/C++, fill in " AT32F421C8T7, USE_STDPERIPH_DRIVER, USE_FULL_ASSERT, AT_START_F421_V1_0 " in Define , and include all paths in Include Paths to prevent program errors, as shown in the following figure
The following figure shows the structure of our project and the files it contains
Open the main function. I put the specific program in the compressed package. Here I will only talk about the important ones. Because serial port 1 is used for printing, we need to configure USART 1. Ateli official provides UART_Print_Init(uint32_t bound) function in at32_board.c, which can initialize serial port 1. But here, I choose to refer to this function and write another function USART_Configuration(void) (personal habit, want to unify the style), and write all the serial port initialization configurations here.
The serial port interrupt can be disabled here . At the same time, at32_board.c also provides the initialization function and status reading function of the onboard buttons. Here we choose to call them directly. The final main function is shown in the figure below.
When the USER button is pressed, the serial port prints Hello World!,
Here I would like to explain that I directly use the virtual serial port function of AT-LINK-EZ, which is more convenient.
OK , that concludes the second review.
|