Professional Documents
Culture Documents
LAB6 Timer
LAB6 Timer
LAB6 Timer
Faculty of Engineering
Electrical Engineering Department
PIC Lab (EELE- 4115)
Lab # 5
Timer Interrupt
BY
Submitted for
Sec. Time
Gaza, Palestine
Thursday
December 13, 2018
Objective :
To be familiar with Timer and know the important registers .
Labwork :
Q1 : Using the references I gave you explain How to Compute the delay
duration Generated By the timer ?
Figure 1
2
o T0CS: Timer0 Clock Source Select bit (External or Internal)
o T0SE: Timer0 Source Edge Select bit (high-to-low transition or low-
to-high transition on T0CKI pin)
o PSA: Timer0 Prescaler Assignment bit (bypasses prescaler or no)
o T0PS2:T0PS0: Timer0 Prescaler Select bits
▪ 111 = 1:256 Prescale value
▪ 110 = 1:128 Prescale value
▪ 101 = 1:64 Prescale value
▪ 100 = 1:32 Prescale value
▪ 011 = 1:16 Prescale value
▪ 010 = 1:8 Prescale value
▪ 001 = 1:4 Prescale value
▪ 000 = 1:2 Prescale value
Figure 2
1- INTCON Register :
o GIE/GIEH : enable global interrupts
o PEIE/GIEL : enable peripheral interrupts
2- TMR1L Timer1 Register Low Byte
3- TMR1H Timer1 Register High Byte
4- PIR1 Register :TMR1IF Timer 1 flag
5- PIE1 Register :TMR1IE Timer 1 enable
6- IPR1 Register :TMR1IP Timer 1 priority
7- T1CON: Timer1 control register:
o RD16: 16-Bit Read/Write Mode Enable bit
o T1RUN: Timer1 System Clock Status bit (from Timer1 oscillator or
another source)
o T1CKPS1:T1CKPS0: Timer1 Input Clock Prescale Select bits
o T1OSCEN: Timer1 Oscillator Enable bit
o T1SYNC: Timer1 External Clock Input Synchronization Select bit
o When TMR1CS = 1:
o 1 = Do not synchronize external clock input
o 0 = Synchronize external clock input
o When TMR1CS = 0:
o This bit is ignored. Timer1 uses the internal clock when TMR1CS = 0.
3
o TMR1CS: Timer1 Clock Source Select bit (External from
RC0/T1OSO/T13CKI pin or internal )
o TMR1ON: Timer1 On bit
Figure 3
1- INTCON Register:
o GIE/GIEH : enable global interrupts
o PEIE/GIEL : enable peripheral interrupts
4
Registers associated with Timer3
Figure 4
1- INTCON Register:
o GIE/GIEH : enable global interrupts
o PEIE/GIEL : enable peripheral interrupts
5
Q3 Using Timer0 write a program that count from 0 to 9 every 4 bush button
(with code Comments).
Figure 5
Figure 6
6
Q4 Generate delay using timer0 on led output (simple flasher).
Figure 7
Figure 8
7
Figure 9
The End