// LED-display Clock

#define XTAL	8e6
#define F_CPU	XTAL

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>

#include "..\..\includes\BitUtilities.h"
#include "..\..\includes\LED_display_no_interrupt.h"

volatile int tc;	// seconds counter

ISR(TIMER1_OVF_vect)	// 1 second clock
{	TCNT1 = 34286; tc++;
}

int main(void)
{	int  hr=20, min=0, sec=0;	 //set start time
	initialize_LED_display();
	
	// initialize timer1
	TIMSK |= _BV(TOIE1); 	// aktivate overflow interrupts of timer1 
	TCCR1B |= (1<<CS12);	// prescaler = 256
	TCNT1 = 0xFFFF; 		// FFFF for start 
	sei();	
	
	while(1)
	{	number_output (hr*10000+min*100+sec);geändert
		{	sec=tc;
			if (sec==60)
			{	tc=0; sec=0; min++;
				if (min==60) 
				{	min=0; hr++;
					if (hr==24) hr=0;
				}
			}
		}
		while (sec==tc)	refresh(); 
	}	
	return(0);
}