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 / Help for serial communication

Help for serial communication

|

Microcontroller › 8051 › Help for serial communication

  • This topic has 3 replies, 2 voices, and was last updated 12 years, 6 months ago by AJISH ALFRED.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • January 4, 2013 at 8:57 am #2047
    Radhika
    Participant

    Hello,

    I am developing a controller based serial communication project  in which I am sending two data to serial port. One is for selecting output pin & second for getting different timer delay value to generate different delayed pulses. My problem is that I can’t properly send data to serial port please help me if anyone have idea about this.

    I am using AT89c52 controller & max232 for level converter. Here is my code.

    Please help me..

    Thanks in advance.

    My code:

     

     

    #include <AT89X52.H>
    #include<stdio.h>
     
    sbit Pulse1=P1^0;
    sbit Dir1=P1^1;
    sbit Pulse2=P1^2;
    sbit Dir2=P1^3;
     
    sbit a=P0^0;
    sbit b=P0^1;
    sbit c=P0^2;
    sbit d=P0^3;
     
    msdelay(unsigned int value);
    getdata();
    unsigned int value;
     
    getdata()
    {
            if(b)   // For Dir1
            Dir1=1;
            if(d)    //  For Dir2
            Dir2=1; 
            
    if((!a)&(!c))
    {
    Pulse1=0;
    Pulse2=0;
    }
     
    if(a&(!c))         
       {
    Pulse1=1;
    msdelay(value);
    Pulse1=0;
    msdelay(value);
    }
     
    if((!a)&c)
    {
    Pulse2=1;
    msdelay(value);
    Pulse2=0;
    msdelay(value);
    }
     
    if(a&c)
    {
    Pulse1=1;
    Pulse2=1;
    msdelay(value);
    Pulse1=0;
    Pulse2=0;
    msdelay(value);
    }
    }
    void recive(void) interrupt 4
    {
    unsigned int mybyte,i;
      while(1)
      {
    if(RI==1)
    {
    P0=0xFF;
        ACC=0x00;
        P1=0x00;
    }
     
    if(i==0)
    {
     mybyte=SBUF;
     ACC=mybyte;
     P0=ACC;
     RI=0;
     i++;
    }
     
    if(i==1)
    {
     mybyte=SBUF;
     ACC=mybyte;
     value=ACC;
     RI=0;
     i=0;
    }
    getdata();
       }
    }
    void main()       
    {  
       P1=0x00;
       EA=1;
       ES=1;  
       SCON = 0x50; // mode 1, 8-bit UART, enable receiver 
       TMOD = 0x20; // timer 1, mode 2, 8-bit auto-reload 
       TH1 = 0xFD; // for 9600 baud rate 0xFD
       TR1 = 1;    // run timer 1
      
       while (1) 
       { 
       }
     
    }
     
    //delay function
    msdelay(unsigned int value)
    {
    unsigned int x,y;
    for(x=0;x<value;x++)
    for(y=0;y<1275;y++);

    } 

    January 5, 2013 at 6:24 pm #8905
    AJISH ALFRED
    Participant

    Hi Radhika,

    Where are you trying to display the data? Are you getting junk data or simply nothing?

    January 7, 2013 at 11:35 am #8914
    Radhika
    Participant

    I am dispiaying data on Led connected toPort1 but when i enter two data it accepts only one either 1st or 2nd data as input.

    Here problem is in accepting 2nd input but i dnt know how to solve it… Please help me.

    January 8, 2013 at 11:34 am #8920
    AJISH ALFRED
    Participant

    You are not calling any functions from your main function. Then how the code will it do something?

  • 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

  • How to make string LEDs? July 10, 2025
  • Raise your hand if your car had one of these: July 10, 2025
  • The Analog Gods Hate Me July 10, 2025
  • Display TFT ST7789 (OshonSoft Basic). July 10, 2025
  • Fixing board, Easy question HEX SCHMITT July 10, 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