//发送一个char
void SendData_1(unsigned char dat)
{
SBUF = dat; //Send current data
while(!TI); //Wait for the previous data is sent 等待前一个转换结束
TI = 0; //Clear TI flag,清除TI标志位
}
//发送一个字符串
void SendString_1(unsigned char *s)
{
RS_1 = 1; //使能发送
Delay_us(1000);
while(*s) //Check the end of the string
{
SendData_1(*s++); //Send current char and increment string ptr
}
RS_1 = 0; //发送完毕置位使能接收
Delay_us(1000);
}
void SendData_1(unsigned char dat)
{
SBUF = dat; //Send current data
while(!TI); //Wait for the previous data is sent 等待前一个转换结束
TI = 0; //Clear TI flag,清除TI标志位
}
//发送一个字符串
void SendString_1(unsigned char *s)
{
RS_1 = 1; //使能发送
Delay_us(1000);
while(*s) //Check the end of the string
{
SendData_1(*s++); //Send current char and increment string ptr
}
RS_1 = 0; //发送完毕置位使能接收
Delay_us(1000);
}
----------------------这样100% 没问题,你那样用的话,RW切换太频繁,反应不过来的!尤其是使能发送后需要一个比较长的延时,自己试试多少合适吧。
一周热门 更多>