Today, under the guidance of a low-level expert, I learned how to configure the PWM module! Woof!
First open the file configured last time, as follows:
Then, we need to use TIM1 to set PWM:
Then, the clock configuration does not need to be changed
.
Double-click and the following window will pop up automatically:
Box 1 is the pre-scaling. Since the main frequency of our chip is 72MHz, the pre-scaling selection of 71 means that the timing frequency of this timer is actually 72M/(1+71)=1MHz, that is, the time interval for each addition (incremental count) or subtraction (decremental count) of this timer is 1/1M=1 microsecond.
Box 2 is the period length of the timer counter. Here, 10000 is written, which means that every time the counter reaches 10000, it will be reset and start counting again. This number determines the period of the PWM wave. Here, the period of the PWM wave is 1uS*10000=0.01S.
Boxes 3 and 4 are the variables that determine the duty cycle of the two channels. 3000 means 3000/10000=30%, a thirty percent duty cycle. 4000 here means a 40% duty cycle.
In the same window, select a different page:
NVIC is an interrupt priority manager. Since PWM does not generate interrupts here, this interrupt is optional. We do not select it here.
Then code generate.
Then
Add these two sentences! Then you can find the PWM wave in those two ports! (After testing, there is no problem so far)
Ps: Use library function:
The structure of opening Lib is probably like this:
The content is as follows:
Add the Lib file to the location just shown, build the required files, and then join the Lib group:
Then package compilation path:
After writing, sprinkle flowers
Previous article:STM32CubeMX: UART operation
Next article:STM32CubeMX:PWM
Recommended ReadingLatest update time:2024-11-16 12:01
- Popular Resources
- Popular amplifiers
- Network Operating System (Edited by Li Zhixi)
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- MATLAB and FPGA implementation of wireless communication
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
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
- 【RPi PICO】Breathing light
- Why does the resolution decrease when the gain is increased?
- Evaluation of the domestic FPGA Gaoyun GW1N-4 series development board - Software Part 2
- A busbar power supply plant power rapid protection anti-sway cabinet
- How to put C2000 into low power mode
- GD32F350 is easy to use
- Industrial and Automation Solutions Collection
- Award-winning live broadcast | Use ModusToolbox to build a system to flexibly meet IoT design challenges
- Verilog009
- 5G is a revolutionary advancement in mobile communications