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 / serial data is not receiving by 8051 micro controller

serial data is not receiving by 8051 micro controller

|

Microcontroller › 8051 › serial data is not receiving by 8051 micro controller

  • This topic has 3 replies, 4 voices, and was last updated 11 years, 11 months ago by SHAH DISHANT H..
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • August 3, 2013 at 4:22 am #4830
    V L RAGHURAM
    Participant
    Hi friends, i am new to this forum, i have encountered a problem, i want to send the serial data from PC to 8051 micro controller through serial port and hyper terminal software, but the data is not receiving by micro controller. I want to display the character on 16 x 2 LCD display. RI is not setting to 1 and the routine what i written to receive and display the character is not executing. I am using Flash magic software to dump the code into micro controller and it is going properly. 
     
    Since one week i am facing this problem, earlier it worked properly(data displayed on LCD). I attached my code and circuit diagram, so please suggest me what to do.

    #include <REGX51.H>
     
     
    sbit rs = P3^7;
    sbit rw = P3^5;
    sbit en = P3^6;
     
    void msdelay(unsigned int value)
    {   
    unsigned int i,j;
    for(i=0;i<value;i++)
    for(j=0;j<1275;j++);
    }
     
    void LCD_data(unsigned char x)
    {
     
     rs=1;
     rw=0;
     P1=x;
     en=1;
     msdelay(6);
     en=0;
     msdelay(6);
    }
     
    void LCD_cmd(unsigned char x)
    {
      
      rs=0;
      rw=0;
      P1=x;
      en=1;
      msdelay(6);
      en=0;
      msdelay(6);
    }
     
    void lcd_str(unsigned char *str)
    {
     int x;
     for(x=0;str[x]!=0;x++)
      {
        LCD_data(str[x]); 
      }
    }
     
    void lcd_ini()                  //Function to initialize the LCD
    {
        LCD_cmd(0x38);          
        msdelay(5);
        LCD_cmd(0x0F);        
        msdelay(5);
        LCD_cmd(0x80);
        msdelay(5);
    }
     
    /* this headder file having the functions
    serialinit()
    tx(hex value) 
    txs(string)
    rx()
     
    */
    void serialinit()   //serialinitilization
    {
    TMOD=0x20;// timer1,mode2
    SCON=0x50;
    TH1=-3;
    TR1=1;
    }
    void tx(unsigned char ch) //transmitting a single charecter
    {
    SBUF=ch;
    while(TI==0);  //wait until TI=1
    TI=0;
    }
    void txs(unsigned char *chr) //to send a string
    {
    unsigned char i=0;
    for(i=0;chr!=’’;i++)
    tx(chr);
    }
    unsigned char rx()  //serial receiving
    {
    unsigned char ch;
    while(RI==0);
    ch=SBUF;
    RI=0;
    LCD_cmd(0x01);
    LCD_data(ch);
    }
     
     
     
     
     
    void main()   
    {
    serialinit();
    lcd_ini();
    txs(“testing string”);
    lcd_str(“Raghuram”);
    while(1)
    {
    rx();
    }
      
     
    }
    January 6, 2014 at 8:01 pm #10831
    AJISH ALFRED
    Participant

    Hi Raghuram,

    RI and TI are bits, right? so try

     

    “while ( RI = 0 );” and “while ( TI = 0 );” instead of “while ( RI == 0 );” and “while ( TI = 0 );”

    February 9, 2014 at 12:58 pm #10985
    Ashutosh Bhatt
    Participant

    there must be a problem in your baud rate. it wont be same on both side

    set 9600 baud rate in your hyper terminal software (or flash magic or tera term) in PC

    to set 9600 baud in your 8051 use 11.059 MHz crystal. and calculate proper value to load in timer registers.

    February 25, 2014 at 5:29 am #11100
    SHAH DISHANT H.
    Participant

    Hi,

     

    Have you checked with baud rate?

     

    Set the same baudrate on both side and check it.

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

RSS Recent Posts

  • Buffer design? February 9, 2026
  • BPF February 9, 2026
  • To couple or decouple February 9, 2026
  • ANOTHER OLD PROJECT REDO February 9, 2026
  • Op amp shock February 9, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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