----- Original Message ----- From: Peter To: Sent: Sunday, December 05, 1999 3:35 PM Subject: Timing issue > Hi.. > > Can anyone help me regarding the capturing of incoming pulses > which has a period of 2 micro sec using timer0 to count the cycles > and compute the frequency? The PIC used is P16C66x. > > Currently, I am quite lost at the usage of timer0 to sample the pulses > with the use of the prescaler. I intend to use 200 nanosec (20 MHz clk) > to run timer0. Is it fast enough to do it? Can someone advise me? Why you want to use a 16c66x ? Try a chip with a capture module or/and with 2 timers or more (to count the pulses with one timer and count the time with the other). Do you have enough time to build a routine that use 100% processor time for a while? I suppose, 20MHz as processor clock is ok. T0CKL must be high for least 2 Tosc. Tosc is 0,8us, 2*Tosc=1,6us Therefor 2us signals are long enough. For counting the pulses with the timer0 and have a good timebase try this Start timer0 as Counter wait xyz micro seconds, xyz depends of the range of freq's you want to determine (perhaps 100us) stop timer0 compute the frequency For better results, you can use timer0 interrupt too, and set xyz to a longer time. pulses=0 Start timer0 as Counter wait 1ms or more stop timer0 pulses+=tmr0 compute the frequency ISR_timer0 pulses+=256 Ciao Jan Erik Bertram