STM32 peripheral configuration-when do I need to turn on the AFIO clock?

problem found

Timers, serial ports, these are peripherals of STM32, which are regarded as a multiplexing function of GPIO port when in use.

But when configuring these peripheral clocks, I don’t know if you have such doubts. Since it is a multiplexing function of the GPIO port, why do not need to turn on the multiplexing clock (AFIO clock)?
Insert picture description here
Insert picture description here

The STM32 Chinese Reference Manual gives the answer to this question

Insert picture description here
Insert picture description here
It can be seen that only when using event control registers, multiplexing remapping and debugging registers, and external interrupt registers, do you need to turn on the AFIO clock in advance! It is not necessary to enable the AFIO clock to use the pin multiplexing function.

Precautions

Peripherals such as timers and serial ports do not need to turn on the multiplexed clock, but they must turn on their own corresponding peripheral clocks.
Also, these peripherals are indeed a kind of multiplexing of pin functions. Don't forget to use multiplexing push-pull output or multiplexing open-drain output when configuring GPIO output mode ! ! !
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43690936/article/details/108920485