hodahussein
Full Member level 2
hi
i am using pic18f87k22 in our product battery charger, so we need to use timer 3 and timer 5 and timer 7
for Timer3 the initialization code as following
so it work as we want after TMR overflow the interrupt is occurred.
for timer 5
first problem in Timer 5 the pre-scale is adjusted with 1:2 so we observed that the timer count each 8 cycle not 2 cycle
second problem the interrupt did not happen although the flag bit "PIR5,TMR5IF" become one
========
for timer 7
the timer 7 will count each 2 cycle ok the pre scale is right
but also the interrupt not happen
i need to fix this problem
thanks
i am using pic18f87k22 in our product battery charger, so we need to use timer 3 and timer 5 and timer 7
for Timer3 the initialization code as following
Code:
CLRF TMR3H
CLRF TMR3L
MOVLW B'01011000'
MOVWF T3CON
clrf T3GCON
bcf PIR2,TMR3GIF
bcf PIR2,TMR3IF
bsf PIE2,TMR3IE
bsf T3CON,TMR3ON
so it work as we want after TMR overflow the interrupt is occurred.
for timer 5
Code:
CLRF TMR5H
CLRF TMR5L
clrf T5GCON
MOVLW B'00011000'
MOVWF T5CON
bcf PIR3,TMR5GIE
bcf PIR3,TMR5GIF
bcf PIR5,TMR5IF
bsf PIE5,TMR5IE
bSf T5CON,TMR5ON
BSF INTCON,GIE
BSF INTCON,PEIE
second problem the interrupt did not happen although the flag bit "PIR5,TMR5IF" become one
========
for timer 7
Code:
banksel T7CON
MOVLW B'00011000'
MOVWF T7CON
clrf T7GCON
CLRF TMR7H
CLRF TMR7L
bsf T7CON,TMR7ON
CLRF BSR
bcf PIR5,TMR7GIF
bcf PIR5,TMR7IF
bsf PIE5,TMR7IE
bCf PIE5,TMR7GIE
bCf IPR5,TMR7IP
CLRF BSR
BSF INTCON,GIE
BSF INTCON,PEIE
but also the interrupt not happen
i need to fix this problem
thanks
Last edited by a moderator: