Rich: You can use Mikroelectronica Basic for PICs, for up to 2k free... I use th= e licensed version and really like it... many libraries etc. Rich -----Original Message----- From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] On Behalf Of Richard R. Pope Sent: Saturday, July 19, 2014 9:50 AM To: Microcontroller discussion list - Public. Subject: Re: [PIC] Looking for frequency counter software Richard, I think BASIC is cool and I would use it instead of C or ASM if I coul= d find a good BASIC compiler that was free. I'm following you as you do this. I'm using hardware to display my readings and I'm only using the PIC to latch in the reading and then to clear the display in preparation for the next reading. Thanks, rich! On 7/19/2014 8:24 AM, Richard Pytelewski wrote: > Dwayne: > > Just finishing project with similar reqt's. Using the CCP in Capture=20 > mode, and using TMR1, you can get excellent results. FWIW: use a=20 > good high freq crystal.... my measurements are in microseconds and=20 > anything but a crystal will yield inconsistent results. > > I use ME Basic (OK, I know, BASIC is not cool) but here is my working=20 > code that may provide a start > > Detect: > T1CON =3D 0x05 ' TMR1 ON, 1:1 pre-scaler > CCP1CON =3D 0x05 ' CCP Capture mode, every risin= g 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 ed= ge > TMR1L =3D 0 ' Clear the TMR1L value > TMR1H =3D 0 ' Clear the TMR1H value > CCP1CON =3D 0x04 ' CCP Capture mode, every falli= ng > 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 edge > tim1 =3D TMR1H<<8 + TMR1L ' Retain TMR1 value =3D ON time > CCP1CON =3D 0x05 ' CCP Capture mode, every risin= g 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 > > -- 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 .