|
Tài trợ cho PIC Vietnam |
Những câu hỏi thường gặp Những lỗi cơ bản thường gặp khi làm việc với PIC hoặc những vấn đề cơ bản nhất thường được hỏi trong những năm qua |
|
Ðiều Chỉnh | Xếp Bài |
10-11-2010, 06:15 PM | #1 |
Nhập môn đệ tử
Tham gia ngày: Feb 2010
Bài gửi: 3
: |
Lập trình ngắt timer0 pic8f452
em viết đoạn chương trình này nhưng không chạy là sao hả các bác
#include <18f452.h> #device adc=8 #FUSES NOWDT //No Watch Dog Timer #FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale #FUSES RC_IO //Resistor/Capacitor Osc #FUSES NOPROTECT //Code not protected from reading #FUSES NOOSCSEN //Oscillator switching is disabled, main oscillator is source #FUSES BROWNOUT //Reset when brownout detected #FUSES NOPUT //No Power Up Timer #FUSES STVREN //Stack full/underflow will cause reset #use delay(clock=20000000) #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bi ts=8) int16 count; int8 led ; #int_timer0 void ngat_timer0() { set_timer0(57); ++count; if(count>=98) { count=0; led<<=1; led+=1; } } void main() { setup_adc_ports(NO_ANALOGS); setup_adc(ADC_OFF); setup_psp(PSP_DISABLED); setup_spi(SPI_SS_DISABLED); setup_wdt(WDT_OFF); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); set_tris_b(0); set_timer0(57); enable_interrupts(global); enable_interrupts(int_timer0); while(1) { output_b(led); } } |
|
|