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 : code này em mới tự viết, mục đích là nhấn nút bấm nối với RB0 thì chạy sang chuơng trình ngắt. Mấy anh xem giùm e coi sai chỗ nào, e mới học vài bữa nên không rõ lắm, e có mô phỏng Proteus nhưng k chạy khi nhấn RB0. Cám ơn mọi người |
Múi giờ GMT. Hiện tại là 07:11 PM. |
Tên diễn đàn: vBulletin Version 3.8.11
Được sáng lập bởi Đoàn Hiệp.
Copyright © PIC Vietnam