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 tansmit single character via RS232 using P89V51RD?

Hi,
I am using P89V51RD2 NXP micro controller. I tried this code and able to transmit the char 's' for infinite time. Now i want to print/transmit it once. After removing the while(1) it print infinite time.
What should i change in my program to transmit for one time?

// Program to test serial communication of controller with PC using hyper terminal
#include<reg51.h>

void ini()     // Initialize Timer 1 for serial communication
{
TMOD=0x20;  //Timer1, mode 2, baud rate 9600 bps
TH1=0XFD;
SCON=0x50;
TR1=1;
}

void transmit()  // Funtion to transmit serial data
{
SBUF='s';
while(TI==0);
TI=0;
}

void main()
{
  ini();
while(1)
{
  transmit();
}
}
/



Parents
  • // Program to test serial communication of controller with PC using hyper terminal
    #include<reg51.h>
    
    void ini()     // Initialize Timer 1 for serial communication
    {
        TMOD=0x20;  //Timer1, mode 2, baud rate 9600 bps
        TH1=0XFD;
        SCON=0x50;
        TR1=1;
    }
    
    void transmit()  // Funtion to transmit serial data
    {
        SBUF='s';
        while(TI==0);
            TI=0;
    }
    
    void main()
    {
        ini();
        transmit();
    
        PCON = 0x02 ;         // Power Down Mode for P89V51R(Set PD bit in PCON)
    
    }
    

Reply
  • // Program to test serial communication of controller with PC using hyper terminal
    #include<reg51.h>
    
    void ini()     // Initialize Timer 1 for serial communication
    {
        TMOD=0x20;  //Timer1, mode 2, baud rate 9600 bps
        TH1=0XFD;
        SCON=0x50;
        TR1=1;
    }
    
    void transmit()  // Funtion to transmit serial data
    {
        SBUF='s';
        while(TI==0);
            TI=0;
    }
    
    void main()
    {
        ini();
        transmit();
    
        PCON = 0x02 ;         // Power Down Mode for P89V51R(Set PD bit in PCON)
    
    }
    

Children