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 / Transmitting an integer serially by AT89S51

Transmitting an integer serially by AT89S51

|

Microcontroller › 8051 › Transmitting an integer serially by AT89S51

  • This topic has 1 reply, 2 voices, and was last updated 12 years, 9 months ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 9, 2013 at 6:36 am #2174
    Saad Rafey
    Participant

     

    I have written a program to transmit char value serially for AT89S51. Its is working perfectly.
     
    Program is given below:-
     
     
     
     
         #include<reg51.h>
         void main()
         {
         TMOD=0x20;
         TH1=0xFD;
         SCON=0x50;
         TR1=1;
         while(1)
         {
         SBUF=’A’;
         while(TI==0);
         TI=0;
         }
         }
     
     
     
     
    In above code char ‘A’ is transmitted.
     
    Now I want to transmit an integer value and I have written a program for it.
     
    Program is given below:-
     
     
     
         #include<reg51.h>
         void main()
         {
         int i=61;
         TMOD=0x20;
         TH1=0xFD;
         SCON=0x50;
         TR1=1;
         while(1)
         {
         SBUF=i;
         while(TI==0);
         TI=0;
         }
         }
     
     
     
    Above program is transmitting ‘ = ‘(i.e decimal 61 corresponds to ‘ = ‘  character in ASCII).
     
    I want to know how I can transmit an integer value.
     
    Please guide me in this regard.  
    March 11, 2013 at 4:49 pm #9298
    AJISH ALFRED
    Participant

    Hi Saad,

    You can transmit a single digit integer like this.

    If you have a single digit integer, say ‘7’ stored in a variable ‘i’

     

    int i = 7

     

    Now you can transmit the ‘7’ using the following,

     

    SBUF = ‘0’ + i;                //Simply adding the value to the ascii value of zero

     

    Hope this helps.

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

RSS Recent Posts

  • mechanism to shutdown feeding when sensor temperature rises December 9, 2025
  • Want Thermal Camera with Fixed Thermal Span option December 8, 2025
  • Bad design , bad maintenance or just how it was. December 8, 2025
  • Looking for single photovoltaic cells for light gate December 8, 2025
  • Sanity Check – Peltier "Cooler" for Heating and Cooling December 8, 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