#包含
#include 'main.h '
#include 'intrins.h '
//T2计时器2用于控制串行端口1的波特率
#define FOSC 18432000L //系统频率
#定义蓝牙9600//串行端口1波特率
#定义tm2 (65536-) fosc/4/Baud ) )
#define NONE_PARITY 0 //无检查
#define ODD_PARITY 1 //奇检查
#define EVEN_PARITY 2 //偶数检查
#define MARSK_PARITY 3 //标记检查
#define SPACE_PARITY 4 //空白检查
#定义奇偶校验位none _ parity//定义奇偶校验位
比特总线1=0;
字节c _ data;
BYTE s_data;
voiduart1_sendstring(char*s );
void UART1_ send data (字节数据;
语音主(语音) )。
{
SCON=0x50; //8位可变波特率
T2L=TM2;
T2H=TM28;
AUXR=AUXR_T2R;
AUXR |=AUXR_T2x12
AUXR |=AUXR_S1ST2; //使用计时器2作为串行端口1的波特率发生器
ES=1;
EA=1;
UART1_ send string (rn ST c15 f2k 08 suart1testrn );
wile(1;
}
/* * * * * * * * * * * * * * *
串行1 APP应用程序
* * * * * * * * * * * * * * *
/*UART1中断服务程序*
void UART1_ ISR (中断4 using1)
{
uchar r_data;
是if (射频)
{
RI=0;
r_data=SBUF;
c_data=RB8;
URT1_senddata(r_data;
}
是if(ti )
{
TI=0; 清除//ti位
总线1=0; //清除忙碌的标记
}
}
void UART1_ send data (字节数据) )。
{
while(busy1; //等待上一个数据的发送完成
ACC=dat; //获取奇偶校验位
是if(p )
{
#if(paritybit==odd_parity () ) ) ) ) ) ) ) ) ) 65
{
TB8=0; //使奇偶校验位为0
}
#Elif(paritybit==Even_Parity () ) ) ) ) ) ) ) ) 652
{
TB8=1; //将奇偶校验位设为1
}
#endif
}
else
{
#if(paritybit==odd_parity () ) ) ) ) ) ) ) ) ) 65
{
TB8=1; //将奇偶校验位设为1
}
#Elif(paritybit==Even_Parity () ) ) ) ) ) ) ) ) 652
{
TB8=0; //使奇偶校验位为0
}
#endif
}
busy1=1;
SBUF=ACC; 在UART数据寄存器中写入数据
}
void UART1_ send字符串(char * s ) )。
{
while(s )//检测字符串结束标志
{
URT1_senddata(*s; //发送当前文字
}
}