On 1 Dec 2007 at 15:52, Dharmesh Joshi wrote: From: "Dharmesh Joshi" <[EMAIL PROTECTED]> To: <avr-chat@nongnu.org> Date sent: Sat, 1 Dec 2007 15:52:04 -0000 Subject: [avr-chat] Re:
> Hi Guys > > The AVR has in built timers, are there any samples code or website showing > how to use them. I am very interested in using them as a calendar, and > passing there varaible to my program and also changing the calander when > nessary. > If you want time and calender functions, then you should use a RTC (Real Time Clock). Some of the AVRs do have the functionality to enable one to add a "watch crystal" which is a 32.768kHz crystal which is often used to provide the clock for RTC functions. It is simpler to use a dedicated RTC device. Below is a routine for calculating the weekday from a specific date: /********************************************************************\ * Calculate Day of the week * 0 -> SUN * 6 -> SAT \********************************************************************/ unsigned char GregorianWeekDay(unsigned short year, unsigned char month, unsigned char day) { int a,y,m,d; a = (14 - month) / 12; y = year - a; m = month + 12*a - 2; d = (day + y + y/4 - y/100 + y/400 + (31*m)/12) % 7; return((unsigned char)d); } Regards Anton Erasmus -- A J Erasmus _______________________________________________ AVR-chat mailing list AVR-chat@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-chat