>Hi, there is a friend that needs a special circuit to attach >to a PIC, but I can't find a single chip solution for him. > >He needs a 2^8 bits counter, 8 stages, easy solution, >but it needs to have a serial output, not parallel, so >he could read the actual counter 8 bits using a 2 wire >serial transfer. Right from the 12c508 data sheet: PIC12C5XX 40 Tt0H T0CKI High Pulse Width - No Prescaler 0.5 TCY + 20 ns - With Prescaler 10 ns 41 Tt0L T0CKI Low Pulse Width - No Prescaler 0.5 TCY + 20 ns - With Prescaler 10 ns Read it carefully! What they are saying is that if you use the prescaler with TMR0 and clock from an external input, the HI and LO periods must exceed 10 nS each. Thats a total period of 20 nS which is 50 MHz. This works! I have products that measure past 50 MHz with no problems. The logic is minorly convoluted. Feed the signal to TMR0 pin via a 2K2 resistor. Figure out what your measurement period is going to be. set TMR0 pin to OUTPUT assign the prescaler (/256) to TMR0 and clear TMR0. at the start of the measurement period, set TMR0 pin to INPUT. at end of measurement period, set TMR0 pin to output. read TMR0, store. clear counter :loop set TMR0 pin to hi compare TMR0 to stored value set TMR0 pin to lo if not same, goto normalize inc counter goto loop :normalize subtract counter value from 256 this is the LO byte of your 16 bit counter TMR0 is the hi byte of your 16 bit counter serialize it and send it out reset everything and go to top Note that if you already have a PIC and are not using TMR0 and have the time, you can integrate all that into the PIC you already have. I use a single 12c508 to implement a specialised frequency counter - I drive the displays using shift registers. dwayne Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (403) 489-3199 voice (403) 487-6397 fax Celebrating 15 years of Engineering Innovation (1984 - 1999) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Do NOT send unsolicited commercial email to this email address. My posting messages to Usenet neither grants consent to receive unsolicited commercial email nor is intended to solicit commercial email.