PWM Output Mode
The STM32 PWM output has two modes, Mode 1 and Mode 2, which are determined by the OCxM bit in the TIMx_CCMRx register ("110" is Mode 1, "111" is Mode 2). The differences between Mode 1 and Mode 2 are as follows:
110: PWM mode 1 - When counting up, once TIMx_CNT
111: PWM mode 2 - When counting up, once TIMx_CNT < TIMx_CCR1, channel 1 is at an invalid level, otherwise it is at a valid level; when counting down, once TIMx_CNT > TIMx_CCR1, channel 1 is at a valid level, otherwise it is at an invalid level.
From this point of view, Mode 1 and Mode 2 complement each other and are opposite to each other, so there is not much difference in their application.
From the counting mode point of view, PWM also has up counting mode, down counting mode and center alignment mode just like TIMx when it is used as a timer. For specific information about the three modes, please refer to the "14.3.9 PWM Mode" section of the "STM32 Reference Manual". I will not go into details here.
The output pins of PWM are determined. For specific pin functions, please refer to the "8.3.7 Timer Multiplexing Function Remapping" section of the "STM32 Reference Manual". It should be emphasized here that different TIMx have different pins assigned, but considering the pin multiplexing function, STM32 proposes a concept of remapping, that is, by setting some related registers, PWM can be output on other non-originally designated pins. However, these remapped pins are also given by the reference manual. For example, the second channel of TIM3, when there is no remapping, the designated pin is PA.7. If partial remapping is set, the output of TIM3_CH2 is mapped to PB.5. If full remapping is set, the output of TIM3_CH2 is mapped to PC.7.
PWM outputs a square wave signal, the frequency of which is determined by the TIMx clock frequency and the TIMx_ARR prescaler. The specific setting method is explained in detail in the previous study notes. The duty cycle of the output signal is determined by the TIMx_CRRx register. The formula is "duty cycle = (TIMx_CRRx/TIMx_ARR)*100%", so you can output a square wave signal with the frequency and duty cycle you need by filling in the appropriate number in CRR.
Follow these steps to configure:
1.
2.
3.
4.
Here is the reference program I wrote:
{//PA13 pin configuration
}
void TIMER3_Init()
{
}
void TIMER3_PWM_Init()
{
}
Previous article:STM32 PWM input mode
Next article:10. ARM9(2440) IIC-theoretical knowledge and program examples
Recommended ReadingLatest update time:2024-11-16 08:52
- Popular Resources
- Popular amplifiers
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
- What is the purpose of the PG pin?
- [Mil MYD-YA15XC-T Review] + epoll serial communication
- TI 2018 Annual Educators Conference, friends in Wuhan, let’s get started!
- DC-DC
- Will the power supply problem not allow 32 this year?
- Practical information is here|【TI Embedded Seminar Highlights】The site has added a lot of new content
- When a computer starts the operating system, it loads the system on the disk into the memory and runs it. Does the microcontroller have a similar operating mode?
- Low-pass filter, high-pass filter, integral circuit, differential circuit
- TI C6000 Hardware Architecture Optimization Strategy
- Full of useful information! How to choose a rectifier bridge?