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.

Serial comm with 8051

Status
Not open for further replies.

Monu johar

Newbie level 5
Joined
Aug 19, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,330
I want to represent data bits on port2 of 8051...and this same data is transmitted serially on rxd pin of uC by putty software on pc. I.e if i send byte "1" by putty software then this byte "1" should be represented on port 2 in terms of 8 bits on port 2 pins...can anyone provide me code. At 9600 boud rate.
 

hey try this..

Code:
#include<reg51.h>
#include<string.h>
char a;
void main()
{ 
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
SBUF=' ';
TR1=1;
while(1)
{
while(RI==0);
a=SBUF;
P2=a;
}
}
 
Last edited by a moderator:

Code:
#include<reg51.h>
unsigned int rdata;

void recieve() interrupt 4  \\ interrupt for recive the data
{
if(RI==1)
{
rdata=SBUF;
RI=0;  
P2=rdata;
}

}

void main()
{
    TMOD=0x20;                         
    TH1=0XFD;
    SCON=0x50;
    TR1=1;
    EA=1;
    ES=1;                             
    delay(200);
    while(1)
    {
	SBUF='A';       \\ it will send data 'A' Serily & waiting for interrupt
        while(TI==0);    

    }
}


try this and update me.....in this am using interrupt for display received data...
 

If you need code in assembly, drop a line,
 

This code is not working sir.
I have code as
org 0h
AJMP BEGIN
ORG 40h
BEGIN : MOV SCON,#01010000B
MOV TH1,#0FDH
MOV TMOD,#00100000B
MOV P2,#00H
MOV A,#00H
SETB TR1
START: JNB RI,START
MOV A, SBUF
MOV P2, A
CLR RI
AJMP START
END
this code is not working. Data is coming on rxd pin of port 3 .i checked by cro... All bits are coming correctly..

- - - Updated - - -

In starting there is not org 0h,
there is ORG 0.

- - - Updated - - -

Sir you have used
EA =1 AND
ES=1
. Why you used this i know this is ie register for intrpt . What if i do not use this in my programming for only receiving data. I have not clear cut about this.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top