大家看一下我这个程序能正确读出返回值吗?
时间:10-02
整理:3721RD
点击:
#include<reg52.h>
#include "lcd.h"
#define uchar unsigned char
#define uint unsigned int
//可一次接收数据量
void rs232_init();
void disp();
void Sendata();
uchar flag,i,k,l;
uint num; //删除无用变量
uchar table[5]={0x11,0x02,0x01,0x00,0xEC};
uchar table1[14];
uchar table2[14];
uchar table3[6]; //接收缓存数组
uchar j=0; //接收计数器
void shujuchuli()
{
if(flag==1)
{
num=table2[5]*256+table2[6];
table3[0]=num/100000%10+'0';
table3[1]=num/10000%10+'0';
table3[2]=num/1000%10+'0';
table3[3]=num/100%10+'0';
table3[4]=num/10%10+'0';
table3[5]=num%10+'0';
j=0; //清零接收计数器
flag=0;
}
}
void UsartInit()
{
TMOD=0x20;
TH1=0xfa;
TL1=0xfa;
PCON=0x80;
TR1=1;
SCON=0x50;
EA=1;
ES=1;
}
void Sendata(uchar *table)
{
uchar i;
for(i=0;i<5;i++)
{
SBUF=(table[i]);
while(!TI);
TI = 0;
}
}
void Usart() interrupt 4
{
if(RI)
{
for(i=0;i<14;i++)
{
table2[i]=SBUF;//出去接收到的数据
RI = 0;//清除接收中断标志位
}
flag=1;
}
else
TI=0;
}
void main()
{
UsartInit();
while(1)
{
Sendata(table);
LcdInit();
shujuchuli();
LcdWriteData(0x43);
LcdWriteData(0x48);
LcdWriteData(0x32);
LcdWriteData(0x4f);
LcdWriteData(0x3a);
for(l=0;l<6;l++)
{
LcdWriteData(table3[l]);
}
LcdWriteData(0x6d);
LcdWriteData(0x67);
LcdWriteData(0x2f);
LcdWriteData(0x6d);
LcdWriteData(0x33);
Lcd1602_Delay1ms(300);
}
}
#include "lcd.h"
#define uchar unsigned char
#define uint unsigned int
//可一次接收数据量
void rs232_init();
void disp();
void Sendata();
uchar flag,i,k,l;
uint num; //删除无用变量
uchar table[5]={0x11,0x02,0x01,0x00,0xEC};
uchar table1[14];
uchar table2[14];
uchar table3[6]; //接收缓存数组
uchar j=0; //接收计数器
void shujuchuli()
{
if(flag==1)
{
num=table2[5]*256+table2[6];
table3[0]=num/100000%10+'0';
table3[1]=num/10000%10+'0';
table3[2]=num/1000%10+'0';
table3[3]=num/100%10+'0';
table3[4]=num/10%10+'0';
table3[5]=num%10+'0';
j=0; //清零接收计数器
flag=0;
}
}
void UsartInit()
{
TMOD=0x20;
TH1=0xfa;
TL1=0xfa;
PCON=0x80;
TR1=1;
SCON=0x50;
EA=1;
ES=1;
}
void Sendata(uchar *table)
{
uchar i;
for(i=0;i<5;i++)
{
SBUF=(table[i]);
while(!TI);
TI = 0;
}
}
void Usart() interrupt 4
{
if(RI)
{
for(i=0;i<14;i++)
{
table2[i]=SBUF;//出去接收到的数据
RI = 0;//清除接收中断标志位
}
flag=1;
}
else
TI=0;
}
void main()
{
UsartInit();
while(1)
{
Sendata(table);
LcdInit();
shujuchuli();
LcdWriteData(0x43);
LcdWriteData(0x48);
LcdWriteData(0x32);
LcdWriteData(0x4f);
LcdWriteData(0x3a);
for(l=0;l<6;l++)
{
LcdWriteData(table3[l]);
}
LcdWriteData(0x6d);
LcdWriteData(0x67);
LcdWriteData(0x2f);
LcdWriteData(0x6d);
LcdWriteData(0x33);
Lcd1602_Delay1ms(300);
}
}
跪求大佬帮忙哇
没人回我?我顶
还是没人吗,待会我再来问一遍,