[an error occurred while processing this directive] [an error occurred while processing this directive]
Вот, недавно писал для PICа на Си:
(«Телесистемы»: Конференция «Микроконтроллеры и их применение»)
[an error occurred while processing this directive] [an error occurred while processing this directive]

Отправлено Baser 17 мая 2002 г. 13:21
В ответ на: AVR календарь отправлено dm37 17 мая 2002 г. 08:33

persistent char Second; // Seconds Counter
persistent char Minute; // Minutes Counter
persistent char Hour; // Hours Counter
persistent char Day; // Days Counter
persistent char Month; // Months Counter
persistent char Year; // Years Counter

persistent - значит не обнуляемый после сброса

Прерывание от таймера, каждую секунду:
//- - - - - - - - - - - - - - - - - - - - - - -//
Second++; // Real Time Clock service
if (Second >= 60)
{
Second = 0;
Minute++;
}
if (Minute >= 60)
{
Minute = 0;
Hour++;
}
if (Hour >= 24)
{
Hour = 0;
Day++;
}
{ char lastday;
switch (Month)
{
case 2: if ((Year & 0x03)==0) lastday = 29;
else lastday = 28;
break;
case 4:
case 6:
case 9:
case 11: lastday = 30; break;
default: lastday = 31; break;
}
if (Day > lastday)
{
Day = 1;
Month++;
}
}
if (Month > 12)
{
Month = 1;
Year++;
}
if (Year >= 100) Year = 0;
//- - - - - - - - - - - - - - - - - - - - - - -//

Составить ответ  |||  Конференция  |||  Архив

Ответы



Перейти к списку ответов  |||  Конференция  |||  Архив  |||  Главная страница  |||  Содержание  |||  Без кадра

E-mail: info@telesys.ru