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 receive character to P89V51RD using serial communication?

Hi everyone,
In my code receive session is not working.. what changes should i made to receive a character from my keyboard?

// 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 recieve()  //Function to receive serial data
{
unsigned char value;
while(RI==0);
value=SBUF;
P1=value;
RI=0;
}

void transmit()  // Funtion to transmit serial data
{
P2=P1-32;
SBUF=P2;
while(TI==0);
TI=0;
SBUF=P1;
while(TI==0);
TI=0;
}

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


Thank in advance

Parents
  • interruptifobia seems, in 99% of the cases, to be the reason to use polled.

    I can't remember when I last (if ever) used polled.

    Using interrupts is not rocket science, and using poll, which may work very well in simple apps will, as your code grows, someday, show uip as one of these "unexplainable once in a day hiccups".

    Erik

Reply
  • interruptifobia seems, in 99% of the cases, to be the reason to use polled.

    I can't remember when I last (if ever) used polled.

    Using interrupts is not rocket science, and using poll, which may work very well in simple apps will, as your code grows, someday, show uip as one of these "unexplainable once in a day hiccups".

    Erik

Children
No data