mithila
Newbie level 4
serial driver for 8051
Hi,
I'm developing serial driver for 8051.
I've compltd the code for sending the string as
SendStr( char *Str )
{
while( * Str != '\0' )
{
TI0 = 0;
SBUF0 = ( * Str );
while( !TI0 );
TI0 = 0;
Str++;
}
}
and i've also written for receiving using interrupt.
But now i've to change this receiving method as function Recvstr(char *ptr,int maxlength). Can anyone help?
The ISR routine is
void serialdriver(void) interrupt 4 using 1
{
if(RI0)
{
ch[j++] = SBUF0;
RI0 = 0;
if( ch[j-1] == 0x0d ) // 0x0d - hex value for new line
{
string = 1;
ch[j] = '\0';
}
}
}
Hi,
I'm developing serial driver for 8051.
I've compltd the code for sending the string as
SendStr( char *Str )
{
while( * Str != '\0' )
{
TI0 = 0;
SBUF0 = ( * Str );
while( !TI0 );
TI0 = 0;
Str++;
}
}
and i've also written for receiving using interrupt.
But now i've to change this receiving method as function Recvstr(char *ptr,int maxlength). Can anyone help?
The ISR routine is
void serialdriver(void) interrupt 4 using 1
{
if(RI0)
{
ch[j++] = SBUF0;
RI0 = 0;
if( ch[j-1] == 0x0d ) // 0x0d - hex value for new line
{
string = 1;
ch[j] = '\0';
}
}
}