STM32 self-study notes - multiplexing and remapping

Publisher:快乐舞蹈Latest update time:2018-06-15 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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? 
Write the picture description here
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


Keywords:STM32 Reference address:STM32 self-study notes - multiplexing and remapping

Previous article:STM32F10 series pin multiplexing function and AFIO
Next article:stm32 timer remapping

Recommended ReadingLatest update time:2024-11-16 16:54

STM32 reset/clock control
========================== Reset/Clock Control ==================== ===  1. Clock Security System (CSS)     After the clock safety system is activated, the clock monitor will monitor the external high-speed oscillator in real time; if the HSE clock fails, the external oscillator is automatically turned off and a clo
[Microcontroller]
STM32Cube.AI v7.2 now supports deep quantized neural networks
STMicroelectronics recently released STM32Cube.AI v7.2, which brings support for deep quantized neural networks, allowing more accurate machine learning applications to run on existing microcontrollers. STM32Cube.AI was launched in 2019 to convert neural networks into code suitable for STM32 MCUs. The solution is a
[Internet of Things]
STM32Cube.AI v7.2 now supports deep quantized neural networks
STM32 register operation learning - general timer/counter shadow register
Careful friends may find in this picture that some registers have shadows under their boxes, which means that the register has a corresponding shadow register. This register means that physically this register corresponds to two registers, one is a register that the programmer can write or read, called the preload
[Microcontroller]
STM32 register operation learning - general timer/counter shadow register
STMicroelectronics' STM32 Smart Wireless Modules Accelerate Development of Innovative Connected Products
STMicroelectronics' STM32 Smart Wireless Modules Accelerate Development of Innovative Connected Products I-care Group uses STM32WB5MMGH6 wireless module in Wi-care smart industrial predictive maintenance system November 7, 2022, China -- STMicroelectronics (STMicroelectronics), a world-
[Embedded]
Comparative analysis of the advantages and disadvantages of stm32 microcontroller and pic microcontroller
stm32 microcontroller The STM32 series of microcontrollers launched by ST are known to all industry friends as being a series of microcontrollers with the highest cost-performance ratio, and they are extremely powerful. They are based on the ARM Cortex-M core designed specifically for embedded applications that requir
[Microcontroller]
Comparative analysis of the advantages and disadvantages of stm32 microcontroller and pic microcontroller
STM32 interrupt priority (Cortex-M3)
I. Overview  There are two priority concepts in STM32 (Cortex-M3) - preemption priority and response priority. The smaller the attribute number, the higher the priority. Some people call the response priority "sub-priority" or "sub-priority". Each interrupt source needs to be assigned these two priorities.  An int
[Microcontroller]
Set the clock of each part of the stm32 system
The function is as follows: /****************************************************** ************************* * Function name: RccInitialisation * Function description: Set the clocks of various parts of the system * Input parameters: None * Output result: None * Return value: None **********************************
[Microcontroller]
STM32 USB Design-MCU Program
First, let's take a look at the working process of USB. When a USB device is connected to the host, the host begins to enumerate the USB device and sends a command to the USB device to obtain the relevant description information of the USB device, including device description (device descriptor), configuration
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号