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

serial communication

I am using a Atmel AT89C51 and I am having trouble doing serial communication. Here is what I am trying:

#include <AT89X51.H>
#include <STDIO.H>
#include <intrins.h>

int i,j;

void main()
{
PCON |= 0x00; /* don't double baud rate */
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD |= 0x20; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 253; /* TH1: reload value for 9600 baud @ 11.0592 MHz */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */

do{
P1 = P2;
printf("i got a pocket full");
putchar(0x20);
for(j=0; j<255; j++);
{
for(i=0; i<255; i++)
{
_nop_();
_nop_();
}
}
printf("yyyyyyy\n\n");
}while(1);
}

Any suggestions as to what I should try would be appreciated. Thanks.