PRINTING VALUE OF TCNT1, TCNT1L, TCNT1H WITH Serial.println

I am experimenting with timers using TCCRIB and TCNT1 registers. When I use Serial.Print to read the value ot TCNT1 registers or TCNT1L and TCNT1H seperately, the value of TCNT1 does not go beyond 255, while TCNT1H remains zero. The code I am using is as under, I am using Mega 2560, the basic program was to make Pin 13 blink at 1/20 sec . Can some one help:-

include<avr/io.h>

void setup(){
DDRB = DDRB | B1000000; // set digital 13 as OUTPUT
Serial.begin(9600);

}

void loop(){

TCCR1B |=(1<<CS10);

Serial.println(TCCR1B,BIN);
Serial.print(TCNT1L);
Serial.print(" ");
Serial.print(TCNT1H);
i=TCNT1;
Serial.println(" TCNT1 ");
*/
for(;:wink:
{

Serial.print(TCNT1L);
Serial.print(" ");
Serial.print(TCNT1H);
Serial.print(" ");
Serial.println( TCNT1);

if (TCNT1 >= 49999)
{
Serial.print(" TCNT1 ");

PORTB = PORTB ^ B10000000;
TCNT1=0;
}

}
}

And now without the Smiley, please.
(Hint: use code tags)

include<avr/io.h>

void setup(){
DDRB = DDRB | B1000000; // set digital 13 as OUTPUT
Serial.begin(9600);

}

void loop(){

TCCR1B |=(1<<CS10);

Serial.println(TCCR1B,BIN);
Serial.print(TCNT1L);
Serial.print(" ");
Serial.print(TCNT1H);
i=TCNT1;
Serial.println(" TCNT1 ");
*/
for(;smiley-wink
{

Serial.print(TCNT1L);
Serial.print(" ");
Serial.print(TCNT1H);
Serial.print(" ");
Serial.println( TCNT1);

if (TCNT1 >= 49999)
{
Serial.print(" TCNT1 ");

PORTB = PORTB ^ B10000000;
TCNT1=0;
}

}
}

what AWOL meant was that you should use the CODE tags when you post some code.
You can click up there on the third button from the right on the last row of message formating buttons (it has a number sign - # - on it) and then put all your code inside the tags.
Something like this

[ code]
will look like this
[ /code]

will look like this

Save the values of TCNT1 etc to suitable variables and then print the values from those variables.

...R

Would you be so kind to tell which variable is suitable?
I have tried a lot of types but I could not make it work.

You can read my code below. What I am doing is that I connect a signal generator on the INT0 pin and I wish to measure the time between falling edges and later communicate this. This actually works but only until I reach the 8 bit limit. The value of period will never go above 255 although according to the datasheet it should be possible to read the value of TCNT1 simply with 1 command.
I also tried reading TCNT1L and TNCT1H separately but I ended up same as the Original Poster.

Could you please give me a hint here to which variable type I really need or what I should do to get the 16 bit value from the TCNT1 register?
Thank you! :blush:

int ledPin = 13;                 // LED connected to digital pin 13
int INTPin = 2;
int FlagPin = 5;
unsigned int period = 0;

ISR(INT0_vect){
  period=TCNT1;
  if (period > 255) PORTD^=1<<FlagPin; // This flag will somehow never trigger
  TCNT1=0;
}

void TIMER1_init() 
{
  //Init Timer 1 to normal mode prescaler = 8 -> 500ns
  TCNT1=0;
  TCCR1B=0x02;  //Set prescaler to 8 & start counter
}

void INT_init() {
  EICRA=0x02; //1<<ISC0; //Set Pin change IT for INT0 to falling edge
  EIMSK=0x01; //1<<INT0; //Enable INT0 interrupt  
  }

void setup() {
  Serial.begin(1000000);
  pinMode(ledPin, OUTPUT);  
  pinMode(3, OUTPUT);   
  pinMode(INTPin, INPUT);
  pinMode(FlagPin, OUTPUT);  
  
  INT_init();
  TIMER1_init();
}

void loop() 
{}

theryz:
Would you be so kind to tell which variable is suitable?
I have tried a lot of types but I could not make it work.

If it is an 8-bit value the correct type is a byte
If it is a 16-bit value the correct type is an int.

For example

byte mySavedTCNT1H;

mySavedTCNT1H = TCNT1H;

...R