How to use Keil to create STM32F103 project

Next, how to use Keil to create the STM32F103 project, and complete the function of lighting the LED and blinking the LED, which is the starting method for many students to learn the MCU. This tweet is a continuation of the content of the previous tweet. The LED is still lit. The difference is that the LED is lit this time in the RT-Thread operating system.
Create project

Create a Keil project, still select STM32F103C8T6 for the chip, and then select the software components that need to be used in the ManageRun-TimeEnvironment dialog box. The difference is that we need to tick the RTT together. As shown below:

In the above figure, the red line boxes are the components of the RTT operating system, which are device drivers, system kernels, and shells. The blue line box is Keil's RTX operating system. What we are going to use now is RTT, so just check the RTT component. Kernel is a required option, devicedrivers depends on kernel, and shell depends on devicedrivers.

Shell also mentioned that the forced translation of the shell into Chinese is the command line shell. Just like the Linux operating system, RTT also provides a set of operation interfaces for users to operate on the command line. The interface provided by RTT is called finsh, which is mainly used for debugging and viewing system information. finsh supports two modes:

1. C language interpreter mode, called c-style for the convenience of writing;

2. Traditional command line mode, this mode is also called msh (moduleshell).

In most embedded systems, hardware debuggers and printf log printing are generally used for development and debugging. In some cases, these two methods are not so easy to use. For example, for RT-Thread, a multi-threaded system, we want to know the running status of threads in the system at a certain time and manually control the system status. If you have a shell, you can enter commands and directly execute the corresponding function to obtain the required information or control the behavior of the program. This will undoubtedly be very convenient. Finsh is designed based on this. It runs on the development board and can communicate with the PC using serial port/Ethernet/USB.

After the project is created, compared to the project created in the previous tweet, there will be more RTT in the project, as shown in the figure below. As for the various files and their functions, they will be gradually understood when they are used later. We currently need to pay attention to the two files board.c and rtthread.h. It can be seen from the figure that only these two files are not marked with keys, and the ones with keys are not allowed to be changed, that is, we can change these two files. These two files will be analyzed later. Let's take the next step.

Write lighting program

After creating the project, start writing the lighting program. Just like the previous tweet, paste the code directly:

#include"rtthread.h"

Solar Panels

Solar Panels,Outdoor Flexible Charging,Portable Solar Camping Generator,Foldable Solar Panel

Guangdong pisen electronics co., ltd , https://www.pisenpro.com