Pailoor, I recently had ocassion to need a frequency measurement too. What I did was to watch the incoming signal for an edge. Which edge you use doesn't matter. When an edge is found, I clear the RTCC and let it count up. I then watch for the next similar going edge, and then transfer the count in the RTCC into a holding register. Then using the floating point math divide routines in the Microchip handbook vol 2, I take the reciprocal of the number in the holding register, an viola', my frequency. I was measuring frequency from about 1Khz to about 5Khz. The method I used got me to within a few cycles of the actual frequency, which for my application was good enough. You could increase the resolution by using a faster clock if needed. I don't know how precise you need to be, but this method worked for me. Maybe it will help you directly or at least give you an idea of how to do it. Sorry, I can't send you the actual source I wrote as it is copyrighted by my employer, but I don't see why you can't use the same idea. Hope it helps. Regards, Jim On Wed, 24 November 1999, Craig Lee wrote: > > It's not, this is the problem.. Based on the frequency of the > input, I then generate the output. > > > -----Original Message----- > > From: pic microcontroller discussion list > > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Ravi Pailoor > > Sent: November 24, 1999 9:06 PM > > To: PICLIST@MITVMA.MIT.EDU > > Subject: Re: Needed: freq meas and gen in 12C508 > > > > > > If the incoming square wave and the outgoing square wave is the same, > > try this. > > > > btfss gpio,0 ; bit 0 is input > > bcf gpio,1 ; bit 1 is output > > btfsc gpio,0 > > bsf gpio,1 > > > > Regards > > > > Pailoor > > > > Craig Lee wrote: > > > > > > I mostly program in C with the benefit of interrupts, > > > but this application calls for small size and price, > > > so I thought I'd ask the piclist. > > > > > > I need to be able to read an incoming square wave, and > > > generate an outgoing square wave based on the first. > > > The frequency is from 10Hz to 1Khz. > > > > > > This is probably very easy for the hardcore micro > > > guys, I guess I've become a bit lazy with my GUIs and > > > high end languages. > > > > > > I've done it in a 16F84, although a bit glitchy (can't > > > trigger well with a scope), but going to the 12C508, > > > I'm a bit lost. > > > > > > Any direction? > > > > > > Craig > > > > -- > > WE DESIGN THE FUTURE > > Website : http://www.chiptechnologies.com > > Website : http://business.vsnl.com/chiptech jim@jpes.com