Problems input capture timer1

Hello guys, I’ve just started working with a Arduino mini pro. I'm trying to measure a RPM with input capture timer 1. The interrupts are being triggered but when I write the value of TCNT1 to my serial monitor I only receive a 8 bit value, instead of a 16bit value. I also tried to get the counter value out of register ICR1L and ICR1H, but I noticed that ICR1H stayed zero and wasn’t receiving any values.
Could anybody tell me what I’m doing wrong?


static unsigned char Timer1;
unsigned int RPM;
unsigned short Period;
unsigned short Prev_Period;

void Init_ReadRPM()
{
  //init RPM_read PB0
    DDRB &= ~0x01;
    TCCR1A |= 0x00;  //Disable PWM
    TCCR1B |= 0xC1;  // - Noise filter on
                     // - Trigger on rising egde
                     // - NC
                     // - Waveform (bit3&4) normal
                     // - Prescaler (bit1&2&3) 1
    TIMSK1 |= 0x21;  //-Interrupt enable
                     // Timer overflow enable
    TIFR1  |= 0x21;  //Reset input capature flag
}

ISR(TIMER1_CAPT_vect)
{
  if((PORTB && 0x01) != 0)
  {
    cli(); // Disable interrupts
    
    if(counter <= 10)
    { 
      Serial.print("TCNT1 = ");
      Serial.println(TCNT1, DEC);
      Serial.print("ICR1H = ");
      Serial.println(ICR1H,DEC);
    }
    
     
    Timer1 = 0;
    
    sei();  // Enable interrupts
    TIFR1  |= 0x10;  //Reset input capature flag
  }
}

ISR(TIMER1_OVF_vect)
{
  Timer1++;
  TIFR1 |= 0x01;
}

Serial_monitor.jpg

    cli(); // Disable interrupts

In your interrupt handler, where interrupts are already disabled. Why?

    if(counter <= 10)
    {
      Serial.print("TCNT1 = ");
      Serial.println(TCNT1, DEC);
      Serial.print("ICR1H = ");
      Serial.println(ICR1H,DEC);
    }

In an interrupt handler. Are you serious?

PaulS:

    cli(); // Disable interrupts

In your interrupt handler, where interrupts are already disabled. Why?

    if(counter <= 10)

{
      Serial.print("TCNT1 = ");
      Serial.println(TCNT1, DEC);
      Serial.print("ICR1H = ");
      Serial.println(ICR1H,DEC);
    }



In an interrupt handler. Are you serious?

In didn't know for sure if this interrupt could be interrupted by a another one. So I manually made sure that it wasn’t going to happen, because I tried to read the counter value (TCNT1) by combining ICR1L and ICR1H (not in the code anymore).

The Serial.print() commands are only in the interrupt to see if everything this working. When the timer is working properly it will be deleted. Or is this even a bad idea to be using for debugging?

Or is this even a bad idea to be using for debugging?

Yes, it is a bad idea. Flash an LED or something quick to confirm that the ISR is being called.

PaulS:
Yes, it is a bad idea. Flash an LED or something quick to confirm that the ISR is being called.

Done :), thank you for the advise. Does anybody know what the problem could be for my 8/16bit timer problem?