Hi
I am beginner in PIC programming. I need help with Timer1 in PIC 16F877.
My code is:
list p=16f877a
#include <p16f877A.inc>
org 000
goto start
org 004
nop
retfie
start
bsf STATUS,RP0
bsf PIE1,0
bcf STATUS,RP0
bsf INTCON,7
bsf T1CON,0
man
nop
nop
nop
goto man
end
My problem: I will not receive the interrupt when the Timer1 overflows and I don't know why. The PIR1 <0> bit is correctly set to log1 on overflow. But the interrupt routine don't start. I use the PIC simulator MPLAB IDE 6.6 and MPLAB SIM debugger.
I think it does not matter. There is some value and when the timer is running, it will overflow soon or later. I try your advice but there is the same problem.
Code:
list p=16f877a
#include <p16f877A.inc>
org 000
goto start
org 004
nop ;interrupt routine - doesn't work
retfie
start
bsf STATUS,RP0
bsf PIE1,0 ;allow timer1 interrupt
bcf STATUS,RP0
bsf INTCON,7 ;allow global interrupt
movlw 000h
movwf TMR1L ;set the value
movwf TMR1H
bsf T1CON,0 ;run timer
man
nop
nop
nop
goto man
end
I think it does not matter. There is some value and when the timer is running, it will overflow soon or later. I try your advice but there is the same problem.
The interrupt flag for timer1 is PIR1<0> and it is set to log0 at the start of program. When the timer overflows it is set to log1. This part works but the interrupt is not generated so its routine can't clear the flag to log0.