5 types of work
Normal mode WGM1 = 0 is similar to the normal mode of 51, with TOV1 overflow interrupt flag, which occurs when MAX (0xFFFF)
1. Use the internal counting clock for ICP capture input occasions - measuring pulse width/infrared decoding (the capture input function can work in multiple modes, not just the normal mode)
2. Use external counting pulse input for counting, frequency measurement and other applications. It is more convenient to use other modes without the trouble of 51.
Dual CTC mode [Compare match clear timer mode] WGM1=4, 12 is similar to 51 in auto-reload mode
1. Used to output square wave signal with 50% duty cycle
2. Used to generate accurate continuous timing signal. When WGM1=4, the maximum value is set by OCR1A, and the OCF1A compare match interrupt flag is generated when TOP. When WGM1=12, the maximum value is set by ICF1, and the ICF1 input capture interrupt flag is generated when TOP.
If TOP = MAX, a TOV1 overflow interrupt flag will also be generated during TOP.
Note: When WGM=15, square wave output from OC1A can also be realized, and double buffer function is available.
Calculation formula: fOCn=fclk_IO/(2*N*(1+TOP)) The variable N represents the pre-division factor (1, 8, 64, 256, 1024), and T2 has two more levels (32, 128).
3. Fast PWM mode WGM1=5, 6, 7, 14, 15 single ramp counting, used to output high frequency PWM signal (twice the frequency of double ramp), all have TOV1 overflow interrupt, when it occurs in TOP [not MAX, different from normal mode and CTC mode], after comparison match, OCF1x comparison match interrupt can be generated.
When WGM1=5, the maximum value is 0x00FF, 8-bit resolution
When WGM1=6, the maximum value is 0x01FF, 9-bit resolution
When WGM1=7, the maximum value is 0x03FF, 10-bit resolution
When WGM1=14, the maximum value is set by ICF1, and an ICF1 input capture interrupt is generated at TOP (single buffer)
When WGM1=15, the maximum value is set by OCRF1A, and OCRF1A compare match interrupt is generated at TOP (double buffering, but OCRF1A will not have PWM capability and can only output square wave at most). When changing the TOP value, it must be ensured that the new TOP value is not less than the value of all compare registers.
Note that even if OCR1A/B is set to 0x0000, a narrow pulse of a timer clock cycle will be output instead of being always low.
Calculation formula: fPWM=fclk_IO/(N*(1+TOP))
4. Phase correction PWM mode WGM1=1, 2, 3, 10, 11 dual ramp counting, used to output high-precision, phase-accurate, symmetrical PWM signals. All have TOV1 overflow interrupt, but when it occurs in BOOTOM, it can generate OCF1x compare match interrupt after compare match.
When WGM1=1, the maximum value is 0x00FF, 8-bit resolution
When WGM1=2, the maximum value is 0x01FF, 9-bit resolution
When WGM1=3, the maximum value is 0x03FF, 10-bit resolution
When WGM1=10, the maximum value is set by ICF1, and an ICF1 input capture interrupt is generated at TOP (single buffer)
When WGM1=11, the maximum value is set by OCRR1A, and OCFR1A compare match interrupt is generated at TOP (double buffering, but OCFR1A will not have PWM capability, and can only output square wave at most). When changing the TOP value, it must be ensured that the new TOP value is not less than the value of all comparison registers. A PWM signal with a duty cycle of 0% to 100% can be output. If the TOP value is to be changed during T/C operation, it is best to use the phase and frequency correction mode instead of the phase correction mode. If TOP remains unchanged, there is actually no difference between these two working modes.
Calculation formula: fPWM=fclk_IO/(2*N*TOP)
5. Phase and frequency correction PWM mode WGM1=8,9 dual ramp counting is used to output high-precision PWM waveform with accurate phase and frequency. There is TOV1 overflow interrupt, but when it occurs in BOOTOM, OCF1x compare match interrupt can be generated after compare match.
When WGM1=8, the maximum value is set by ICF1, and an ICF1 input capture interrupt is generated at TOP (single buffer)
When WGM1=9, the maximum value is set by OCR1A, and an OCF1A compare match interrupt is generated at TOP (double buffering, but OCR1A will not have PWM capability and can only output square waves at most) Phase-frequency correction The main difference between the corrected PWM mode and the phase-corrected PWM mode is the update time of the OCR1x register. When changing the TOP value, it must be ensured that the new TOP value is not less than the value of all comparison registers. A PWM signal with a duty cycle of 0% to 100% can be output. When using a fixed TOP value, it is best to use the ICR1 register to define the TOP. In this way, OCR1A can be used to output a PWM wave at OC1A. However, if the PWM base frequency is constantly changing (by changing the TOP value), the double buffering feature of OCR1A makes it more suitable for this application.
Calculation formula: fPWM=fclk_IO/(2*N*TOP)
Previous article:Design of air detector based on AVR microcontroller
Next article:AVR microcontroller's CPU core structure and assembly language
Recommended ReadingLatest update time:2024-11-16 11:59
- 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
- Melexis for you: Detailed explanation of the implementation and technical support of functional safety in semiconductor R&D. Registration for the prize-winning live broadcast is open!
- One week evaluation report~
- Six key issues when designing a universal serial bus protocol interface
- Reference book on porting from SXX32F103 to MH32F103A
- Good book recommendation! A brief review of Luo's "Basics of Power Supply Design"
- Please give me some advice, is this an amplifier impedance issue?
- Will the wave of Internet layoffs in 2019 have an impact on salary negotiations when changing jobs?
- STEVAL-MKI109V3 Basics
- TI-RTOS Kernel (SYS/BIOS) User's Guide
- PIC24F, clock frequency 8MHZ, after testing ONE_SECOND is not one second, what's going on?