عندى مشكلة فى الكود ارجوووووووووووووووووووووووووووووووووووو المساعدة
المشروع عبارة عن ساعة رقمية باستخدام atmega 16 , lcd , XT 4MHZ والكودMIKROC
المشكة فى الشهور (31) وشهر (2) وعند اضافة الجزء الخاص بالضبط البرنامج لايعمل
هذا هو الكود :
const char _THRESHOLD = 60;
char counter;
unsigned short sec,Min,hr,day,mth;
unsigned yer;
unsigned char ch;
int old;
// LCD module connections
sbit LCD_RS at PORTD2_bit;
sbit LCD_EN at PORTD3_bit;
sbit LCD_D4 at PORTD4_bit;
sbit LCD_D5 at PORTD5_bit;
sbit LCD_D6 at PORTD6_bit;
sbit LCD_D7 at PORTD7_bit;
sbit LCD_RS_Direction at DDD2_bit;
sbit LCD_EN_Direction at DDD3_bit;
sbit LCD_D4_Direction at DDD4_bit;
sbit LCD_D5_Direction at DDD5_bit;
sbit LCD_D6_Direction at DDD6_bit;
sbit LCD_D7_Direction at DDD7_bit;
// End LCD module connections

void Timer1Overflow_ISR() org IVT_ADDR_TIMER1_OVF {
if (counter >= _THRESHOLD) {
if(sec>=59)/*-------------------------------------Is sec =60?*/
{ Min++;/*-----------------------------------Increament Minutes*/
if (Min>=59)
{ hr++;
if(hr>=23)
{ day++;
if(mth==2)
{
if(yer%4==0)
{
if(day>=29)
{
mth++;
day=1;
goto End;
}
}
else if(day>=28)
{mth++;
day=1;
goto End;
}
}
else if(mth==1||3||5||7||8||10||12)
{
if(day>=31)
{
mth++;
day=1;
}
}
else if(day>=30)
{
mth++;
day=1;
}
End:
if(mth>13)
{
yer++;
mth=1;
}
hr=0;
}
else
Min=0;
}
else
sec=0;
}
else sec++;
counter=0;
}
else
counter++; // increment counter
}
void main() {
DDRB=0;
sec=0;Min=0;hr=0;day=1;mth=1,yer=2009;
SREG_I_bit = 1; // Interrupt enable
TOIE1_bit = 1; // Timer1 overflow interrupt enable
TCCR1B = 1; // Start timer with prescaler
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Cmd(_LCD_CLEAR);
do{
old=0;
if(Button(&PINB, 0, 1, 0))
{
TOIE1_bit = 0;
set:
old++;
}
}while(1);

if(old=1)
{
do{
if(hr>23)
hr=0;
ch = hr % 10u;
Lcd_Chr(1,6,48+ch);
ch= (hr / 10u) % 10u;
Lcd_Chr(1,5,48+ch);
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
Delay_ms(500);

if(Button(&PINB, 1, 1, 0))
hr++;
if(Button(&PINB, 0, 1, 0))
goto set;
}while(1);
}


if(old=2)
{
do{
if(Min>59)
Min=0;
ch = Min % 10u;
Lcd_Chr(1,9,48+ch);
ch= (Min / 10u) % 10u;
Lcd_Chr(1,8,48+ch);
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
Delay_ms(500);

if(Button(&PINB, 1, 1, 0))
Min++;
if(Button(&PINB, 0, 1, 0))
goto set;
}while(1);
}


if(old=3)
{
do{
if(day>31)
day=0;
ch = day % 10u;
Lcd_Chr(2,5,48+ch);
ch= (day / 10u) % 10u;
Lcd_Chr(2,5,48+ch);
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
Delay_ms(500);

if(Button(&PINB, 1, 1, 0))
day++;
if(Button(&PINB, 0, 1, 0))
goto set;
}while(1);
}

if(old=4)
{
do{
if(mth>13)
hr=0;
ch = mth % 10u;
Lcd_Chr(2,7,48+ch);
ch= (mth / 10u) % 10u;
Lcd_Chr(2,6,48+ch);
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
Delay_ms(500);

if(Button(&PINB, 1, 1, 0))
mth++;
if(Button(&PINB, 0, 1, 0))
goto set;
}while(1);
}

if(old=5)
{
do{
if(yer>2020)
yer=2009;
ch = yer % 10u;
Lcd_Chr(2,13,48+ch);
ch= (yer / 10u) % 10u;
Lcd_Chr(2,12,48+ch);
ch= (yer / 100u) % 10u;
Lcd_Chr(2,11,48+ch);
ch= (yer / 1000u) % 10u;
Lcd_Chr(2,10,48+ch);
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
Delay_ms(500);

if(Button(&PINB, 1, 1, 0))
yer++;
if(Button(&PINB, 0, 1, 0))
{TOIE1_bit = 1;
old=0;
goto setf;
}
}while(1);
}
setf:

do{
ch = hr % 10u;
Lcd_Chr(1,6,48+ch);
ch= (hr / 10u) % 10u;
Lcd_Chr(1,5,48+ch);
Lcd_Out(1, 7, ":");
ch = Min % 10u;
Lcd_Chr(1,9,48+ch);
ch= (Min / 10u) % 10u;
Lcd_Chr(1,8,48+ch);
ch = sec % 10u;
Lcd_Chr(1,12,48+ch);
ch= (sec / 10u) % 10u;
Lcd_Chr(1,11,48+ch);
Lcd_Out(1, 10, ":");

ch = day % 10u;
Lcd_Chr(2,5,48+ch);
ch= (day / 10u) % 10u;
Lcd_Chr(2,4,48+ch);
Lcd_Out(2, 6, "/");
ch = mth % 10u;
Lcd_Chr(2,8,48+ch);
ch= (mth / 10u) % 10u;
Lcd_Chr(2,7,48+ch);
Lcd_Out(2, 9, "/");
ch = yer % 10u;
Lcd_Chr(2,13,48+ch);
ch= (yer / 10u) % 10u;
Lcd_Chr(2,12,48+ch);
ch = (yer/100u) % 10u;
Lcd_Chr(2,11,48+ch);
ch= (yer / 1000u) % 10u;
Lcd_Chr(2,10,48+ch);

}while (1);
}