单片机如何发送多字节数据
#include<reg51.h>unsignedintaddr,a;unsignedlongintkey;voidsend(){SBUF=key;while(TI==0...
#include<reg51.h>
unsigned int addr,a;
unsigned long int key;
void send()
{
SBUF=key;
while(TI==0);
TI==0;
}
void main(void)
{
for (a=0; a<16; a++)
{
addr=0x00;
key=0x0000;
P1=addr;
addr=addr+0x11;
if(P3^4==1)
{
key=key|(1<<a);
}
if(P3^5==1)
{
key=key|(1<<(a+16));
}
}
TMOD=0X20;
SCON=0X50;
TH1=0Xfc;
TL1=0Xfc;
PCON=0X00;
TR1=1;
send();
}
这里KEY是32位的
要把KEY都发出去 void send()怎么写 展开
unsigned int addr,a;
unsigned long int key;
void send()
{
SBUF=key;
while(TI==0);
TI==0;
}
void main(void)
{
for (a=0; a<16; a++)
{
addr=0x00;
key=0x0000;
P1=addr;
addr=addr+0x11;
if(P3^4==1)
{
key=key|(1<<a);
}
if(P3^5==1)
{
key=key|(1<<(a+16));
}
}
TMOD=0X20;
SCON=0X50;
TH1=0Xfc;
TL1=0Xfc;
PCON=0X00;
TR1=1;
send();
}
这里KEY是32位的
要把KEY都发出去 void send()怎么写 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |