Home > other >  Consecutive serial communication to send strings, is there anyone more efficient, by the way that ho
Consecutive serial communication to send strings, is there anyone more efficient, by the way that ho

Time:02-07

\ * this is my humble way, serial port register is configured * \
Void Uart1BYTE (uint temp)
{
ES=0;
SBUF=temp;
while(! TI);//waiting to send complete signal appears (TI=1)
TI=0;
ES=1;
}

While (str1 [I]!='\ 0')
{
Uart1BYTE (str1 [i++]);
}
Void Serial_interrupt () interrupt 4//serial port interrupt
{
If (RI)
RI=0;//reset interrupt reception, said it would continue to receive
If (TI)
TI=0;
}


\ * I find elsewhere, no success sending * \
Void Serial_interrupt () interrupt 4
{
//a=SBUF;
The P2=SBUF;
RI=0;//reset interrupt reception, said it would continue to receive
//flag=1;//to interrupt the mark symbol of
}


Void Uart1Send (uchar c)
{
SBUF=c;
while(! TI);//waiting to send complete signal appears (TI=1)
TI=0;
}

//serial port for sending char array, termination date/0 will stop
Void Uart1Sends uchar * (STR)
{
While (* STR!='\ 0')
{
SBUF=* STR;
while(! TI);//waiting to send complete signal appears (TI=1)
TI=0;
Str++;
}
}
  • Related