Port multiplexing
What is port multiplexing:
STM32 has many built-in peripherals, and the external pins of these peripherals are multiplexed with GPIO. In other words, if a GPIO can be multiplexed as a function pin of a built-in peripheral, then when this GPIO is used as a built-in peripheral, it is called multiplexing.
How to use:
1. Enable GPIO clock
2. Enable the clock of the multiplexed function
3. Set the GPIO port data according to the data manual,
eg.
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);//①IO clock enableRCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);//②Peripheral clock enable//③Initialize IO to the corresponding modeGPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //PA.9//Multiplexed push-pull outputGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //PA10 PA.10 floating input GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //Floating input GPIO_Init(GPIOA, &GPIO_InitStructure); 12345678910111213
Port Remapping
What is port remapping:
Each built-in peripheral has several input and output pins. Generally, the output ports of these pins are fixed. In order to allow design engineers to better arrange the direction and function of the pins, the concept of peripheral pin remapping is introduced in STM32. That is, in addition to the default port, the pin of a peripheral can also be mapped to other ports by setting the remapping register. In order to optimize the number of peripheral IO functions of different device packages, some multiplexed functions can be remapped to other pins. Many built-in peripheral input and output pins in STM32 have the function of remapping.
How to use:
1. Enable the remapped IO port
2. Enable the functional peripheral clock
3. Enable the AFIO clock
4. Set the GPIO port data according to the data manual
5.. Enable remapping
eg.
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);//①IO clock enableRCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);//②Peripheral clock enableRCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);③Multiplexing clock enable//④Initialize IO to the corresponding modeGPIO_InitStructure.GPIO_Pin = GPIO_Pin_9; //PA.9//Multiplexing push-pull outputGPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //PA10 PA.10 floating input GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //Floating input GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_PinRemapConfig(GPIO_Remap_USART1, ENABLE); //Enable remapping 1234567891011121314151617
question
When to turn on the AFIO clock:
Before reading and writing registers AFIO_MAPR, AFIO_EXTICRX and AFIO_EVCR, the AFIO clock should be turned on first.
AFIO_MAPR: Configure multiplexing function remapping
AFIO_EXTICRX: Configure external interrupt line mapping
AFIO_EVCR: Configure EVENTOUT event output
What is a partial remap? What is a full remap?
Partial remaps have some pins overlapped with no remaps.
Why is it designed this way:
1. Save the number of IO ports
2. Convenient for PCB to reduce cross-interference of signals
3. Achieve the purpose of time-sharing multiplexing
Previous article:STM32F10 series pin multiplexing function and AFIO
Next article:stm32 timer remapping
Recommended ReadingLatest update time:2024-11-16 16:54
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Five factors to consider when designing a fixed wireless access (FWA) system
- Weak Bluetooth signal strength and excessive static power consumption of the product
- Analysis of the circuit diagram of infrared pair tube. Can someone please help me analyze it?
- Practical information! The most comprehensive Linux application development case sharing, including key codes! (Part 2)
- Application design of active RFID tag based on MSP430F2012 and nRF24L01
- CC3200LaunchPad modified infrared thermometer
- EEWORLD University Hall----Live Replay: STMicroelectronics Data Center and Communication Network Power Management Solutions
- Array out of bounds and HardFault exception interrupt
- EEWORLD University Hall----Xuvod ML51PC0AE
- I would like to ask about the LCD display problem. Pictures are attached.