die lcd-routinen lasse ich mal weg:

Code:
#include <avr/io.h>
#include <stdlib.h>
#include "lcd-routines.h"
#include <util/delay.h>      

 

int main(void)
{
	
	int counter=0;
	int temp1, temp2;
	DDRD = 0xf0;	
	
    lcd_init();

    while(1)
    {
	
		if ( PIND&(0x04) )
		{
			PORTD |= 0x40;	//signal LED ein

			TCCR1A = 0x00;
			TCCR1B |= (1<<CS12)|(1<<CS10);	//timer starten
			_delay_ms(20);
			while (PIND&(0x04));
			TCCR1B &= ( (~(1<<CS12)) | (~(1<<CS10)) );	//timer stoppen

			temp1= TCNT1L;
			temp2 = TCNT1H;
			counter = (temp2<<8)+temp1;

			//zählregister auf 0 zurück setzen
			TCNT1H = 0x00;
			TCNT1L = 0x00;
			
			//Ausgang abschalten
			PORTD &= 0xdf;		
		}

		{
			char Buffer[16]; // in diesem {} lokal
			lcd_clear();		

			set_cursor(0,2);
			itoa( counter, Buffer, 10 ); 
	 
		   // ... ausgeben  
		   lcd_string( Buffer );
			_delay_ms(200);
		
		}

    }
 
    return 0;
}