First ask yourself a question: In STM32, USART2 and TIM2 share the same IO, how do you decide whether these IOs are used for USART2 or TIM2? What if you want to use USART2 and TIM2 at the same time?
1. It does not mean that you must start the RCC_APB2Periph_AFIO Clock when using the IO multiplexing function. Refer to the figure below
The AFIO clock needs to be turned on only when the AFIO event control register, AFIO remapping function and external interrupt (EXTI) control register are used. The STM32 reference manual never says that the AFIO clock must be turned on when using the IO multiplexing function. This is a misunderstanding.
For example, the most commonly used USART1 is shown below. If your board uses PA9 and PA10 as TX and TX of USART1 by default, then there is no remapping. In this case, you don't need to turn on the AFIO clock at all. You only need to turn on the USART1 peripheral clock. This experiment is very simple. You will know it by trying it yourself.
2. From the above figure, you can see that USART1 can be placed on PB6 and PB7, but almost all schematic packages will not mark the multiplexing function of PB6 and PB7 as USART1. After all, there are too many cases of remapping, and almost all peripherals can be remapped. It would be very confusing to mark each one.
In STM32, CTS, RTS, TX, RX of USART2 and CH1~CH4 of TIM2 are all on PA0~PA3. How to select these two functions?
If you want to use USART2, start the USART2 peripheral clock. If you want to use TIM2, start the TIM2 peripheral clock. If you start both at the same time, I don't know what will happen. You can try it yourself. I think neither of them should work. If you must use these two functions on PA0~PA3, you can only use time division multiplexing.
The correct way to use USART2 and TIM2 at the same time is to use the AFIO_Remap register mentioned above to remap one of them to other IOs. Of course, you cannot enable the multiplexing function of other IOs.
Back to the previous question, if you don't do Remap, you can't use these two peripherals on PA0~PA3 at the same time. Now you have two solutions:
1. Keep USART2 on the PA port and fully remap TIM2 to other IOs. Or, if you do not use the hardware flow control of RTS and CTS, the corresponding CH1 and CH2 on PA0 (CTS) and PA1 (RTS) do not need to be remapped. You only need to change Bit9:8 to 10, that is, remap CH3 and CH4 to PB10 and PB11, while CH1 and CH2 continue to remain on PA0 and PA1. However, in this case, I2C2 and USART3 on PB10 and PB11 cannot be used.
2. Keep TIM2 on the PA port and remap USART2 to the PD port. Obviously, when TIM2 is not remapped at all, the only signal line required by USART2, the Clock, is not affected. In this case, there is no partial mapping. USART2 must be completely remapped to PD3~PD7. Similarly, FSMC cannot be used in this case.
Previous article:STM32 printf issue
Next article:STM32F103RBT6 program download settings
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- Sandia Labs develops battery failure early warning technology to detect battery failures faster
- EEWORLD University Hall----Live Replay: Maxim nanoPower Technology: Extending Battery Life and Improving Sensor Performance
- How to use high-speed ADC and DAC with FPGA.pdf
- Lisp Badge (uList Badge)
- UART1 idle interrupt exception occurs when STM32F407VE replaces STM32F429VI
- C++ inheritance important understanding
- [SC8905 EVM Evaluation] + Use of the setting tool SC9805tool
- [IDE] Does IAR have a function module similar to Keil's RTE?
- FPGA Learning Experience
- The best NUCLEO-G474RE has arrived
- I don't know if it counts as a benefit. LIS3DHTR