Timer Lab

Submitted by: Submitted by

Views: 27

Words: 673

Pages: 3

Category: Science and Technology

Date Submitted: 03/15/2015 04:40 AM

Report This Essay

LAB REPORT

(AMME)

USE OF TIMERS AND INTERRUPT SERVICE ROUTINES IN PIC18 MICROCONTROLLER

SUBMITTED BY: MUHAMMAD AMMAR ALI

BSME 2010-2014

ROLL# 30

SUBMITTED TO: DR. NASIR JADOON

ABSTRACT:

In this lab we used built-in timer and ISR (Interrupt Service Routines) feature of PIC18 microcontrollers. Both of the features were used in a single code to understand how these features can be used simultaneously.

INTRODUCTION:

The PIC18 has two to five timers depending upon the family member. They are referred to as Timer 0,1,2,3 and 4. They can be used either as timers to generate delays or as counters to count events happening outside the microcontroller.

Timer TMR0

The timer TMR0 has a wide range of applications in practice. Very few programs don't use it in some way. It is very convenient and easy to use for writing programs or subroutines for generating pulses of arbitrary duration, time measurement or counting external pulses (events) with almost no limitations.

Timer0 can be used as an 8-bit 16-bit timer. The 16-bit register of Timer0 as accessed as low byte and high byte. The low byte register is called TMR0L and high byte register is called TMR0H.

Figure 1 TMR0 schematic with all bits which determine its operation.

T0CON Register:

Each timer has control register, called TCON, to set the various timer operation modes. T0CON is an 8-bit register used for control of Timer0.

Figure 2 T0CON Register

Interrupt Service Routines (ISR):

For every interrupt there must be an interrupt service routine or interrupt handler. When an interrupt is invoked, the microcontroller runs the ISR. Generally, in most microcontrollers, for every interrupt there is fixed location in memory that holds the address of its ISR. The group of memory locations set aside to hold the addresses of ISR’s is called the...