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 / the function of the code “SBUF = value”.in RS232 interfacing code by som9543

the function of the code “SBUF = value”.in RS232 interfacing code by som9543

|

Microcontroller › 8051 › the function of the code “SBUF = value”.in RS232 interfacing code by som9543

  • This topic has 2 replies, 3 voices, and was last updated 9 years, 3 months ago by Ashutosh Bhatt.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • July 11, 2011 at 5:11 am #1059
    query
    Participant

    In RS232 interfacing code with 8051 the receive code is given as

    void recieve() //Function to receive serial data
    {
    unsigned char value;
    while(RI==0);
    SBUF=value;
    P1=SBUF;
    RI=0;
    }

    please let me know the function of the code “SBUF = value”. why it is important to assign some unknown value to SBUF?

    October 9, 2016 at 11:06 am #14189
    GANEEV SINGH
    Participant

    Hi there

    I guess the above code is not correct, shouldn't it be:

    void recieve() //Function to receive serial data
    {
    unsigned char value;
    while(RI==0);    //waits untill any reception occurs
    value=SBUF;      //stores 1 byte data in value 
    P1=vlaue;         //that value is also copied to PORT1
    RI=0;               //makes RX part get ready for another reception
    }

    At the end of this function you could also add SBUF=0;(just after RI=0;) to ensure no garbage value stays inside SBUF register, which might have affected the upcoming reception.

    October 11, 2016 at 1:23 pm #14193
    Ashutosh Bhatt
    Participant

    receive function is just to receive value from serial port

    so we can not assign any value to SBUF

    actually it should be value = SBUF

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

RSS Recent Posts

  • Wien bridge oscillator January 19, 2026
  • Silicone insulated wire January 19, 2026
  • Op amp shock January 19, 2026
  • Is the input voltage selectable ? January 19, 2026
  • Unable To Get Advertised Op-Amp Slew Rate January 19, 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