hi all

been having some ups and down with a frequency counter. i had it working taking an audio signal through a NPN pre-amp and then to a 741 config as a comparator. the op amp was powered by +/-4.5v from a 9v cell tapped with a gnu at the middle. this created a nice square wave output. when connected to the pic my code counted the frequency perfectly, using TMR1 as an asynchronous counter and TMR0 to create a 1 second delay in which i count the number of tmr1 overflows.

basically, i wanted to make the fixtures a little more permanent and so replaced the 9v cell with a 7660S CPAZ to give my -ve rail and then integrated a dual op amp, config as a 20 gain amp and comparator. result - a nice -5v/+5v swing square wave. however the pic now does not recognise this as an external clock. and i scoped it before when it was connected. i can see a square wave at the RC0/T1CKI pin on the pic, the correct frequency, but it only runs from -0.6v to +4v now. i don't know if this is the problem. is there a certain format the ext clk is required to be for the input? I've even tried a ttl from a function generator but it doesn't like that either.

i checked code in the xc8 sim and worked every time.

below is code extract:
#include <pic18f252.h>
#include <stdio.h>
#include <stdlib.h>
#include <xc.h>
#include <htc.h>
#include <delays.h>
#include <math.h>
#pragma config WDT = OFF


unsigned int tmr1_ovflow;
unsignedint freq;


/*****************************Timer1 overflow count**********************************/


void high_ISR (void)
{
PIR1bits.TMR1IF = 0; //checks for Timer 1 rollover interrupt flag
tmr1_ovflow=tmr1_ovflow + 1;
}
/*****************************1 Second Delay**********************************/
void delay (void)
{
int i;
i=0;
do{


T0CON = 0x87;
// configure Timer 0 - select 16-bit mode,
// internal clock source, enable 1:256 prescaler
TMR0H = 0xA4;
// load Timer 0 registers for 1 second delay
TMR0L = 0x6D;
INTCONbits.TMR0IF = 0;
// make sure interrupt flag is reset
while(!(INTCONbits.TMR0IF)); // wait until TMR0 rolls over
i=i+1;
}while(i<1);
}
/*****************************Frequency Counter**********************************/


void freqcount ()
{
tmr1_ovflow = 0;
freq = 0;
TMR1H =0;// force Timer1 to count from 0
TMR1L =0;
PIR1bits.TMR1IF = 0;// clear Timer1 interrupt flag
RCONbits.IPEN = 1;// enable priority interrupt scheme
IPR1bits.TMR1IP = 1;// set Timer1 interrupt to high priority
PIE1bits.TMR1IE = 1;// enable Timer1 roll-over interrupt
T1CON = 0x87;// enable Timer1 with external clock, prescaler 1
INTCON = 0xC0;// enable global and peripheral interrupts
delay ();// start one-second delay and wait for interrupts
INTCONbits.GIE = 0;// disable global interrupt
freq = tmr1_ovflow * 65536 + TMR1H * 256 + TMR1L;
// get the total Timer 1 count, i.e. calculate the frequency
}

any ideas? its driving me up the wall haha!