Craig, Have you looked at the PIC12C671 and PIC12C672. They are 8 pin packages like the 12C508. They have three interrupts sources. 1) TMR0 Overflow 2) INT pin 3) Change on I/O Pin. I looked at digikey and the 100 piece pricing is 1.68 for 4MHz and 1.80 for 10MHz versions. They have A/D capability which you can ignore. B. -----Original Message----- From: pic microcontroller discussion list [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Craig Lee Sent: Wednesday, November 24, 1999 10:47 AM To: PICLIST@MITVMA.MIT.EDU Subject: Re: Needed: freq meas and gen in 12C508 What I am doing is using the INT interrupt on a 16F84 to capture my period, using a 1us resolution. I do this by counting the overflows with the TMR0 interrupt, shifting by 8 and adding the current TMRO value. Then I shift right once to get 1/2 a period. Then using that number, I do a calculation to determine the 1/2 period of my generated signal. Then I toggle the output and wait the half period. When the timeout expires, I redo the calculation with the current period value, and toggle my output appropriately. Keeping everything in the time domain, limits the math to integer, and mostly binary shifts. My problem is that I need to use the 12C508 or something of that form factor. Without the benefit of interrupts, I can't depend on the background processing of the edge detection and the timing. So more specifically, I need to be able to code 3 independent tasks using polling techniques instead of interrupts. These tasks are input detection, timing, and output control. Craig > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of James Paul > Sent: November 24, 1999 8:41 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: Needed: freq meas and gen in 12C508 > > > 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