STM32 study notes - AFIO clock configuration issues

Publisher:EtherealGazeLatest update time:2018-08-27 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Recently, when I was writing a program, I found that there was a problem with setting the external interrupt. Why did the previous program not work? After a night of tossing and turning, I found that the problem was in the configuration of the AFIO clock. I did not enable the AFIO clock.


When should AFIO be enabled? Reference Manual: 


It is very clear that the three types of registers of AFIO need to be turned on when operating: 
1. Event control register (AFIO_EVCR)
2. Multiplexing remapping and debugging I/O configuration register (AFIO_MAPR)
3. External interrupt configuration register x (AFIO_EXTICRx)
These three types are actually all the registers of AFIO, AFIO_EVCR is related to events, AFIO_MAPR is related to remapping and debugging I/O, and AFIO_EXTICRx is related to external interrupts. Therefore, AFIO needs to be turned on when remapping and debugging I/O configuration, external interrupts, and events.

 

Looking back at the previous program, you can understand it. In the previous program, there are two lines of code in the initialization area of ​​my main function:

RCC->APB2ENR |= 0x00000001; //Disable JTAG, enable SWD

AFIO->MAPR = (0x00FFFFFF & AFIO->MAPR)|0x02000000;   

This code configures the JTAG and SWD pins, and also configures the AFIO clock. So the function can be realized without operating AFIO in the subsequent external interrupt configuration code. Finally, I added this sentence to the program, and the problem was solved perfectly. RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);  


Keywords:STM32 Reference address:STM32 study notes - AFIO clock configuration issues

Previous article:When does the STM32 AFIO clock start?
Next article:STM32 commonly used pins redefine peripherals

Recommended ReadingLatest update time:2024-11-16 20:37

STM32 study notes 9——stm32L072 SD card program transplantation record
The project uses stm32L072 and needs to save the sampled data to the SD card. The SD card program refers to the routine of the official STM32L073Z_EVAL development board of ST company. The places that need to be modified are as follows:  1. Modify the SPI pin configuration and AF configuration in stm32L073z_eval.h; 
[Microcontroller]
STM32 delay function encapsulation program
    /*---------------------------------     Delay module function     Note: Just add delay.c and delay.h to the project     file, you can use Delayms(__IO uint32_t nTime);     Delay(__IO uint32_t nTime)     -----------------------------------*/     #ifndef __DELAY_H     #define __DELAY_H     #include "stm32f10x.h"  
[Microcontroller]
Solution to the network failure when hot-plugging the network cable of STM32 transplantation LWIP
Development Background: 1. Main chip - STM32F207VCT6; 2. TCP/IP protocol stack - LWIP, transplanted based on ST routines; 3. Operating system - none (bare metal); Anomalies: 1. Power on the device without inserting the network cable, and then insert the network cable, and the ping will fail; (If the network cable is i
[Microcontroller]
stm32 timer 3 generates a specified number of pulses
1. Scenario description: Use PB5 to generate a certain number of pulse signals. PB5 is the second channel of timer 3. 2. Generate PWM code: void Timer3_Configuration(void ) {  TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure; TIM_OCInitTypeDef  TIM_OCInitStructure;   TIM_DeInit(TIM3); // ƵÂÊ30K //Õ¼¿Õ±È50%  //
[Microcontroller]
stm32 timer 3 generates a specified number of pulses
Read protection for STM8S/32
1. Steps for code writing and read protection: 1. Preparation: After the HEX file and JLINK driver (JLinkARM_V420 or above, secure chip may appear gray and unselectable in 4.08) are installed, you can open the application in Start--All Programs--SEGGER--J-Flash ARM First set the chip to be written and the writing me
[Microcontroller]
Porting FATFS for STM32 to read FAT12/16/32 file system on SD card
Transplanting fatfs file system to stm32, finally achieved a phased victory today. Only a few functions need to be provided:  DSTATUS disk_initialize (BYTE);  DSTATUS disk_status (BYTE);  DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);  DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); // If a read-only file system i
[Microcontroller]
STM32 uses internal crystal to record
When the external crystal oscillator is not in use, the pin is left floating. You can also follow the online method to ground or remap it. Use the internal crystal oscillator software configuration method. The internal crystal oscillator is named HSI, and the external crystal oscillator is named HSE. 1. Enter SystemIn
[Microcontroller]
STM32 uses internal crystal to record
Comparison of programming environments between 8051 microcontroller and STM32 microcontroller
Microcontroller programming is a practical technology. Only when the program is run on the microcontroller platform can you see the effect and accumulate programming experience. When studying microcontroller courses in school, you may feel that there is always a sense of disconnection because there is never a place to
[Microcontroller]
Comparison of programming environments between 8051 microcontroller and STM32 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号