1. MICROCONTROLLER BASED SYSTEM DESIGN
“TIMER 2 CONCEPT”
V. KALAIRAJAN M.E;
ASSISTANT PROFESSOR,
ELECTRICAL AND ELECTRONICS ENGINEERING,
KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY.
1KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER2 CONCEPT
2. “TIMER 2 CONCEPT”
VIEWS:
TIMER.
TYPES OF TIMER.
TIMER2 MODULE.
PRESCALER - FREQUENCY DIVIDER.
POSTSCALER - FREQUENCY DIVIDER.
THE STRUCTURE OF THE OPTION_REG REGISTER.
BLOCK DIAGRAM OF THE TIMER2 MODULE.
PIC TIMER2 FORMULA.
KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER2 CONCEPT 2
3. “TIMER 2 CONCEPT”
TIMER:
Now a days, we plan and build systems that perform various
processes that depend on time.
Simple example of this process is the digital wristwatch. The role
of this electronic system is to display time in a very precise
manner and change the display every second (for seconds), every
minute (for minutes) and so on.
To perform the steps we've listed, the system must use a timer,
which needs to be very accurate in order to take necessary actions.
The clock is actually a core of any electronic system.
Each module can generate an interrupt to indicate that an event has
occurred (i.e. timer overflow). The timer modules are:
Timer0 Module
Timer1 Module
Timer2 Module
3KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER2 CONCEPT
4. “TIMER 2 CONCEPT”
TIMER 2 MODULE:
The Timer2 module, timer/counter, has the following features:
Two 8-bit registers (TMR2 and PR2).
Readable and writable.
A prescaler and a postscaler.
Connected only to an internal clock - 4 MHz crystal.
Interrupt on overflow.
PRESCALER - FREQUENCY DIVIDER:
The prescaler allows Timer2 to increment at the following rates:
1:1, 1:4, 1:16.
POSTSCALER - FREQUENCY DIVIDER:
The postscaler can be programmed from 1:1 to 1:16 (inclusive).
4KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER2 CONCEPT
5. “TIMER 2 CONCEPT”
THE STRUCTURE OF THE OPTION_REG REGISTER:
We perform all the necessary settings with T2CON Register The
structure of the T2CON register. The size of the register is 8 bits
INITIALIZING THE OPTION_REG REGISTER:
The following is an example how we can initialize the T2CON
register:
1. TMR2ON=1; // the timer is enable
2. T2CKPS0=0; // Prescaler – 1:1
3. T2CKPS1=0;
4. TOUTPS0=1; // Postscaler – 1:16
5. TOUTPS0=1;
6. TOUTPS0=1;
7. TOUTPS0=1;
Or you can set all the T2CON register at once as follows:
T2CON=0b01111100;
5
KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER2 CONCEPT
6. “TIMER 2 CONCEPT”
BLOCK DIAGRAM OF THE TIMER2 MODULE:
6KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER2 CONCEPT
7. “TIMER 2 CONCEPT”
Timer2 is an 8-bit timer with a programmable prescaler and
postscaler, as well as an 8-bit period register (PR2).
Timer2 can be used with the CCP1 module (in PWM mode) as
well as the Baud Rate Generator for the Synchronous Serial Port
(SSP).
Timer2 is an 8-bit timer with a prescaler and a postscaler. It can be
used as the PWM time-base for PWM mode of the CCP
module(s).
The TMR2 register is readable and writable, and is cleared on any
device reset.
7KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER2 CONCEPT
8. “TIMER 2 CONCEPT”
PIC TIMER2 formula:
Fout - The output frequency after the division.
Tout - The Cycle Time after the division
4 - The division of the original clock (4 MHz) by 4, when
using internal crystal as clock (and not external oscillator).
Count - A numeric value to be placed to obtain the desired output
Frequency-fuot.
(PR2 – TMR2) - The number of times the counter will count.
8KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER2 CONCEPT
9. “TIMER 0 CONCEPT”
CONCLUSION:
In this above presentation we can learn about basic concept of
Timer, types of timer, timer2, features, pre and post scaler -
frequency divider clearly.
REFERENCES:
Mazidi, M.A.,“PIC Microcontroller” Rollin Mckinlay, Danny
causey Printice Hall of India, 2007.
Ravichandran,C., and Arulaalan,M., “Microcontroller Based
System Design”, Suchitra Publications, Ist edition,2016.
Dr.Balamurugan.C.R., Periyaazhagar., “Microcontroller Based
System Design”, Megnus Publications, Ist edition,2016.
Online wikipedia search.
9KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER2 CONCEPT