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.

ascii value for enter key

Status
Not open for further replies.

dinesh401

Advanced Member level 4
Joined
Aug 21, 2010
Messages
104
Helped
3
Reputation
4
Reaction score
2
Trophy points
1,298
Location
BANGALORE
Activity points
2,077
i want to send serial values to the 8051 mc by serial communication. but i want to send the values when i press the enter key. i wrote a sample code for serial interrupt program of 8051.
Code:
#include<reg51.h>


void isr(void) interrupt 4
{
	unsigned char dat[10];
	int i;
for(i=0;i<2;i++)
	{
	while(RI==0);
	RI=0;
	dat[i]=SBUF;
	SBUF=dat[i];
	while(TI==0);
	TI=0; 
        if(/* here i want to keep a ascii check for enter key*/)
        break;
	}		

	if(dat[0]=='3' & dat[1]=='c')
	{
	P0=0x01;

	}
	if(dat[0]=='3' & dat[1]=='e')
	{
	P0=0x02;
	}
	if(dat[0]=='3' & dat[1]=='f')
	{
	P0=0x03;
	}
	if(dat[0]=='3' & dat[1]=='i')
	{
	P0=0x04;
	}
	if(dat[0]=='3' & dat[1]=='j')
	{
	P0=0x05;
	}
	if(dat[0]=='3' & dat[1]=='l')
	{
	P0=0x06;
	}
	if(dat[0]=='3' & dat[1]=='o')
	{		 
	P0=0x07;
	}
	if(dat[0]=='3' & dat[1]=='q')
	{
	P0=0x08;
	}
	if(dat[0]=='3' & dat[1]=='r')
	P0=0x09;

	if(dat[0]=='3' & dat[1]=='t')
	{
	P0=0x0A;
	}
	if(dat[0]=='3' & dat[1]=='w')
	{
	P0=0x0B;
	}
	/*if(dat[0]=='3' & dat[1]=='x')
	{
	P0=0x0C;
	led2=0;
	} */
	if(dat[0]=='5' & dat[1]=='c')
	{
	P0=0x0D;
	}
	if(dat[0]=='5' & dat[1]=='e')
	{
	P0=0x0E;
	}
	if(dat[0]=='5' & dat[1]=='f')
	{
	P0=0x0F;
	}
	if(dat[0]=='5' & dat[1]=='i')
	{		 
	P0=0x10;
	}
	if(dat[0]=='5' & dat[1]=='j')
	{
	P0=0x11;
	}
	if(dat[0]=='5' & dat[1]=='l')
	P0=0x12;
	
}
void main(void)
{
TMOD = 0X20;
TH1=0xFD;
SCON=0X50;					  
TR1=1;
RI=0;
ES=1;
EA=1;
P0=0x00;
 while(1)
 {

	
}
}

whenever i press the enter key. the loop must break and continue to next instructions. can anyone tell me the logic for this.
thankyou
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top