![]() |
![]() |
#11 |
Đệ tử 1 túi
Tham gia ngày: Jan 2007
Bài gửi: 11
: |
Thắc mắc ngắt timer
Em viết chương trình ngắt timer nhấp nháy led, nhưng nạp vào pic phải đợi 1 lúc sau nó mới bắt đầu nháy led, bác nào khắc phục jùm em với.
Đây là code. Code:
#include <16F877A.h> #include <DEFS_16F877A.h> #device 16F877*=16 ADC=10 #FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT #use delay(clock=4000000) #use fast_io(b) #use fast_io(c) #use fast_io(d) #int_timer0 void interrupt_timer0(){ int1 a; int16 count; set_timer0(56); ++count; if(count == 500) { count=0; a=~a; RB0=a; } } void main() { set_tris_b(0); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_2); enable_interrupts(int_timer0); enable_interrupts(global); set_timer0(56); while(true) { } } thay đổi nội dung bởi: namqn, 30-04-2008 lúc 10:34 PM. |
![]() |
![]() |
|
|