View Single Post
Old 06-08-2009, 01:51 AM   #6
manhha2799
Đệ tử 5 túi
 
Tham gia ngày: Apr 2007
Bài gửi: 121
:
Send a message via Yahoo to manhha2799
Trích:
Nguyên văn bởi sonduy1 View Post
#INT_TIMER1
void ngat_timer1()
{ int time=0,count=0;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
set_timer1(24280);
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);//mo transistor để led7 doan dc cap 5v(dung anot chung)
}
if(count==2)
{ portb=bang_ma[n2];
output_low(pin_d1);//tuong tu o d0
}
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);
}



bác coi giup sau e thực hiên quét mà kô dc.
Mấy dòng này bạn phải để trong void main() chứ:
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
set_timer1(24280);
enable_interrupts(int_timer1);
enable_interrupts(global);

Với lại hàm if, mấy cái sau bạn thử dùng else if xem sao. Chứ if thì có thể nó sẽ bị lẫn lộn đó.
__________________
Bảng ledsigns chất lượng cao...
http://www.ledviet.info - manhha2700@yahoo.com
Đt:0949299699
manhha2799 vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn