下面是WriteData()函数,其中WriteData()和DST_CRCStr()函数及SendData()函数都是我自定义的函数,我调试了,都是无误的程序!现在我遇到的问题是在主函数main()中,我想通过在主函数中实现从键盘输入5个数据,可是怎么老是写进去的不是我从键盘输入的数据!麻烦您帮我写个正确从键盘接收多个字节数据的程序吧!谢谢啦!
void WriteData(uchar *buff,uchar length)
{
uint BCC;
uchar i,send_command[15];
send_command[0]=0x35; //第13页的写指令
send_command[1]=0x0E; //第一页的内容
for(i=0;i<length;i++) //通过for循环将要写入13页的数据赋给send_command
{
send_command[i+2]=buff[i];
}
BCC=DST_CRCStr(send_command,length+2); //将所有send_command进行BCC校验
send_command[length+2]=BCC; //低8位赋给BCC
BCC>>=8;
send_command[length+3]=BCC; //高8位赋给BCC
TXCT=0; //下面为数据的发送格式
timer_ms_delay(50);
SendData(send_command,length+4); //发送数据
TXCT=0;
timer_ms_delay(15); //延时15毫秒
TXCT=1;
timer_ms_delay(15);
}
|