Assuming the system clock is 72Mhz, TIM1 is obtained from PCLK2 (72MHz), and TIM2-7 is obtained from PCLK1.
The key is to set the clock pre-division number and the value of the automatic reload register period.
Basic settings of the timer
1. TIM_TimeBaseStructure.TIM_Prescaler = 7199; //Clock pre-division number For example:
clock frequency = 72/(clock pre-division + 1)
2. TIM_TimeBaseStructure.TIM_Period = 9999; //The value of the automatic reload register period (timing
time) accumulates 0xFFFF frequencies and generates an update or interrupt (that is, the timing time is up)
3. TIM_TimeBaseStructure.TIM_CounterMode = TIM1_CounterMode_Up; //Timer
mode counts up
4. TIM_TimeBaseStructure.TIM_ClockDivision = 0x0; //Time division value
5. TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);//Initialize timer 2
6. TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); //Enable interrupt overflow interrupt
7. TIM_Cmd(TIM2, ENABLE);//Enable timer
Or:
TIM_TimeBaseStructure.TIM_Prescaler = 35999;//Division frequency 35999 72M/
(35999+1)/2=1Hz Interrupt overflow once per second
TIM_TimeBaseStructure.TIM_Period = 2000; //Count value 2000
((1+TIM_Prescaler )/72M)*(1+TIM_Period )=((1+35999)/72M)*(1+2000)=1 second*/
Keywords:STM32
Reference address:STM32 timer timing calculation
The key is to set the clock pre-division number and the value of the automatic reload register period.
Basic settings of the timer
clock frequency = 72/(clock pre-division + 1)
time)
mode
Or:
TIM_TimeBaseStructure.TIM_Prescaler = 35999;//Division frequency 35999
(35999+1)/2=1Hz
TIM_TimeBaseStructure.TIM_Period = 2000; //Count value 2000
((1+TIM_Prescaler )/72M)*(1+TIM_Period )=((1+35999)/72M)*(1+2000)=1 second*/
Previous article:STM32 Development Board Getting Started Tutorial (I) GPIO
Next article:STM32 interrupts and nested NVIC quick start
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
Guess you like
- ESD resistance of capacitors
- Date in spring + small flowers blooming in the spring bushes
- [Sipeed LicheeRV 86 Panel Review] Debian Python + Serial Communication
- What is the 5G battle about?
- Zero-based development of WIFI devices
- A detailed description of the development history of Bluetooth technology from 1.0 to 5.0
- Fundamentals of mmWave Sensors (mmWave Training Series)
- Tuya Smart Module SDK Development Course Series - 2. Introduction to Tuya IoT Platform
- C2000 Software Serial Interface (SCI) Implementation Method
- Differences between different versions of TI's ZigBee protocol stack