praveenrpk92
Newbie level 6
I am trying to interface my PC with 8051 using a CP2102 USB to UART bridge. I tried sending the characters 'M' & 'C' and view them using hyper terminal. I am able to receive the characters but instead of receiving them once, the data is received repeatedly in a loop fashion. I simulated this in Proteus and it works as expected i.e. I'm getting characters MC and them the program halts in while loop. Same results as proteus in Keil Debug as well. Please help me fix this issue.
![8051SerialSimulation.PNG 8051SerialSimulation.PNG](https://www.edaboard.com/data/attachments/58/58916-496557bde2f5b1b7591b26816f924b1a.jpg)
Code:
#include <REGX52.h>
void delay_us(unsigned int d);
void send(unsigned char x);
void main(void)
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
RI=0;
TI=0;
send('M');
delay_us(1000);
send('C');
while(1){
}
}
void delay_us(unsigned int d)
{
unsigned int i, limit;
limit = d/15;
for(i=0;i<limit;i++);
}
void send(unsigned char x)
{
SBUF=x;
while(TI==0);
//delay_us(10000);
TI=0;
}
![8051SerialSimulation.PNG 8051SerialSimulation.PNG](https://www.edaboard.com/data/attachments/58/58916-496557bde2f5b1b7591b26816f924b1a.jpg)