1. Basic IO structure:
There are 7 groups of IO for STM32F407, namely GPIOA~GPIOG, each group of IO has 16 IO ports, so there are 112 IO ports. The basic structure of the IO port is as follows:
2. Working method:
There are 8 working modes of STM32F4, including 4 input modes and 4 output modes, namely: input floating, input pull-up, input pull-down, analog mode, open-drain output, open-drain multiplexed output, push-pull output, and push-pull multiplexed output.
1. Input mode:
In input floating mode, the circuit does not pull up or pull down, and is sent to the input data register through the Schmitt trigger and then to the CPU. In input pull-up and pull-down modes, the circuit is pulled up and pulled down in the circuit and then sent to the CPU through the Schmitt trigger. In analog mode, after the Schmitt trigger is turned off, the signal is directly sent to the on-chip peripherals through the analog channel.
2. Output mode:
In the open-drain output mode, the CPU sends input to directly or indirectly control the output data register. Through the output control circuit, when the signal is 1, the N-MOS tube is closed, so the IO level is controlled by the pull-up and pull-down circuits. When the signal is 0, the N-MOS tube is turned on and the output is pulled down to a low level; in the push-pull output mode, when the signal is 1, the P-MOS tube is turned on and the N-MOS tube is turned off, and the output is pulled up to a high level. When the signal is 0, the P-MOS tube is turned off and the N-MOS tube is turned on, and the output is pulled down to a low level. The difference between the open-drain multiplexing and push-pull multiplexing modes and the open-drain and push-pull multiplexing modes is that the source of the signal is different. The signal source of the open-drain multiplexing and push-pull multiplexing is the on-chip peripheral module.
3. Related registers
Each general IO port includes four 32-bit configuration registers (GPIOx_MODER, GPIOx_OTYPER, PIOx_OSPEEDR and GPIOx_PUPDR), two 32-bit data registers (GPIOx_IDR and GPIOx_ODR), one 32-bit position/reset register (GPIOx_BSRR), one 32-bit lock register (GPIOx_LCKR) and two 32-bit alternate function selection registers (GPIOx_AFRL). They are introduced below.
1. Working mode configuration: 1. Port mode (GPIOx_MODER): used to configure the port mode as input, output, multiplexing and analog mode. 2. Port type (GPIOx_OTYPER): used to configure the register mode as output push-pull or output open-drain. 3. Port speed (PIOx_OSPEEDR): used to configure the information transmission rate of the port. 4. Port pull-up and pull-down (GPIOx_PUPDR): used to configure the port mode of no pull-up and pull-down, pull-up, pull-down and reserved.
2. Level configuration: 1. Input data (GPIOx_IDR): The lower 16 bits are used to correspond to a level state of the IO port of this group. 2. Output data (GPIOx_ODR): The function is similar to the input data register. 3. Set and reset (GPIOx_BSRR): The difference from the previous two is that the set and reset registers use 32 bits. When the lower 16 bits are set to 1, they are used to set the corresponding bit. When the upper 16 bits are set to 1, they are used to set the corresponding bit. When the lower 16 bits and the upper 16 bits are set to 0, the original value is not affected.
3. Multiplexing function configuration: The corresponding instructions are given below.
IO multiplexing
1. Reuse Background:
Considering the limited number of IO ports, in order to save IO resources and better coordinate the work between IO ports, it is necessary to assign different functions to IO ports at appropriate times. An IO port can undertake different tasks at different times. This is the multiplexing function of IO.
2. Reuse principle:
Each IO port is connected to a selector. After the configuration of the corresponding registers (GPIOx_AFRH and GPIOx_AFRL), the selector can be used for different functions. The registers are GPIOx_AFRH and GPIOx_AFRL.
3. Register configuration:
Each group of IO ports has an AFRL and an AFRH register, both of which are 32-bit registers, where each 4 bits configure the function of an IO port, and the corresponding GPIOx_AFRL is used to configure the 0th to 7th IO ports, and GPIOx_AFRH is used to configure the 8th to 15th IO ports. Each 4 bits configure an IO port, and the relevant values of the 4-bit data will have corresponding corresponding functions. In this way, the relevant configuration is done.
Summary:
These related configuration processes will use corresponding functions and corresponding variables. You will be more comfortable with the application only after you are proficient in using the related functions and understand their functions. You can also write some related functions of your own to perform operations. Of course, you can also directly operate the related registers.
Previous article:STM32GPIO multiplexing
Next article:Why is the MISO pin of the SPI in STM32 set to multiplexed push-pull output?
- Popular Resources
- Popular amplifiers
- Learn ARM development(15)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- [Qinheng RISC-V core CH582] BUG serial port can only receive up to 8 bytes at a time
- Open Source & Group Purchase: RCSN's Wireless Multi-channel Serial Port Tool is here~
- How to Learn FPGA
- Share a RF power amplifier design guide
- Op amp offset voltage and single or dual power supply issues?
- Keysight Technologies' Thanksgiving Month Oscilloscope Award Photos
- How to filter out 50HZ power frequency interference introduced by active filtering
- Is it the inverter or the integrator circuit?
- I have lived for more than 30 years and my brushing posture is wrong!
- Questions about the MSP430 microcontroller architecture: MSP430, MSP430X, MSP430Xv2