The 11th Lanqiao Cup IoT Design and Development Experiment-ex3 RCC Clock Selection Experiment

Basic Experiment-Based on Provincial Game Resource Set

RCC clock selection experiment

The purpose of the experiment: master the selection method of the RCC clock.
Experimental content: Press the button to switch the clock source selection and output on the PA8 pin. The clock sources are PLL (24MHz), HIS (16M), MSI (4.194MHz).
Experimental phenomenon: Press the USER button, the clock of the chip switches between PLL (24MHz), HIS (16M), MSI (4.194MHz).

STM32CubeMX configuration

  1. Target selection
  2. Pin assignment
  3. Peripheral configuration
  4. Clock configuration
  5. Engineering configuration

1. Target selection

New project
Insert picture description here
selection MCU input STM32L071KB
Insert picture description here
Insert picture description here

2. Pin assignment

PC15 pin: GPIO_Output (output mode)
Insert picture description here
PC14 pin: GPIO_Input (input mode)
Insert picture description here
PA8 pin: RCC_MCO (output internal clock)
Insert picture description here

3. Peripheral configuration

Insert picture description here
PC14 pin configuration

GPIO mode: input mode
GPIO pull-up resistor / pull-down resistor: no pull-up resistor / pull-down resistor

Insert picture description here
PA8 pin configuration

GPIO mode: Alternative function push-pull output
pullup GPIO / pull-down resistance: pull-up resistor / pull-down resistor
output speed: Very fast

Insert picture description here

4. Clock configuration

Clock source: Bypass clock source
Insert picture description here
Clock frequency: PLL (24MHz), HIS (16M), MSI (4.194MHz)
Insert picture description here

5. Engineering configuration

Insert picture description here
Insert picture description here
Insert picture description here
Insert picture description here

Keil5 programming

1. Select STM32L071KBUx chip

Insert picture description here

2. Add code

In the USER CODE BEGIN PM and the USER CODE END PM added at between macro definitions
Insert picture description here
in the USER CODE BEGIN 1 and USER CODE END 1 add the following code between
Insert picture description here
the USER CODE BEGIN 3 and the USER CODE END 3 add the following code between
Insert picture description here
Insert picture description here

3. HAL library function analysis

GPIO input read function: HAL_GPIO_ReadPin (GPIOx, GPIO_Pin)

GPIOx: GPIO port (GPIOA ~ GPIOC )
GPIO_Pin: Pin number corresponding to this port (0 ~ 15)

Published 7 original articles · praised 7 · visits 53

Guess you like

Origin blog.csdn.net/a1347563271/article/details/105472630