void SendData_Usart_2(BYTE dat)
{
while (busy); //Wait for the completion of the previous data is sent
ACC = dat; //Calculate the even parity bit P (PSW.0)
if (P) //Set the parity bit according to P
{
#if (PARITYBIT == ODD_PARITY)
S2CON &= ~S2TB8; //Set parity bit to 0
#elif (PARITYBIT == EVEN_PARITY)
S2CON |= S2TB8; //Set parity bit to 1
#endif
}
else
{
#if (PARITYBIT == ODD_PARITY)
S2CON |= S2TB8; //Set parity bit to 1
#elif (PARITYBIT == EVEN_PARITY)
S2CON &= ~S2TB8; //Set parity bit to 0
#endif
}
busy = 1;
S2BUF = ACC; //Send data to UART2 buffer
}
void SendData_Usart_1(BYTE dat)
{
ES = 0; //1رÕ′®¿úÖD¶Ï
SBUF = dat;
while(!TI);
TI = 0;
ES = 1; //ÔêDí′®¿úÖD¶Ï
}
void SendString_Usart_1(unsigned char *s)
{
while (*s!='\0') //Check the end of the string
{
SendData_Usart_1(*s++); //Send current char and increment string ptr
}
}
void SendString_Usart_2(unsigned char *s)
{
while (*s) //Check the end of the string
{
SendData_Usart_2(*s++); //Send current char and increment string ptr
Delay_Us(5);
}