This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

serial communication in AT89c51

hello sir i have 8 bit data which is coming from ADC0808 this is taken into the AT89c51 micro controller via port P0 now i want to transmit this serially so i have to place data into SBUF (for this please send the C code)....

and after that i received some data serially into SBUF now i ahave to show this data on port P2( for this please send the C code)

i used this code:

SBUF=P0    /// to transfer port dat into SBUF
P2=SBUF // to transfer SBUF data into port 2<pre/>

  but it is not working


Parents
  • <b.sir

    here i am sending the detailed code see it and tell the correction

    #include<reg51.h>
    void serial_init()
    {
    TOMD=0x20;
    SCON=0x50;
    TH1=0xfd;
    TR1=1;
    }
    void main(void)
    {
    unsigned  char var;
    serial_init();
    while(1)
    {
    while(!RI);
    RI=0;
    ACC=SBUF;
    val=ACC;
    SBUF=val;
    while(!TI);
    TI=0;
    }
    }
    

    but i am not able to send data correctly into SBUF and not extracting data from SBUF into any other regioster

    please help me in code i tried in so many fashions but failed

Reply
  • <b.sir

    here i am sending the detailed code see it and tell the correction

    #include<reg51.h>
    void serial_init()
    {
    TOMD=0x20;
    SCON=0x50;
    TH1=0xfd;
    TR1=1;
    }
    void main(void)
    {
    unsigned  char var;
    serial_init();
    while(1)
    {
    while(!RI);
    RI=0;
    ACC=SBUF;
    val=ACC;
    SBUF=val;
    while(!TI);
    TI=0;
    }
    }
    

    but i am not able to send data correctly into SBUF and not extracting data from SBUF into any other regioster

    please help me in code i tried in so many fashions but failed

Children