|  | 
| 
 | 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 | 
|  23-09-2013, 07:01 PM | #1 | 
| Nhập môn đệ tử Tham gia ngày: Aug 2013 Nơi Cư Ngụ: hồ chí minh 
					Bài gửi: 6
 : | 
				
				interrupts
			 #include "C:\Users\Tran Van Long\Desktop\LAB\NUT NHAN\nutnhan.h" #include <def_877a.h> #fuses HS,NOWDT #use delay(clock=20000000) #int_global ///////////////////////////////// // chuong trinh nut nhan void LED_nhap_nhay() { portd=0xFF; delay_ms(20); portd=0x00; delay_ms(20); } ///////////////////////////////// void ngat_portb(); void ngat(); void IO(); void main() { setup_adc_ports(NO_ANALOGS); setup_adc(ADC_OFF); setup_psp(PSP_DISABLED); setup_spi(SPI_SS_DISABLED); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE); // TODO: USER CODE!! ngat_portb(); IO(); ngat(); while(1) { LED_nhap_nhay(); } } void IO() { set_tris_d(0x00); portd=0x00; } void ngat() { enable_interrupts(global); enable_interrupts(int_ext); clear_interrupt(int_ext); ext_int_edge(H_TO_L); } #int_ext void ngat_portb() { output_high(PIN_B0); output_high(PIN_B1); delay_ms(100); } P/S: Em mới học về PIC và tự viết code này. Cho em hỏi là em dùng Interrupts: Nhấn RB0 thì chạy sang chương trình ngắt, nhưng qua mô phỏng Proteus không chạy được. Mấy anh xem giùm em với. Cám ơn mọi người. | 
|   |   | 
|  | 
| Ðiều Chỉnh | |
| Xếp Bài | |
| 
 | 
 |