PDA

View Full Version : uart 18f4550 bị lỗi


exellence
11-06-2012, 04:37 PM
Em truyền 1 kí tự từ máy tính xuống vdk. nhưng vdk nhận toàn bị sai. code dưới nếu truyền nhận cho chip 16f877a thì lại chuẩn. ko biết lỗi gì ah. các bác giúp e với
#include <18F4550.h>
#DEVICE ADC=8
#fuses HSPLL,MCLR,NOWDT,NOPROTECT,NOLVP,NODEBUG,USBDIV,PL L3,CPUDIV1,VREGEN
#use delay(clock=48000000)
#use rs232(baud=9600, parity=N, xmit=pin_C6, rcv=pin_C7,bits=9)
#include <LCD-20x4.h>
int8 temp;

void main(void)
{
lcd_init();

while(1)
{
temp = getc();
putc(temp);
output_b(temp);
printf(lcd_putc,"c= %d", temp);
}
}

hein_ts
24-06-2012, 04:49 PM
Các giá trị PLL, CPUDIV, thạch anh bạn xem lại xem để khai báo use delay cho chính xác