STM32H7 clock tree RCC analysis --- CubeMx configuration (3)

Foreword:
We talked about the clock principle of H7 before, and the clock configuration code of HAL library. Let's take a look at how to configure CubeMx

STM32H7 clock tree RCC analysis - principle explanation (1)
STM32H7 clock tree RCC analysis - HAL library configuration (2)

Tools used:

1. Chip: STM32H743II

2. STM32CubeMx software V6.1.0

3. IDE: MDK-Keil5 software

4. STM3H7xxHAL library

1 Set the RCC clock
insert image description here

2 Clock source settings

There are many clock settings for cubemx, the simplest is that we directly select the clock source HSE and then set the system clock frequency

Press Enter directly, the software will automatically configure
insert image description here

Mine is an external crystal oscillator HSE is 25MHz

  • 1 select external clock HSE 25MHz
  • 2 PLL phase-locked clock source selection HSE
  • 3 The system clock source is selected as PLL
  • 4Fill in 400 and press Enter

H7 is different from F1 and F4. Many peripherals can directly set the corresponding clock. Because there are three phase-locked loops, you can pull down to see the corresponding peripheral clock settings. It should be noted that the corresponding peripherals are enabled. Ability to select peripheral clocks
insert image description here

3LED settings

Here we directly set PB0 and PB1 as external clocks
insert image description here

set to output mode
insert image description here

4 Project file settings

insert image description here

  • 1 Set the project name
  • 2 Set the storage path
  • 3 Select the IDE used

insert image description here
5Create project file

Then click GENERATE CODE to create the project

Configuration download tool
All configurations of the new project are default, we need to choose the download mode by ourselves, check the download and reset the operation

insert image description here

Main.c add code:

		HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,GPIO_PIN_RESET);	//PB0置0
		HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_RESET); //PB1置0
		delay_ms(500);
		HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,GPIO_PIN_SET);	//PB0置1
		HAL_GPIO_WritePin(GPIOB,GPIO_PIN_1,GPIO_PIN_SET);	//PB1置1
		delay_ms(500);

You can implement a basic running water lamp

Guess you like

Origin blog.csdn.net/as480133937/article/details/123631683