24-01-2008, 03:34 PM | #20 |
Đệ tử 5 túi
Tham gia ngày: Sep 2006
Bài gửi: 100
: |
Để chương trình dễ theo dõi hơn tui đã làm như sau: Dùng phần mềm Com Master do minhcuong cung cấp ở link này: http://www.picvietnam.com/forum/show...p?t=274&page=4. Phần mềm này sẽ gửi các ký tự gõ vào từ bàn phím xuống cho vi điều khiển, vi điều khiển nhận ký tự trong ngắt nhận và truyền trở lại cho máy tính.
Code:
#include <16F877A.h> #include <def_877a.h> #device *=16 adc=10 #FUSES NOWDT, XT, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT #use delay(clock=4000000) #use fast_io (b) #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9) #include <lcd_lib_4bit.c> #INT_RDA Receive_isr() { char c; disable_interrupts(GLOBAL); c = getc(); // nhận ký tự putc(c); // truyền trả lại cho máy tính enable_interrupts(GLOBAL); } //----------------------------------------------------------------- void main(void) { output_b(0xC0); set_tris_a(0xC0); set_tris_b(0xC1); port_b_pullups (TRUE); set_tris_c(0xD0); LCD_init(); delay_ms(500); LCD_putcmd(0x80); enable_interrupts(INT_RDA); enable_interrupts (global); while (1) {} }
__________________
Do more than exist, LIVE |
|
|