1. MICROCONTROLLER BASED SYSTEM DESIGN
“TIMER 0 CONCEPT”
V.KALAIRAJAN M.E;
ASSISTANT PROFESSOR,
ELECTRICALAND ELECTRONICS ENGINEERING
KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY,TRICHY
KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER 0 CONCEPT 1
2. “TIMER 0 CONCEPT”
VIEWS:
TIMER.
TYPES OF TIMER.
TIMER0 MODULE.
PRESCALER - FREQUENCY DIVIDER.
THE STRUCTURE OF THE OPTION_REG REGISTER.
BLOCK DIAGRAM OF THE TIMER0 MODULE.
PIC TIMER0 FORMULA FOR INTERNAL CLOCK.
PIC TIMER0 FORMULA FOR EXTERNAL CLOCK.
PROGRAM FOR DELAY OF 1 SEC USING TIMER0.
KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER 0 CONCEPT 2
3. “TIMER 0 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 TIMER 0 CONCEPT
4. “TIMER 0 CONCEPT”
TIMER0 MODULE:
The Timer0 module timer/counter has the following features:
8-bit timer/counter
Readable and writable
8-bit software programmable prescaler
Internal or external clock select
Interrupt on overflow from FFh to 00h
Edge select for external clock
PRESCALER - FREQUENCY DIVIDER:
We can use Prescaler for further division of the system clock. The
options are:
1:2, 4, 8, 16, 32, 64, 128, 256
4KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER 0 CONCEPT
5. “TIMER 0 CONCEPT”
THE STRUCTURE OF THE OPTION_REG REGISTER:
We perform all the necessary settings with OPTION_REG Register. The
size of the register is 8 bits.
INITIALIZING THE OPTION_REG REGISTER:
The following is an example how we can initialize the OPTION_REG:
PSA=0; // Prescaler is assigned to the Timer0 module
PS0=1; // Prescaler rate bits
PS1=1; // are set to “111”
PS2=1; // which means divide by 256
TOSE=0; // rising edge
TOCS=0; // Internal instruction cycle clock
5KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER 0 CONCEPT
7. “TIMER 0 CONCEPT”
Timer mode is selected by clearing bit T0CS (OPTION<5>).
In timer mode, the Timer0 module will increment every
instruction cycle (without prescaler).
If the TMR0 register is written, the increment is inhibited for
the following two instruction cycles.
The user can work around this by writing an adjusted value
to the TMR0 register. Counter mode is selected by setting bit
T0CS (OPTION<5>).
In counter mode, Timer0 will increment either on every
rising or falling edge of pin RA4/T0CKI.
The incrementing edge is determined by the Timer0 Source
Edge Select bit T0SE (OPTION<4>). Clearing bit T0SE
selects the rising edge. Restrictions on the external clock
input
7KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER 0 CONCEPT
8. “TIMER 0 CONCEPT”
PIC TIMER0 formula for internal clock:
PIC TIMER0 formula for external clock:
8KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER 0 CONCEPT
9. “TIMER 0 CONCEPT”
Program for Delay of 1 sec using Timer0:
9KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER 0 CONCEPT
10. “TIMER 0 CONCEPT”
CONCLUSION:
In this above presentation we can learn about basic concept of
Timer, types of timer, timer0, features, prescaler - 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.
10KONGUNADU COLLEGE OF ENGINERING AND TECHNOLOGY, TRICHY TIMER 0 CONCEPT