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

problem in 8051 to matlab communication

hi
i am final year student of electrical engineering and doing a project on 8051 microcontroller.
in this project,i have to interface the 8051 to maltab for real world data.i successfully complete the interfacing and communicate serially on proteus.data which is transfer from 8051 to matlab is not accurate when i send more than one character.in single character, matlab does not show any data.plz help me,how to solve that problem as i am using 8051 first time.

Parents
  • sorry, here's the code again with comments...

    
    #include <reg51.h>
    sbit d1=P1^0;
    void main(void)
    {
    
     PCON=0xFF;                     //to set PCON.7 for baud rate
     TMOD=0x20;                     //timer 1 mode 2
     TH1=0xFA;                      //for baud rate 9600
     SCON=0x50;
     TR1=1;                         //start timer 1
     if(d1==1)
        {SBUF='Y';                  //sends Y
         while(TI==0);
         TI=0;
        }
    
     else
         {SBUF='N';                 //sends N
         while(TI==0);
         TI=0;
         }
     SBUF=0x0D;                     //sends carriage return and line feed
     while(TI==0);
     TI=0;
     SBUF=0x0A;
     while(TI==0);
     TI=0;
    
    }
    

Reply
  • sorry, here's the code again with comments...

    
    #include <reg51.h>
    sbit d1=P1^0;
    void main(void)
    {
    
     PCON=0xFF;                     //to set PCON.7 for baud rate
     TMOD=0x20;                     //timer 1 mode 2
     TH1=0xFA;                      //for baud rate 9600
     SCON=0x50;
     TR1=1;                         //start timer 1
     if(d1==1)
        {SBUF='Y';                  //sends Y
         while(TI==0);
         TI=0;
        }
    
     else
         {SBUF='N';                 //sends N
         while(TI==0);
         TI=0;
         }
     SBUF=0x0D;                     //sends carriage return and line feed
     while(TI==0);
     TI=0;
     SBUF=0x0A;
     while(TI==0);
     TI=0;
    
    }
    

Children
No data