PDA

View Full Version : Timer3 Problems



Joe Rocci
- 27th November 2006, 18:04
I'm having problems making timer3 on my PIC18F2620 work. I want to use the external 20Mhz clock source to toggle the counter. Eventually. I want to generate an interrupt everytime the counter overflows, but I can't seem to even make it count. To test whether the counter is counting or not, I put in a simple test that turns a LED on until the counter overflows, then turns it off. The LED is always on, so I assume the counter isn't counting. Here is the code:

'*************************************************
TMR3ON VAR T3CON.BIT0
TMR3CS VAR T3CON.BIT1
T3SYNC VAR T3CON.BIT2
T3CKPS0 VAR T3CON.BIT4
T3CKPS1 VAR T3CON.BIT5
T3CCP1 VAR T3CON.BIT3
T3CCP2 VAR T3CON.BIT6
RD16 VAR T3CON.BIT7
TMR3IE VAR PIE2.BIT1
TMR3IF VAR PIR2.BIT1
GIEH var INTCON.bit7
GIEL var INTCON.bit6

TMR3ON = 1 ' ENABLE TIMER3
TMR3CS = 0 ' TRIGGERED BY Fosc/4
T3SYNC = 1 ' USE INTERNAL CLOCK
T3CKPS0 = 1 ' PRESCALER = 8
T3CKPS1 = 1 ' PRESCALER = 8
T3CCP1 = 1
T3CCP2 = 1
RD16 = 0 ' 8 BIT READ/WRITE/MODE
TMR3IE = 1 ' TIMER3 INTERRUPTS ENABLED
GIEH = 1
GIEL = 1

LOOP:
if tmr3if = 1 then
LED = 1
else
LED = 0
endif
GOTO LOOP
'************************************************* ***
Can someone suggest what I'm doing wrong, or not doing at all???

Joe

Joe Rocci
- 27th November 2006, 19:18
I got this working gang. Problem was that I had the interrupt enable bit set, but no interrupt handler.

Joe