> Ok, guys.
> I'm having some trouble, and I can't get it figured out.
> I'm building a device that's sampling the RPM of an engine.
> The incoming signal is therefore in the range of max 350 Hz, and it
> is connected to RB0.
> I need to accurately count the time *between* pulses, to get a number
> that is inversely proportional to the RPM.
> The TMR0 and the external interrupt is used. (16F84)
> I've programmed the TMR0 to run with a prescaler of 1:2, so the TMR0
> frequency should be 1.25 MHz.
> I want to have a 16 bit counter, so in the interrupt routine I
> increment a register for each TMR0 interrupt. This is the high byte
> of my counter.
> When the external interrupt occurs, I read both the TMR0 and this
> register. Together they are transferred to another 16 bit variable
> that is used by the rest of the code. Then the TMR0 and the high byte
> register is cleared, and I exit the ISR.
> What troubles me is that I get a lot of jitter on my count value.
> A lot more than I would expect. The latency of the TMR0 interrupt
> should not bother me, since in the part of the ISR that handles this
> I just increment the high byte and then exits. The TMR0 itself is not
> tampered with.
> The latency that I get when the external interrupt occurs will cause
> a little bit of jitter, since I'm reading the TMR0, but it shouldn't
> be more than a couple of bits, especially since the TMR0 is running
> at half the instruction cycle.
> Any good hints?
> I don't have the code here, but I can post that later if necessary.
> _______________________________________________
> Xyvind Kaurstad,
EraseMEoyvindspam_OUT
TakeThisOuTsafetel.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)