> > Immediately after I read TMR0 I also clear it, and this will prevent > > a new overflow for some time. > > Sorry, I missed this instruction. There is a slim chance that TMR0 > overflows in the same instruction when you read it. As I understand > from datasheets, read is made in the beginning of instruction cycle, > and write - in the end. So actually, there is still some room for > error. I don't know if this can matter. Best way is compare with this > (INTF part of your routine): I actually discovered this myself yesterday. If I read 0xFF from TMR0 the INTF flag is already set, and my check of the INTF-flag will actually generate a big jitter. I solved it by checking if my TIMER_STR (copy of TMR0) is 0xFF. If it is, I just skip the INTF-test. Like this: movf TMR0,0 ;Read TMR0 clrf TMR0 movwf TIMER_STR ;Store it in TIMER_STR comf TIMER_STR,0 ;Complementing it, store in W skpnz ;If it was 0xFF the Z flag will be set goto $+3 ;and the goto will be performed btfss INTCON,T0IF ;These two instructions will be skipped incf TIMER_STR+1,1 ;only if TIMER_STR == 0xFF This solved my problem! Thanks for all help. > >> > btfss INTCON,INTF ;RPM-interrupt? > >> > goto nex_chk_1 ;Nope, skip to end of handler > >> > >> > bsf STAT,0 ;Signals that an RPM pulse-count > >> > is ready > >> > >> > movf TMR0,0 > btfsc INTCON,T0IF > movlw 255 > >> > clrf TMR0 ;Clears TMR0 > >> > movwf TIMER_STR ;Stores cur. TMR0 value in > >> > TIMER_STR low byte ;btfss INTCON,T0IF ;Timer > >> > interrupt pending? ;goto $+3 > >> > ;Nope, skips next two ;instructions > >> ;incf TIMER,1 ;Increases TIMER > >> > manually > >> bcf INTCON,T0IF ;Clears the timer interrupt > >> > >> > movf TIMER,0 > >> > movwf TIMER_STR+1 ;Stores TIMER in TIMER_STR high > >> > byte clrf TIMER > >> > >> > bcf INTCON,INTF ;Clears the RPM-interrupt > > Bye, > Nikolai _______________________________________________ ¯yvind Kaurstad, oyvind@safetel.no Safetel AS P.B. 405, N-4067 Stavanger, Norway Tel: +47 51 81 78 80 (Switchboard) +47 51 81 78 82 (Office) +47 51 81 78 93 (Fax)