【GD32307E-START】Development environment construction + development practice -> light up the onboard LED
[Copy link]
This post was last edited by ylyfxzsx on 2020-9-29 21:25
Friends, in this section we will officially start to build the development environment. So, we start with the simplest way to light up the onboard LED, and then gradually deepen our study and exploration to accumulate a sense of accomplishment. Here, from the perspective of a novice, I will share with you the process of learning and exploration, various joys and complaints. If you just copy and run the official routine, it will lose the meaning of exploration. We should take one step at a time and know the reason why, so that learning will be meaningful.
Okay, the first step is to install the Pack package required in the Keil development environment. In GD32307E-START_Files\ GD32307E-START Files\GD32F30x_Addon Files, click the Pack package, click Next all the way, and the installation is complete.
After the installation is complete, create a new "GD32307E_DEP" folder to store the project code files. According to my habit, I will create several GROUP folders in this general folder to classify and store the Code. The name of the folder can be named as you like, but try to be concise and clear. In layman's terms, you can know what it does at a glance. A good programming habit and style will help you get twice the result with half the effort and facilitate viewing and management.
Because the official library files are used for development, copy the standard library files in GD32307E-START_Files---> GD32307E-START Files---> GD32F30x_Firmware_Library_V1.1.0---> Firmware to the newly created GD32307E_DEP---> FwLibrary folder.
Then copy other files such as "startup_gd32f30x_cl.s" and "core_cm4.h" to the corresponding folders according to your own habits. Next, open Keil5, create a new project, and then create a corresponding GROUP in the newly created project file, corresponding to the folder we created before, and include the required files. Then create a new main file main.c
After creating a new Keil5 project file and including the configuration file and hardware library file, you can now start writing the code to light up the onboard LED. Before that, you need to look at the SCH and LED hardware connections.
Open GD32307E-START_Files--->GD32307E-START Files--->GD32307-START-V1.0 Demo--->GD32307E-START-V1.0.pdf, you can see that LED1 is connected to PC6 of MCU
Next, create a new hw_led.c and hw_lled.h file in the Hardrare folder and add it to the Keil project file .
Start writing the code to light up the LED. Here I wrote a very simple test code for a simple LED flashing.
Then press F7 to compile. You can see that there are no errors in the compilation. Then download it to the development board, the LED starts flashing, the development environment is set up, the LED lights up successfully, and you can start further in-depth exploration!
|