PIC microcontroller learning TMR2

Publisher:老卫Latest update time:2016-08-04 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The width of TMR2 is 8 bits, the same as TMR0, and it usually appears together with the CCP module and PWM function.

 

The 8-bit TMR2 timer has a pre-prescaler and a post-prescaler, and a cycle control register that works together with it to count the instruction cycles of the microcontroller.

 

TMR2 can only be used as a timer and cannot count external input pulses.

 

The biggest difference between TMR2 timer and TMR0 is that TMR2 has a cycle control register PR2. The PR2 register can set the upper limit of the timer. As long as the count value of TMR2 is equal to the set value of PR2, it will automatically return to 0 and generate an interrupt.

 

When the count value of TMR2 matches the value set in the PR2 register, the arrival of a count pulse should cause TMR2 to overflow to 0. Note: After a count overflows to 0, the TMR2IF interrupt flag is not necessarily generated immediately. When the interrupt flag is generated depends on the division ratio of the post-divider. If the selected post-divider ratio is 1:8, an interrupt will be generated only after TMR2 overflows 8 times.


//Pre-divider 
//T2CKPS1 T2CKPS0 
// 0 0 1 division TMR1 clock is crystal clock/(4*1) 
// 0 1 4 division TMR1 clock is crystal clock/(4*4) 
// 1 x 16 division TMR1 clock is crystal clock/(4*16) 
//Post-divider 
//TOUTPS3 TOUTPS2 TOUTPS1 TOUTPS0 
// 0 0 0 0 1 division 
// 0 0 0 1 2 division 
// 0 0 1 0 3 division 
// 0 0 1 1 4 division 
// 0 1 0 0 5 division// 0 1 0 
1 6 division 
// 0 1 1 0 7 division 
// 0 1 1 1 8 division 
// 1 0 0 0 9 division 
// 1 0 0 1 10-way division 
// 1 0 1 0 11-way division 
// 1 0 1 1 12-way division 
// 1 1 0 0 13-way division 
// 1 1 0 1 14-way division 
// 1 1 1 0 15-way division 
// 1 1 1 1 16-way division

Reference address:PIC microcontroller learning TMR2

Previous article:PIC16F877A Watchdog Timer Experiment
Next article:PIC16F877A TIMER1 counting operation

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号