PIC16F877 Timer Modules Tutorials - PIC Timer0 Tutorial
PIC16F877 Timer Modules Tutorials - PIC Timer0 Tutorial
https://www.microcontrollerboard.com/pic-timer0-tutorial.html 1/4
21/01/2024 09:13 PIC16F877 Timer Modules tutorials | PIC timer0 tutorial
Search this web site:
PIC16F877 Timer Modules tutorials - Timer0
Search
Many times, 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.
PIC Microcontroller
Development tools 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.
Home
In this PIC timer module tutorial we will study the existing PIC timer modules. The microcontroller
PIC microcontroller kits
PIC16F877 has 3 different timers:
PIC programming books
PIC Timer0
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
PIC Introduction to PIC we could not perform any further steps while the program executes the "delay procedure"
PIC Memory Organization
Now, using Timers we can build a very precise time delays which will be based on the system clock
Microchip MPLAB IDE 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
HI-TECH compiler
one of them. We will study each one separately.
Microcontroller Board
PIC Timer0 tutorial
PIC USB Programmer
The Timer0 module timer/counter has the following features:
PIC Debuger
8-bit timer/counter
PIC Timer Modules
PIC Interrupts Let’s explain the features of PIC Timer0 we have listed above:
PIC A/D converter Timer0 has a register called TMR0 Register, which is 8 bits of size.
We can write the desired value into the register which will be increment as the program progresses.
PIC Microcontroller Frequency varies depending on the Prescaler. Maximum value that can be assigned to this register
Projects is 255.
1:2
1:4
1:8
1:16
1:32
1:64
1:128
1:256
https://www.microcontrollerboard.com/pic-timer0-tutorial.html 2/4
21/01/2024 09:13 PIC16F877 Timer Modules tutorials | PIC timer0 tutorial
We perform all the necessary settings with OPTION_REG Register. The size of the register is 8 bits.
Click the link to explore the relevant bits of OPTION_REG Register
Suppose we want to create a delay of 0.5 second in the our program using Timer0. What is the
value of Count?
Calculation:
First, let’s assume that the frequency division by the Prescaler will be 1:256. Second, let’s set
TMR0=0. Thus:
https://www.microcontrollerboard.com/pic-timer0-tutorial.html 3/4
21/01/2024 09:13 PIC16F877 Timer Modules tutorials | PIC timer0 tutorial
If using EXTERNAL clock source (oscillator), the division is performed as follow:
In this case there is no division by 4 of the original clock. We use the external frequency as it is.
What is the output frequency - Fout, when the external oscillator is 100kHz and Count=8?
Calculation:
First, let’s assume that the frequency division by the Prescaler will be 1:256. Second, let’s set
TMR0=0. Thus:
https://www.microcontrollerboard.com/pic-timer0-tutorial.html 4/4