bác coi giup e doạn chương trình này cái.
Trích:
Nguyên văn bởi nguyenquoctoan
lỗi này mình cũng thường gặp, nhưng ở dạng cảnh báo và chương trình vẫn chạy bình thường, do sắp xếp các chuơng trình con chưa hợp lý, đặc biệt là sử dụng ngắt, bạn hãy sắp xếp lại thử coi.
|
Code:
#INT_TIMER0
void ngat_timer0()
{ int dem;
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
set_timer0(15536); //mac dinh gia tri ban dau cho TMR0
dem=0;
dem++;
if(dem==20) //20*50000=1s
{ dem=0;
sec++;
}
if(sec==60)
{ sec=0;
min++;
}
if(min==60)
{ min=0;
h++;
}
if(h==24)
{ h=0;
}
enable_interrupts(int_timer0);
enable_interrupts(global);
}
//quet led
//khao bao TMR1
#INT_TIMER1
void ngat_timer1()
{ int time=0,count=0;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
set_timer1(24280);
time==0;
count==0;
time++; // timer 1 tràn sau ==> 500 000 us = 0.5s
if(time==2) // 2* 500 000 =1s
{
count++;
if(count==1)
{ portb=bang_ma[n1];
output_low(pin_d0);
}
if(count==2)
{ portb=bang_ma[n2];
output_low(pin_d1);
}
if(count==3)
{ portb=bang_ma[n3];
output_low(pin_d3);
}
if(count==4)
{ portb=bang_ma[n4];
output_low(pin_d4);
}
count=0;
}
enable_interrupts(int_timer1);
enable_interrupts(global);
}
void main(void)
{ trisb=0x00;
portb=0xff;
output_high(pin_d0);
output_high(pin_d1);
output_high(pin_d2);
output_high(pin_d3);
n1=n2=1;
n3=4;
n4=5;
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256);
set_timer0(15536); //mac dinh gia tri ban dau cho TMR0
/////////////////////////////////////
////////////////////////////////////
while(1)
{
n1=h/10;
n2=h%10;
n3=min/10;
n4=min%10;
.......//ko biet làm sao để hiển thị led 7 doạn và clock
}
}
thay đổi nội dung bởi: phamminhtuan, 04-08-2009 lúc 04:54 PM.
Lý do: Định dạng code
|