EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Problem with serial communication

Problem with serial communication

|

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)
  • Author
    Posts
  • March 6, 2012 at 5:34 pm #1597
    Julian
    Participant

    Hi, 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 #7269
    nikhiljain
    Participant

    check the code step by step. there seems to be some logical error.

    March 7, 2012 at 10:15 am #7270
    nikhiljain
    Participant

    post your code here..

    March 7, 2012 at 4:21 pm #7277
    Julian
    Participant

     

    #include <reg51.h>
    #include <stdio.h>
    #define lcd_port P1
     
    int 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]!=’’;j++)
    {
      lcd_data(morning[j]);
      delay(100);
    }
    }
     
    void serial()
    {
    int m;
    lcdcmd(0x01);
    delay(150);
     
    for(m=0; m<=15; m++)
    {
    while (RI == 0);
    word = SBUF;
    lcd_data(word);
    RI = 0;
    }
     
    lcdcmd(0xC0);
    for(m=0; m<=15; m++)
    {
    while (RI == 0);
    word = SBUF;
    lcd_data(word);
    RI = 0;
    }
    }
     
    void lcd_init()
    {
    lcdcmd(0x38);
    delay(150);
    lcdcmd(0x0E);
    delay(150);
    lcdcmd(0x01);
    delay(150);
    lcdcmd(0x06);
    delay(150);
    lcdcmd(0x80);
    delay(150);
    }
     
    void main(void)
    {
    lcd_init();
    lcd_mrg();
    shift_left();
    TMOD = 0x20;
    TH1 = 0xFD;
    SCON = 0x50;
    TR1 = 1;
     
    while(1)
    { 
    if(!BUT_serial)
    {
    LED_serial = 0;
    serial();
    if (RI == 0)
    {
    shift_left();
    }
    }
     
    else 
    {
    shift_left();
    }
     
    }
    }
     
    This is my code. Your help will be much appreciated. 
    March 11, 2012 at 4:27 pm #7283
    Syed Aameer
    Participant

    buffer means say for in your program you are using word as variable to store SBUF value..

     

    declare the word as Word[15]..

    then in recieviing Program

     

    while(RI==0);

    Word[i++]=SBUF;

     

     

    where i=0;

    then diplay the Word value in for loop..

     

    Hope this may help you

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Panasonic RQ-A170 Walkman recorder November 16, 2025
  • Looking for obsolete item from Parallax November 16, 2025
  • Can a small solar panel safely trickle-charge old NiMH AA batteries? November 16, 2025
  • TraxMaker Pro? I only have the non-Pro version. Looking for the Pro version that has the integrated pick and place coordinates export. November 16, 2025
  • ESP32-S3 started outputting NMEA GPS location frames after EMC disturbance — what mode is this? November 15, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise