PIC16F877 Timer Modules Tutorials - PIC Timer0 Tutorial PDF
PIC16F877 Timer Modules Tutorials - PIC Timer0 Tutorial PDF
http://www.microcontrollerboard.com/pic-timer0-tutorial.html
Contact us
Blog
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
EDUPIC microcontroller board
order to take necessary actions.The clock is actually a core of any electronic system. In this PIC timer module tutorial we will study the existing PIC timer modules. The microcontroller PIC16F877 has 3 different timers: PIC Timer0
ICP2 USB programmer
PIC Introduction to PIC PIC Memory Organization Microchip MPLAB IDE HI-TECH compiler Microcontroller Board PIC USB Programmer PIC Debuger
PIC Timer Modules
PIC Timer1 PIC Timer2 We can use these timers for various important purposes. So far we used delay procedure to implement some delay in the program, that was counting up to a specific value, before the program could be continued. "Delay procedure" had two disadvantages: we could not say exactly how long the Delay procedure was in progress we could not perform any further steps while the program executes the "delay procedure" Now, using Timers we can build a very precise time delays which will be based on the system clock and allow us to achieve our desired time delay well-known in advance. In order for us to know how to work with these timers, we need to learn some things about each one of them. We will study each one separately.
The Timer0 module timer/counter has the following features: 8-bit timer/counter Readable and writable 8-bit software programmable prescaler
Internal (4 Mhz) or external clock select Interrupt on overflow from FFh to 00h Edge select (rising or falling) for external clock Lets explain the features of PIC Timer0 we have listed above:
General
We can write the desired value into the register which will be increment as the program progresses. Frequency varies depending on the Prescaler. Maximum value that can be assigned to this register is 255.
1 of 3
11/01/2013 10:39
http://www.microcontrollerboard.com/pic-timer0-tutorial.html
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 - Fout. (256 - TMR0) - The number of times in the timer will count based on the register TMR0.
Calculation:
First, lets assume that the frequency division by the Prescaler will be 1:256. Second, lets set TMR0=0. Thus:
2 of 3
11/01/2013 10:39
http://www.microcontrollerboard.com/pic-timer0-tutorial.html
In this case there is no division by 4 of the original clock. We use the external frequency as it is.
Calculation:
First, lets assume that the frequency division by the Prescaler will be 1:256. Second, lets set TMR0=0. Thus:
Contact Page
3 of 3
11/01/2013 10:39