> Hello Xyvind, Not to be picky, but my first name does not start with an 'X'... It's a Norwegian special character that is probably displayed as an 'X' on your screen, but it really looks like an 'O' with a slash across. It does sound a bit exotic, though... Xyvind... > Again, you leave the room for error. Even if you read TMR0 and then > check for TMR0 overflow, this doesn't solve the problem. TMR0 can read > 255 and overflow before you check T0IF. So you get the error again. Hmm. I don't understand this. If TMR0 overflows sometime in the beginning of the ISR (during context save, for instance) this will be detected by my check. I will read a low TMR0 value, but the high byte will be increased since I check the INTCON,T0IF flag a tad later. Immediately after I read TMR0 I also clear it, and this will prevent a new overflow for some time. Can you please explain in detail how this can go wrong? > Nikolai > > On Tuesday, February 08, 2000 Xyvind Kaurstad wrote: > [snip] > > The current ISR looks like this: > > > org 0x04 > > > movwf W_TEMP > > swapf STATUS,0 > > bcf STATUS,RP0 > > movwf STAT_TEMP ;Saves W and STATUS registers > > > 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 > > 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 > > > nex_chk_1 > > > btfss INTCON,T0IF ;Timer interrupt? > > goto end_handler ;Nope, skip to end of handler > > > incf TIMER,1 ;Increase timer high byte by 1 > > bcf INTCON,T0IF ;Clears the T0IF interrupt > > > end_handler > > > swapf STAT_TEMP,0 > > movwf STATUS > > swapf W_TEMP,1 > > swapf W_TEMP,0 ;Restores W and STATUS registers > > retfie > > > > Any good hints on jitter improvement? > > > The external interrupt is in the frequency range of 0 to 350 Hz, and > > the TMR0 module has a prescaler of 1:2. The processor is running at > > 10MHz. > > > -Xyvind > > > _______________________________________________ > > Xyvind 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) _______________________________________________ ¯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)