Hi,
I'm trying to make a Frequency Counter with a PIC running at 10 Mhz, but I can't get it to pass the 700 KHz. I found a couple of websites that claim to have achieved up to 80 Mhz with the same type of MCU, but they don't offer the source code to see how they've done it.
I would appreciate any help, advice or suggestions; or if anyone could direct me towards or explain the technique that I need to use it would be great.
In my code I'm already using interrupts and as few lines as possible; with Timer 0 tracking the time between the signal pulses through Timer 1.
Thanks in advance for your help,
I'm trying to make a Frequency Counter with a PIC running at 10 Mhz, but I can't get it to pass the 700 KHz. I found a couple of websites that claim to have achieved up to 80 Mhz with the same type of MCU, but they don't offer the source code to see how they've done it.
I would appreciate any help, advice or suggestions; or if anyone could direct me towards or explain the technique that I need to use it would be great.
In my code I'm already using interrupts and as few lines as possible; with Timer 0 tracking the time between the signal pulses through Timer 1.
Thanks in advance for your help,
Code:
void interrupt myISR() // Called on any interrupt
{
// TMRxIE Overflow Interrupt enable
// TMRxIF Overflow Flag bit
if(INTCONbits.TMR0IE && INTCONbits.TMR0IF)
{
count+=256;
INTCONbits.TMR0IF = 0; // clear the flag
}
if(PIE1bits.TMR1IE && PIR1bits.TMR1IF)
{
frequency=(count+TMR0)*4;
count=TMR0=0;
PIR1bits.TMR1IF = 0; // clear the flag
}
}
Last edited: