Many thanks! There isn't anything wrong with using Basic. One of the best (and=20 fastest) programmers that I have ever worked with does all of his PIC=20 stuff using PIC Basic Pro from MELabs. He does most of his other=20 stuff in C but seems to prefer PIC Basic for his PIC stuff. It works=20 very well for him. dwayne PS - are you free to share your entire project? dwayne At 06:24 AM 7/19/2014, Richard Pytelewski wrote: >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 fre= q >crystal.... my measurements are in microseconds and anything but a crystal >will yield inconsistent results. > >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= edge > 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 edg= e > TMR1L =3D 0 ' Clear the TMR1L value > TMR1H =3D 0 ' Clear the TMR1H value > CCP1CON =3D 0x04 ' CCP Capture mode, every fallin= g >edge > PIR1.5 =3D 0 ' Clear bit 5 (capture occurred = info) > end if > while PIR1.5 =3D 0 > nop > wend > if PIR1.5 =3D 1 then ' Capture occurred on rising e= dge > tim1 =3D TMR1H<<8 + TMR1L ' Retain TMR1 value =3D ON time > CCP1CON =3D 0x05 ' CCP Capture mode, every rising= edge > PIR1.5 =3D 0 ' Clear bit 2 (capture occurred = info) > 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 O= f >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 generato= r >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 th= e >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 = in >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 signa= l >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 bo= th >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 > >-- >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/chan= ge >your membership options at http://mailman.mit.edu/mailman/listinfo/piclist > >-- >http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist --=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 --=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 .