Microcontroller › 8051 › Problem with serial communication
- This topic has 4 replies, 3 voices, and was last updated 13 years, 8 months ago by
Syed Aameer.
Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
March 6, 2012 at 5:34 pm #1597
Julian
ParticipantHi, I’m doing serial communication between 8051 and PC and data will be displayed on LCD. Baud rate used is 9600 and crystal’s frequency is 11.0592MHz. When I type ‘ABC’ on the PC, the LCD will only display ‘AC’ but if i type ‘A B C’ meaning there is a space between the characters then the LCD can display ‘ABC’ as wanted. Does anyone know what is the problem? I googled and found people saying about using a buffer but i’m not sure how.
March 7, 2012 at 10:14 am #7269nikhiljain
Participantcheck the code step by step. there seems to be some logical error.
March 7, 2012 at 10:15 am #7270nikhiljain
Participantpost your code here..
March 7, 2012 at 4:21 pm #7277Julian
Participant#include <reg51.h>#include <stdio.h>#define lcd_port P1int j;unsigned char word;sbit rs = P3^5;sbit rw = P3^6;sbit en = P3^7;sbit BUT_serial = P0^0;sbit LED_serial = P2^0;char morning[]={“Gd morning LeeYJ!”};void delay(unsigned int msec){int i,j ;for(i=0;i<msec;i++)for(j=0;j<200;j++);}void lcdcmd(unsigned char value){rs = 0;rw = 0;lcd_port = value;en = 1;delay(1);en = 0;}void lcd_data(unsigned char display){rs = 1;rw = 0;lcd_port = display;en = 1;delay(1);en = 0;}void shift_left(){lcdcmd(0x18);delay(250);}void lcd_mrg(){for (j=0; morning[j]!=’