I am currently developing an LED light product using the stm8s003 MCU. I am using the PWM output function of TIM2, using TIM2_CHANNEL3, and the PA3 pin is multiplexed as TIM2_CH3.
1. How to reuse the PA3 pin as TIM2_CH3
The pin multiplexing function of stm8MCU is not like the NXP MCU or 51MCU I have used before. The NXP MCU pins used before have dedicated pin function configuration registers, and the pins can be configured to different functions through the configuration registers. The pins of stm8MCU have a main function (after reset), which is the main function of the pin after reset. In addition, the pin has a default alternet function, for example: the default alternet function of PA3 is TIM2_CH3. If you want to use TIM2_CH3, you only need to configure the TIM2_CH3 function when TIMER2 is initialized and enable TIMER2 to use the TIM2_CH3 function.
In the pin description of stm8MCU, you can also see that the pin has an alternet function after remap [option bit]. The function in [ ] refers to the pin function that can be realized by configuring AFR through STVP software.
2. Output status of PWM function pin after stm8 timer stops
After the stm8s timer function stops, the PWM function output of the channel pin corresponding to the timer is in an uncertain state. So if you want to keep the PWM function pin in a certain state after turning off the timer, such as turning off the PWM function and outputting a low level. This requires configuring the CCMR1 register of the timer. As shown below, using the library function, after TIMER2 is turned off, keep the pin output low level:
TIM2_Cmd(DISABLE);
/* Pull the level to low after stopping PWM */
TIM2_ForcedOC1Config(TIM2_FORCEDACTION_INACTIVE);
Previous article:STM8 timer TIM1 timing
Next article:Setting the level when stm8 pwm stops
Recommended ReadingLatest update time:2024-11-16 11:48
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
- Intelligent Control Technology of Permanent Magnet Synchronous Motor (Written by Wang Jun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- 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
- MATLAB and FPGA implementation of digital modulation and demodulation technology - Altera/Verilog version
- STM32 study notes on the use of GPIO ports
- The first batch of shortlisted ideas are for netizens' reference - 9 days left to register for the Pingtouge RISC-V development board event
- STM32 controls WS2812D full-color LED
- Thonny Automatically set the time
- 77Ghz single-chip millimeter wave sensor enables automatic parking
- All employees dismissed! Shenzhen's old power supply factory suddenly stopped production
- [Mil MYC-JX8MPQ Review] + Unboxing
- Huawei base station equipment cavity filter disassembly
- ADI-based intelligent temperature transmitter reference design information