![]() |
![]() |
#5 | |
Đệ tử 5 túi
Tham gia ngày: Oct 2005
Bài gửi: 117
: |
Trích:
Còn về lập trình giao tiếp RS232 tôi đã có một bài mẫu. Chương trình nhận ký tự từ bàn phím và hiên thị ra LCD, rồi xuất trả lại máy tính ký tự đó. Code:
#include <16f877a.h> #include <def_877a.h> #use delay(clock=20000000) #FUSES NOWDT, HS, NOPUT, NOPROTECT, NODEBUG, NOBROWNOUT, NOLVP, NOCPD, NOWRT #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9) #include <lcd_lib_4bit.c> #include <input.c> int8 count=0; char string_in[16]; #INT_RDA Receive_isr() { char c; int8 i; count++; c = getc(); putc(c); if (c=='c' | c=='C') {LCD_putcmd(0x01);count=0;} //Clear Screen if (count<=16) LCD_putchar(c); else {count=0;LCD_putcmd(0xC0);} } void main() { enable_interrupts(int_rda); enable_interrupts(GLOBAL); lcd_init(); lcd_putcmd(0x01); lcd_putcmd(line_1); printf("Enter a String."); printf("Or anything you want!"); while (1) {} } thay đổi nội dung bởi: falleaf, 04-02-2008 lúc 10:32 AM. |
|
![]() |
![]() |
|
|