View Single Post
Old 11-09-2013, 05:02 PM   #4
buivantuyen89th
Đệ tử 3 túi
 
buivantuyen89th's Avatar
 
Tham gia ngày: Jun 2012
Bài gửi: 54
:
Trích:
Nguyên văn bởi thuanbk1989 View Post
hi!
Chào mọi người. mọi người giúp e với nhé.
E dùng lệnh delay_ms(10000); nói chung là lệnh delay thì nó chạy k có đúng lệnh delay_ms(10000) mà nó chạy 13,5s lận. e phải làm sao giờ tại e cần độ chính xác xíu.
Nọi thứ đều hoạt động tốt chỉ sai chỗ này thui .e có dùng lênh #use delay( clock = 20000000)
CODE:
#int_EXT
#use delay( clock = 20000000)
void EXT_isr(void)
{
//delay_ms(1000);
Output_high(pin_a1);
//delay_ms(2000);
}
void main()
{

setup_adc_ports(sAN0|VSS_VDD);
setup_adc(ADC_CLOCK_DIV_2);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
ext_int_edge (0 ,L_TO_H) ; //chon kieu ngat tu muc thap len cao
//Setup_Oscillator parameter not selected from Intr Oscillator Config tab

// TODO: USER CODE!!
set_tris_a(0b00000101);
//set_tris_c(0b00000000);

while(1) {
Output_high(pin_a1);
delay_ms(5000);
Output_low(pin_a1);
delay_ms(5000);

}
cảm ơn moi người trước nhé
Mình cũng chưa có điều kiện thử độ chính xác của delay.hi. nhưng mình nghĩ thế này.bạn làm xem có được không nhé.
bỏ hết các ngắt khác ( chỉ để mình ngắt ngoài để kiểm tra) và chuyển lệnh use delay lên bên trên int_EXT.
Chúc bạn thành công!
buivantuyen89th vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn