|
|
SendString("STC15F2K60S2\r\nUart2 Test !\r\n");這個沒問題,是字符串。
怎么發(fā)送SendString(74)SendString(A1) ,這種十六進(jìn)制數(shù)據(jù)?
這個dat的類型改成啥?忘記了。。
void SendData(BYTE dat)
{
while (busy); //等待前面的數(shù)據(jù)發(fā)送完成
ACC = dat; //獲取校驗位P (PSW.0)
if (P) //根據(jù)P來設(shè)置校驗位
{
#if (PARITYBIT == ODD_PARITY)
S2CON &= ~S2TB8; //設(shè)置校驗位為0
#elif (PARITYBIT == EVEN_PARITY)
S2CON |= S2TB8; //設(shè)置校驗位為1
#endif
}
else
{
#if (PARITYBIT == ODD_PARITY)
S2CON |= S2TB8; //設(shè)置校驗位為1
#elif (PARITYBIT == EVEN_PARITY)
S2CON &= ~S2TB8; //設(shè)置校驗位為0
#endif
}
busy = 1;
S2BUF = ACC; //寫數(shù)據(jù)到UART2數(shù)據(jù)寄存器
}
|
|