The ".c" library functions needed are stm32f10x_gpio.c and stm32f10x_rcc.c
1. Start the RCC (reset always control) of the corresponding Port x
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOx, ENABLE);
x can be A to G, GPIO is controlled by APB2 (high-speed peripheral) clock
2. Assign values to the three parameters in the GPIO initial structure (the structure name needs to be defined before the program: "GPIO_InitTypeDef GPIO_InitStructure;")
The three parameters are
pins: GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10;
speed: GPIO_InitStructure.GPIO_Speed=GPIO_Speed_2MHz;
mode: GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
The values of the three parameters can be found in the "Firmware Function Library"
3. Use the GPIO initialization function GPIO_Init(GPIOx,&GPIO_InitStructure) to define the previously assigned structure to Port x.
x can be A to G;
4. Then you can use the GPIO_ResetBits(GPIOx,GPIO_Pin_y) function to set the pin to 0
or use the GPIO_SetBits(GPIOx,GPIO_Pin_y) function to set the pin to 1
x can be: A to F;
y can be: 0 to 15; multiple values can be separated by "|", such as: GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9
5. You can also use the GPIO_ReadInputDataBit(GPIOx,GPIO_Pin_y) function to read the value of the input pin
or use the GPIO_ReadOutputDataBit(GPIOx,GPIO_Pin_y) function to read the value of the output pin.
x can be: A to F;
y can be: 0 to 15; multiple values can be separated by "|", such as: GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9
Note: a) The functions for reading the entire Port value are GPIO_ReadInputData(GPIOx) and GPIO_ReadOutputData(GPIOx)
b) The function for writing the entire Port value is GPIO_Write(GPIOx, value)
c) Generally, after starting according to the first 3 steps, the set GPIO pins will be set to 0 (low level)
Previous article:STM32 (II) GPIO operation (1) - input and output operation
Next article:STM32 GPIO principle: input and output control
Recommended ReadingLatest update time:2024-11-23 11:19
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Playing with Zynq Serial 40——[ex59] Binocular vision image acquisition and display example based on Zynq
- Several reasons for electromagnetic flowmeter errors
- Software and hardware design of intelligent release
- Power Management Features
- SiGe wireless RF front-end solution effectively reduces Wi-Fi system size and reduces costs
- Summary and analysis of interference problems in circuit design
- Does the dummy pad have any impact on the electrical characteristics of the PCB?
- [HC32F460 Development Board Review] NO.2 Familiarity with the development process and different peripheral functions
- TLP3547 Evaluation Results
- Classification of RFID readers and their advantages