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

How to communicate between RS232 VB6.0 & 8051 keil C

I want to have some leds in P2.0~2.3 and show off the "ON" lamp in VB6.0 program though RS232 during the sensors are +5V output to P1.0~1.3 89S52 MCU. But it appears many errors and doesn't work in PC. Please advise me the comments for the following code. Thanks a lot!!

Parents
  • Thanks! If i have the following codes, how to write the code through RS232 to PC?? Please advise it!!

    #include<REGX52.H>
    #include<STDIO.H>
    main()
    {
      TMOD=0x20;
      TH1=230;
      TL1=230;
      TR1=1;
    
      SCON=0x70;
      while(1)
        {
    
          RI=0;
              TI=0;
              SBUF=P1 | 0xf0;
              while(TI==0);
    
              while(RI==0);
    
              if(SBUF==0xfe)
                 P1=0x3f;
              else if(SBUF==0xfd)
             P1=0xcf;
              else if(SBUF==0xfb)
             P1=0x0f;
              else if(SBUF==0xf7)
             P1=0xff;
        }
    }
    

Reply
  • Thanks! If i have the following codes, how to write the code through RS232 to PC?? Please advise it!!

    #include<REGX52.H>
    #include<STDIO.H>
    main()
    {
      TMOD=0x20;
      TH1=230;
      TL1=230;
      TR1=1;
    
      SCON=0x70;
      while(1)
        {
    
          RI=0;
              TI=0;
              SBUF=P1 | 0xf0;
              while(TI==0);
    
              while(RI==0);
    
              if(SBUF==0xfe)
                 P1=0x3f;
              else if(SBUF==0xfd)
             P1=0xcf;
              else if(SBUF==0xfb)
             P1=0x0f;
              else if(SBUF==0xf7)
             P1=0xff;
        }
    }
    

Children