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.

[General] c code for receiving 8 bit data from hyperterminal to 89c51

Status
Not open for further replies.

Sagar Shinde

Newbie level 3
Joined
Feb 6, 2014
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
22
i am doing home automation project but i dont know how to enable particular pin i.e P1.0 enable when 8 bit data is received
Description:
consider, when i send 10011101 from hyperterminal then only P1.0 pin is enabled
when i send 10111100 from hyperterminal then only P1.1 pin is enabled


please send me c code
 

which compiler you are using following explaination for 8051 and keil compiler.

first you have to define bit as

Code:
sbit pin1=P1^0;
sbit pin2=P1^1;

above main function.

then compare the recieved character with you data as you given

Code:
if(receiv_data == 0x9D)
	pin1 = 1;
else if (receiv_data == 0xBC)
	pin2 = 1;
 

which compiler you are using following explaination for 8051 and keil compiler.

first you have to define bit as

Code:
sbit pin1=P1^0;
sbit pin2=P1^1;

above main function.

then compare the recieved character with you data as you given

Code:
if(receiv_data == 0x9D)
	pin1 = 1;
else if (receiv_data == 0xBC)
	pin2 = 1;

thank you!!! i will try
 

#include<reg51.h>
sbit pin1=P1^0;
sbit pin2=P1^1;

void main(void)
{
unsigned char i;
unsigned char bit1[]="10101010";
unsigned char bit2[]="11110000";
unsigned char buff[8];
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
while(1)
{
while(RI==0)
{
for(i=0;i<8;i++)
{
buff=SBUF;
}

if(buff==bit1)
{
pin1=1;
}
else
{
pin2=1;
}
}
}
}




here is my code please suggest me what can i do to comparision between bit1 and receiving data from hyperterminat

- - - Updated - - -

#include<reg51.h>
sbit pin1=P1^0;
sbit pin2=P1^1;

void main(void)
{
unsigned char i;
unsigned char bit1[]="10101010";
unsigned char bit2[]="11110000";
unsigned char buff[8];
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
while(1)
{
while(RI==0)
{
for(i=0;i<8;i++)
{
buff=SBUF;
}

if(buff==bit1)
{
pin1=1;
}
else
{
pin2=1;
}
}
}
}




here is my code please suggest me what can i do to comparision between bit1 and receiving data from hyperterminal
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top