STM32CubeMX new project + basic IO configuration process

Before I read this article, I can check out my previous article:

This article follows the previous article in conjunction with the basic IO configuration example to describe the process of creating a new STM32CubeMX project. Finally, a software project for driving IO (lighting LED) is completed through the STM32CubeMX tool configuration, that is, after the STM32CubeMX configuration is completed, the project can be directly downloaded to illuminate the LED.

This article uses Keil (MDK-ARM) V5 software for the compilation environment, if you do not have the latest version of the software installed, please install the latest version of the software, the specific process can refer to one of my articles:

See below for more details on this article.

Ⅱ、STM32CubeMXNew project description

In the previous article, I briefly described the steps to create a new project. Here is an example to describe the details of each step of the new project.

1.turn onSTM32CubeMXSoftware, click on "New Project"

2.selectMCU orselect(STOfficial) development board

A. If it is purchased online or by our own development board, click “MCU Selector” to enter the MCU selector. The selector is common on web pages and is chosen according to your needs (we take the STM32F103E as an example).

1. According to the "series" selection; such as: F0, F1, F2 ... F7, L0, L1, L4, etc.;

2. According to the "product line" selection;

3. According to the "package" selection;

4. According to "other features" selection; such as: FLASH size, RAM size, IO number, etc.

After layer-by-layer screening, you can finally see the chip model you want, double-click the "check" chip, as shown below:

B. If your development board is to purchase ST's official development board (or evaluation board), click "Board Selector" to enter the development board selector. (We take STM3210E-EVAL as an example).

1. According to the "manufacturer" selection; currently only ST manufacturers, it is estimated that other manufacturers will be expanded in the future;

2. According to the "board type" selection;

3. According to the "chip series" selection;

After layer-by-layer screening, you can finally see the chip model you want, double-click the "check" chip, as shown below:

The above two methods are similar, and the following configuration is similar. We select the first one below.MCUSTM32F103ZE) as an example to tell.

3.Engineering configuration

After "selecting" the chip in the previous step, it enters the chip engineering configuration interface.

A.Project ->Settings popup settings window;

B. There are 3 options in the pop-up settings window:

ProjectProject Settings: This option is the main setting option, and the configuration information is described below;

Code GeneratorCode Generation Configuration: This option is about code generation configuration. Such as: copy the configuration of the HAL library, generate the configuration of .c and .h (usually no modification, default configuration).

AdvancedSettingsAdvanced Settings: This option can be set after configuring the chip (pin function).

C.Project project settings, this option is an important option for configuration engineering, and the configuration information is also important and easy to understand.

This next configuration is closely related to our final running code. Let's take a simple configuration IO (PF11 pin) to drive the LED as an example.

A. Zoom in on the chip icon and find PF11 (can be found by Find):

B. Select PF11-> Left button -> Pop-up list -> Check "GPIO_Output"

C. Configure the "Crystal" pin (RCC configuration)

If you use "external crystal oscillator" you still need to continue configuration (we configure HSE as an example), including three configurations:

HSE external high-speed clock, LSE external low-speed clock, MCO clock output.

5.ClockConfiguration

The configuration here is a more user-friendly configuration, combined with the clock tree, you can see at a glance (also according to the reference manual clock tree configuration), the configuration method is the same.

6."comprehensive" configuration

Since we only configure the PF11 pin, other functions (such as DMA, USB, etc.) are not configured. If there are some configurations in the previous configuration, there is more information here, so it is called "comprehensive configuration".

Click GPIO, pop up the configuration dialog box, fill in the information in order, click "OK" just fine:

7.Low power configuration

Generally, in the learning phase, there are fewer low-power configurations, and there are many things to consider when configuring low-power in actual projects (including hardware).

8.Generate code

After completing all the above configuration, the final job is to click the "Generate Code" button:

If the previously generated build software project, the HAL library file will be copied in your project:

Finally prompted to open the software project (provided you have installed the IDE: MDK-ARM)

9.Compile download

Open the project, compile without errors, no warnings, download, program running;

At this point, the entire process is complete. If your development board LED light pin (PF11) is the same as the above configuration, download it to the development board. If you reset it, you can see that the LED light is on (low level LED).

STM32CubeMX basic IO configuration process (original version), available to everyone to download the address (360 cloud disk):

10.Add code

The above project is a simple project (configuration initialization code), you can add your own code at the prompt (such as USER CODE BEGIN).

I added a "test delay" function under "USER CODE BEGIN 0"; an LED light-off statement was added at "USER CODE BEGIN WHILE".

Adding the above two codes will enable the LED interval (delay) to change for a while.

STM32CubeMX basic IO configuration process (modified version), available to everyone to download the address (360 cloud disk):

III. Description

The above is a detailed step of the "Basic IO Configuration Process". Follow-up will periodically update the article on using STM32CubeMX to create various peripheral resource projects. Please wait.

The above summary is for reference only, please understand if there is something wrong.

IV, last

More exciting articles I will share in the WeChat public account for the first time. If you have any questions about this article, you can leave a message on WeChat.

In the principle of free sharing, it is convenient for everyone to learn knowledge on mobile phones and share technical knowledge on the WeChat platform on a regular basis. If you feel that the content you share is useful to you and would like to know more about the article, please use WeChat search.EmbeddDeveloper" Or scan the QR code below, follow, there will be more exciting content waiting for you.

        </div>
            </div>
        </article>