I have AT89C51 controller and i m trying to establish communication between controller and my Laptop via serial cable. I am using At89c51. I have hyperterminal tool. I don't think there is anything wrong in hyperterminal because its showing connected status.
I am not looking any text message on hyperterminal. What could be wrong
I am not looking any text message on hyperterminal. What could be wrong
C:
#include <reg51.h>
//Function Prototype
void Serial_Init(void);
void Send_Byte(unsigned char);
char Receive_Byte(void);
void Send_String(char String[]);
void main(void)
{
Serial_Init(); //Initialze Serial communication by calling Serial_Init() function
EA = 1;//Enable Globle interrupt
ES = 1;//Enable Serial interrupt
Send_String("Hello!!");
while(1)
{
}
}
void Serial_Init(void)
{
TMOD = 0x20;// Timer 1 in mode 2 auto reload mode for baudrate generation
SCON = 0x50;// Serial Mode 1, 8-DATA bit 1-Start Bit, 1-Stop Bit, Receive Enable
TH1 = 0xFD;// Load value for 9600 baudrate
TR1 = 1;// Start Timer
}
void Send_Byte(unsigned char DATA)
{
SBUF = DATA; //Load data into SBUF
while(TI == 0); //Wait untill transmission to complete
TI = 0; //Clear transmitte interrupt(TI) flag
}
char Receive_Byte(void)
{
char Receive;
while(RI == 0); //wait for character
Receive = SBUF; //Read received data from SBUF
RI=0; //Clear Receive interrupt flag
return Receive;
}
void Send_String(char String[])
{
unsigned char count;
for(count=0;String[count]!='\0';count++) //Send single byte one by one untill null character in string
Send_Byte(String[count]);
}
void serial_ISR (void) interrupt 4 //Serial interrupt
{
//receive character
char Receive;
if(RI==1)
{
Receive = SBUF; //Read received data from SBUF
RI = 0; //Clear Receive interrupt flag
Send_Byte(Receive); //echo received character
}
P1 = Receive; //Display ASCII value of receive character at P1
RI = 0;
}