The one using is stm32f103rct6.
I am currently writing a program that uses a single timer to capture 4-channel PWM waves. I have to change the detection edge in the interrupt function and manually calculate the PWM frequency and pulse width by manually recording the captured values.
There are many related programs on the Internet, but when I was writing them, I encountered a very insignificant problem for beginners, which caused the results to be wrong:
As shown in the figure, I am using TIM4_CH1. Because I saw that other structures were defined by themselves before use, I defined an object 'TIM4_Type' in the 'TIM_TypeDef' structure and then found that the result was wrong.
After careful analysis, I found that this structure already has an object instance in stm32f10x.h: TIM4. And the location of this TIM4 is exactly where those registers are located, and the object 'TIM4_Type' I defined myself is in the user memory area, so no matter how I operate 'TIM4_Type', I can't get the correct result.
Later, I looked at the official manual of V3.5 and found that those 'xxx_TypeDef' structures all have their own object declarations in stm32f10x.h and their own specific memory addresses. In other words, this type of structure does not need to be defined by yourself, while other types do not have specific memory addresses, so they need to be defined by themselves before they can be operated.
Previous article:Detailed explanation of STM32's PWM output and calculation of frequency and pulse width (duty cycle)
Next article:The JTAG port of the stm32f103 series chip is used as a normal IO
Recommended ReadingLatest update time:2024-11-16 14:31
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
- General Concept of Frequency Response
- (FPGA Experiment 5): Verilog HDL language digital tube clock (hours, minutes, seconds)
- How to choose the right AFE for BMS
- Design and production of LED electronic dot matrix screen control card (provide some ideas for question I)
- HC05 and HC06 Bluetooth configuration experience summary
- Some understanding of C language memory
- VGA display image
- Two watchdogs of STM32
- [NXP Rapid IoT Review] + Mobile Synchronizer 4
- The difference between bit rate, baud rate and data transmission rate