The following is the timer logic diagram of STM32 , which helps to understand:
TIM3's ARR register and PSC register,
Determine the PWM frequency.
The two timers configured here determine the frequency of PWM. My understanding is that the period (frequency) of PWM is the multiplication of the ARR register value and the PSC register value, but it is not a simple multiplication. For example, to set the frequency of PWM, refer to the algorithm for setting the overflow time in the last general timer. For example, to output PWM with a frequency of 100HZ, first determine the clock of TIMx. Unless the clock division number of APB1 is set to 1, the clock of the general timer TIMx is twice the clock of APB1. At this time, the clock of TIMx is The value is 72MHz. Divide the TIMx clock 72MHz by (PSC+1) to get the timer increment every few seconds. Here, assign 7199 to PSC, and calculate that the timer increments every 0.0001 seconds, that is, the frequency is 10KHz. Multiply this value by (ARR+1) to get the PWM frequency. If the ARR value is 0, that is, 0.0001*(0+1), the output PWM frequency is 10KHz. If the output frequency is 100Hz PWM, set the ARR register to 99. If you want to adjust the PWM duty cycle accuracy, just reduce the value of the PSC register.
The TIMx_CCRx register determines the PWM duty cycle.
TIMx_CCR1-TIMx_CCR4 determine the duty cycle of the four PWM channels CH1-CH4 of the timer. Simply assign a value of 0-65535 to this register to determine the duty cycle. Duty cycle calculation method: The value of TIMx_CCRx divided by the value of the ARR register is the duty cycle. Because the duty cycle is between 0-100%, the value of the TIMx_CCRx register cannot exceed the value of the ARR register, otherwise it may cause the accuracy of the PWM frequency or duty cycle.
Previous article:Newbie benefits! Detailed explanation of uCGUI transplantation for STM32 learning
Next article:Before learning ARM, you need to know these
- 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
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- ad14 always wait a moment when opening
- A novice’s question is, how to find the most suitable chip when making hardware?
- How to create beam-forming smart antennas using FPGAS
- 64 details that must be paid attention to in switching power supply design
- Domestic voltage regulator device
- CC2650 launchpad and msp432 launchpad
- Switching Power Supply Interest Group 19th Task
- LED power supply not working
- Smart MM32 + UCOS + uCGUI
- How to decorate a chemical analysis room?