A simple understanding of AFIO for beginners of STM32

Publisher:草木知秋Latest update time:2018-08-26 Source: eefocusKeywords:STM32  AFIO Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

When configuring the external line interrupt of the PC13 pin, the multiplexing function is used when configuring its external clock:

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO,ENABLE);

The reason is that the first function pin of PC13 is GPIO, and the second function pin is TAMER-RTC1, which does not have the EXTI function. If you want to use it to generate an external line interrupt, you must configure the AFIO multiplexing function and map the EXTI function to the PC13 pin.

PC13 pin function diagram

Another example:

The CAN bus uses PB8 and PB9, but these two pins do not have CAN functions and need to be remapped:

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOB, ENABLE);



PB8, PB9 pin function diagram



CAN&485 TR pin diagram



Some configurations do not require multiplexing functions, for example, UASRT1 pins PA9 and PA10, whose second function pins are USART functions, so when using the UASRT function, the clock cannot be configured in AFIO.

When configuring the RCC external clock, you need to configure both the basic GPIO mode and the clock of its second function USART.


The second pin of PA9 is used, and one of the output modes is the multiplexed output mode, so it needs to be configured into the multiplexed output mode.

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;



Since both USART and GPIOA are externally connected to RCC_APB2, the parameter is a combination of the two values.

/* config USART1 clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA, ENABLE);



Keywords:STM32  AFIO Reference address:A simple understanding of AFIO for beginners of STM32

Previous article:Aliases of R0~R15 registers in ARM registers
Next article:When does the STM32 AFIO clock need to be turned on?

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

STM32—Serial Communication
1. Basic concepts of serial ports In the STM32 reference manual, the serial port is described as a universal synchronous asynchronous receiver and transmitter (USART), which provides a flexible method for full-duplex data exchange with external devices using the industry standard NRZ asynchronous serial data format. U
[Microcontroller]
How to use ST's library to develop STM32
The chip I use is STM32F103VET and the compiler is IAR ARM V5.5, the debugger is JLINK V8 1, download the ST library, the current version is STM32F10x_StdPeriph_Lib_V3.3.0, unzip it, and then copy the entire Libraries to your working directory. The Project directory is a lot of demonstration codes, you can refer to h
[Microcontroller]
Burn the program to STM32 through the serial port
1. Set BOOT0 to 1 and BOOT1 to 0 BOOT0 is not connected to a short-circuit block and is at a high level. 2. Connect the computer and the circuit board via the USB to serial port module The GND of the module is connected to the GND of the circuit board, the TXD of the module is connected to the RX of the circuit boar
[Microcontroller]
Burn the program to STM32 through the serial port
STM32 USB CAN Learning Notes - Usage of Shared RAM
The USB clock can be enabled at all times.  If the CAN clock is not enabled, the RAM can be read and written by software. (CANBus cannot send and receive messages)  If the CAN clock is enabled, the RAM cannot be written by software. The CANBus Core controls this RAM area. (CANBus can send and receive messages)  CANBus
[Microcontroller]
Mil's bare metal development application notes based on the STM32MP135 development board, MCU-friendly transition to MPU
Previously, microprocessors (MPUs) and microcontrollers (MCUs) were two distinct devices, with MPUs supporting rich software systems such as Linux and related software stacks, while MCUs would typically focus on bare metal and RTOS. In recent years, as MCUs have become increasingly powerful, the distinc
[Embedded]
Mil's bare metal development application notes based on the STM32MP135 development board, MCU-friendly transition to MPU
STM32 Application Notes GPIO Initialization
//Initialize IO mode: pull-up/pull-down input. Call function:  void KEY_Init(void) //IO initialization {       GPIO_InitTypeDef GPIO_InitStructure;        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOE,ENABLE); //Enable PORTA, PORTE clock        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|G
[Microcontroller]
What is the difference between mode 1 and mode 2 when the stm32 general timer generates pwm
110: PWM mode 1 - When counting up, once TIMx_CNT Valid is 1, invalid is 0.
[Microcontroller]
Understanding the STM32 startup file
        In the process of embedded application development, due to the use of C language programming, the execution process of the underlying registers of the machine is rarely involved. Generally, the code is written directly in the main function. It seems that main has become the starting point for granted, although
[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
Guess you like

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号