Error in finding frequency of an input signal

Here is my code to find the frequency of an input rectangular wave at pin 8 of the Arduino Uno board.

const uint16_t freqPin = PB0;
const uint16_t load = 0;
unsigned long int count=0;
unsigned int value=0;

void setup()
{
Serial.begin(9600);
DDRB = 0x00;
TCCR1A = 0;
TCCR1B = TCCR1B & B11111000 | B00000111;
TCNT1 = load;
TIMSK1 |= (1<<ICIE1);
TIMSK1 |= (1<<TOIE1);
sei();
}

void loop()
{
}

ISR(TIMER1_OVF_vect){

  count++;
}
ISR(TIMER1_CAPT_vect){
  value = TCNT1;
  TCNT1 = load;
  Serial.println(count);
  Serial.println(value);
}

The output is

0  
0  
0  
0  
0

Why the output is showing zeroes only. why is this happening ? Can someone explain?
Thanks in advance.

If you are playing with interrupts, you should start with being aware of what you can, and what you can not, and what you can, but should not, do in an ISR.

Serial.print() relies on interrupts, which are disabled when an ISR is running.

The two variables 'count' and 'value' must be declared volatile because they are used in an ISR.

Pete

Is there any way to calculate the frequency of input square wave signal on a digital pin? or should I be completely relied upon the pulseIn() function??

I have written the ISR of my code like this

ISR(TIMER1_OVF_vect){
  count++;
}
ISR(TIMER1_CAPT_vect){
  value = TCNT1;
  TCNT1 = load;
  }

and tried to print the values on serial monitor(variables: value and load are volatile variables) but it shows zeroes only. I cant figure out whats going wrong in it.!

The declaration of the program is as follows

const uint16_t freqPin = PD5;
const uint16_t load = 0;
volatile unsigned long int count=0;
volatile unsigned int value=0;

void setup()
{
Serial.begin(9600);
DDRD &= ~(1<<freqPin);
TCCR1A = 0;
TCCR1B &= B11111000 | B00000111;
TCNT1 = load;
TIMSK1 |= (1<<ICIE1);
TIMSK1 |= (1<<TOIE1);
TIFR1 |= (1<<TOV1);
sei();
}

Please help. Thanks in advance

Have you looked at any of the frequency counter libraries available online?

If pulseIn() works for the frequency you are interested in, then use a pin interrupt to save micros() each time the input changes. You don't need the timer.

What frequency range are you measuring?

I want to measure in Mhz range.

I just found your other thread. Please keep all questions about each project in one thread. You can report your own post to a moderator and ask for the two threads to be merged.

Ok, MHz. With only a 16MHz Arduino, you cannot measure MHz. You will need some kind of pre-scaler or divider to shift the frequency down to something that the Arduino can measure.