Dwayne: Just finishing project with similar reqt's. Using the CCP in Capture mode, and using TMR1, you can get excellent results. FWIW: use a good high freq crystal.... my measurements are in microseconds and anything but a crystal will yield inconsistent results. =20 I use ME Basic (OK, I know, BASIC is not cool) but here is my working code that may provide a start Detect: T1CON =3D 0x05 ' TMR1 ON, 1:1 pre-scaler CCP1CON =3D 0x05 ' CCP Capture mode, every rising e= dge PIR1.5 =3D 0 ' Clear bit 5 TMR1L =3D 0 ' Clear the TMR1L value TMR1H =3D 0 ' Clear the TMR1H value tim1 =3D 0 ' Reset variable while PIR1.5 =3D 0 nop wend if PIR1.5 =3D 1 then ' Capture occurred on rising edge TMR1L =3D 0 ' Clear the TMR1L value TMR1H =3D 0 ' Clear the TMR1H value CCP1CON =3D 0x04 ' CCP Capture mode, every falling edge PIR1.5 =3D 0 ' Clear bit 5 (capture occurred in= fo) end if while PIR1.5 =3D 0 nop wend if PIR1.5 =3D 1 then ' Capture occurred on rising edg= e tim1 =3D TMR1H<<8 + TMR1L ' Retain TMR1 value =3D ON time CCP1CON =3D 0x05 ' CCP Capture mode, every rising e= dge PIR1.5 =3D 0 ' Clear bit 2 (capture occurred in= fo) end if If tim1 <3700 then TMR1L =3D 0 ' Clear the TMR1L value TMR1H =3D 0 ' Clear the TMR1H value tim1 =3D 0 ' Reset variable goto Initialize_Detect end if Rich -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf Of Dwayne Reid Sent: Friday, July 18, 2014 9:01 PM To: pic microcontroller discussion list Subject: [PIC] Looking for frequency counter software Good day to all. The recent discussion about controlling the frequency of a signal generator reminded me of a project that I've been meaning to do for years. But it's been sitting for so long that I should see if anyone has done anything similar to what I want. I have a couple of older BK Precision function generators. These cover the range of sub-Hz through, I think, 5 MHz. They work well but suffer one tragic flaw: it is not possible to know what frequency you are generating without using an external frequency counter or scope. I want to add a digital frequency readout to these units. There is space i= n the upper-left corner of the front panel that is just crying out for some form of readout. I've seen a couple of frequency meter projects over the past few years - most are simple and use a PIC's TMR0 and its' prescaler to measure a signal up to 50 MHz. But I'm picky. I want something that measures and displays frequency when the generator freq is above, say, 1 KHz but measures period and converts that period measurement to frequency at lower freqs. This allows quick display updates even when generating low-frequency signals. Bonus points if the unit can also measure and display period as well as bot= h positive and negative pulse width. I could write it myself but surely someone has already done something similar to this. I hope. Any thoughts? Many thanks! dwayne --=20 Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax www.trinity-electronics.com Custom Electronics Design and Manufacturing -- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/chang= e your membership options at http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .