Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

regarding serial communication

Status
Not open for further replies.

nigam

Newbie level 1
Newbie level 1
Joined
Mar 11, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,295
Hi sir,
I am trying to implement a serial communication between PC and microcontroller at89s52.for this I am Initializing SCON,TMOD,TH1,TR1 registers. i am sending a data from hyper terminal in small letters .according to program controller should receive data send it back in capital letters .but I am not getting the result.
At hyper terminal I am getting the same data I am sending, it means there is a close circuit and data is loop back. i have checked the baud rate too, both are working on same baud rate i.e. 9600.I have checked the books, in forums ,and on the websites. there they are giving the same logic and code I am using.
I am not getting how to resolve this problem. please help me

my code is:: the uart.c file
#include<reg51.h>
void uart_tx(unsigned char);
unsigned char * uart_rx(void);
void TXCHAR(unsigned char);
void init_uart(void)
{
//EA=0;
SCON=0x50;
TMOD=0X20;
TH1=0Xfd;
TR1=1;
//ES=1;
//EA=1;
//TI=1;
}

void uart_tx(unsigned char c)
{
SBUF=c;
while(TI==0);
//delayms(2);
TI=0;
return;
}
unsigned char * uart_rx()
{
unsigned char P;
while(!RI);
RI=0;
P= SBUF-32
return P;
}



TXSTR(unsigned char c[])
{
unsigned int i=0;
while(c)
{
uart_tx(c);
i++;
}
}


the main.c file
#include<reg51.h>
#include<string.h>
#include"DELAY.h"
#include"uart.c"
main()
{
unsigned char buff[]={"ankit"};
unsigned char *buff_rcv;
init_uart();

while(1)
{

buff_rcv=uart_rx();
TXSTR(buff_rcv);


}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top