#include typedef struct { unsigned char second; unsigned char minute; unsigned char hour; unsigned char date; unsigned char month; unsigned int year; unsigned char changed; } time_t; time_t time={0,0,12,1,1,2007}; char not_leap(void) //check for leap year { if (!(time.year%100)) return (char)(time.year%400); else return (char)(time.year%4); } SIGNAL(SIG_OVERFLOW2) //overflow interrupt vector { if (++time.second==60) //keep track of time, date, month, and year { time.second=0; if (++time.minute==60) { time.minute=0; if (++time.hour==24) { time.hour=0; if (++time.date==32) { time.month++; time.date=1; } else if (time.date==31) { if ((time.month==4) || (time.month==6) || (time.month==9) || (time.month==11)) { time.month++; time.date=1; } } else if (time.date==30) { if(time.month==2) { time.month++; time.date=1; } } else if (time.date==29) { if((time.month==2) && (not_leap())) { time.month++; time.date=1; } } if (time.month==13) { time.month=1; time.year++; } } } } time.changed=1; } void RTC_init(void) { TIMSK2 = 0; // disable OCIE2A and TOIE2 ASSR = (1<