I would like first to thank Dave and Skimask for their answer. Actually I submitted a simplified version of the proble I got with timer.

I first tried with this. As you can see I used TIMER1 as the clock source for TIMER3. Then I read TMR3H and TMR3L in a loop.

Without any interrupt and I can't see why the Timer register is affected by how often it is read during a certain time. This is why I tried with no luck using interrupt. So the question is still the same. Why do I get different values when I use longer pause ???


DEFINE RESET_ORG 800h
DEFINE OSC 32

DEFINE LCD_LINES 4
DEFINE LCD_DREG PORTD
DEFINE LCD_RSREG PORTC
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTC
DEFINE LCD_EBIT 1

OSCCON = %11110000 '8 mhz, internal osc
OSCTUNE = %11000000 '4x PLL enabled

T1CON.7 = 1 '16 bits read/write
T1CON.6 = 0 'clock from internal osc
T1CON.5 = 1 '1:8 prescale
T1CON.4 = 1 '1:8 prescale
T1CON.3 = 0 'osc shut off
T1CON.2 = 1
T1CON.1 = 0 'Internal clock
T1CON.0 = 1 'enabled

T3CON.7 = 1 '16 bits read/write
T3CON.5 = 1 '1:8 prescale
T3CON.4 = 1 '1:8 prescale
T3CON.1 = 1 'clock from timer1
T3CON.0 = 1 'enabled

myTMR var word
myTMR = 0
TMR3H = 0
TMR3L = 0

start:
gosub gettime
LCDout $FE,1, "timer: " , #myTMR
pause 500
goto start

'pause = 50 ---> count up to 660 approx (30 sec)
'pause = 500 ---> count up to 60 approx (30 sec)

getTime
myTMR.BYTE1 = TMR3H
myTMR.BYTE0 = TMR3L
return

end