当前位置:网站首页>STM32GPIO

STM32GPIO

2022-06-26 01:17:00 m0_ forty-six million three hundred and twenty-one thousand one

GPIO Basic knowledge

STM32 Most owned GPIOA、GPIOB...GPIOG Seven ports , Each port has a maximum of Pin0、Pin1...Pin15 common 16 One pin .

STM32 Each I/O Ports can be freely programmed , but I/O The register must be pressed 32 Bit words are accessed

Two GPIO Output HAL Library function

1)GPIO Electric frequency output HAL Library function

GPIOx: The port number of the target pin

GPIO_Pin: The pin number of the target pin

PinState: High level ---GPIO_PIN_SET, Low level --GPIO_PIN_RESET

for example : towards PB8 Pin output high level HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET);

2)GPIO Level flip HAL Library function

Output the opposite level according to the current level

for example :PA3 Output level flip ,HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_3);

GPIO The functions and properties of the port

Normal output ( Push pull output and open floor output )

Analog input

Reuse output

I/O Interface circuit

To configure STM32cubeMX

To configure SYS as well as RCC

Configure clocks

The generated code , Name the file , And choose MDK-ARM V5

Check the box shown in the above figure , Then you can generate code , To MDK Editor in chief

stay mian Functional USER CODE Editor inside , When it's halfway through development , If you want to redefine the pins , Can return STMcubeMX edit , Instead of deleting all the original code .

Compile successfully

原网站

版权声明
本文为[m0_ forty-six million three hundred and twenty-one thousand one]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202180558176229.html