Check Software for 8051 Uart communcation

Status
Not open for further replies.

namees22

Junior Member level 2
Joined
Aug 30, 2012
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Ernakulam
Activity points
1,430
Hi ,

I am posting my UART code here can anyone tell what all things that i have to consider while writing
a SoftUART for my 8052 controller..help me guys


#include<reg52.h>

#define RX1 P1^2 #define TX1 P1^3

unsigned char data SBUFF; sbit data TFLG;

void external_interrupt(void) interrupt 0
{

//Function body
}

void rev_fn(void)
{ unsigned char cp_dat,tr=0,rcd;

cp_dat=RX1; while(tr<8) { rcd=(0x80&RX1)?1:0; cp_dat=cp_dat<<1; tr++; } TFLG=1; SBUFF=rcd;
} void tx_fn(void)
{ unsigned char cp_dat,tr=0,txd;

cp_dat=SBUFF; while(tr<8) { TX1=(0x80&dat)?1:0; cp_dat=cp_dat<<1; tr++; } TFLG=1;
} void main()
{ TMOD=0x02; TH0=0xFD; SCON=?; TR0=1; IE=0x81; while(1);
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…