[mw_shl_code=c,true]void main(void)
{unchar buf[10];
P4SW=0x70;
AUXR = 0x8E;
AUXR = AUXR|0x40; // T1, 1T Mode
// EA=0;
//ES=0;
UART_init(); //???????®??
orderflag=0;
LCD_Init();
LCD_Clear();//????
LCD_Write_Char(1,0,'k');
//LCD_Write_String(1,1,"www.doflye.net");
do
{ delay();
delay();
delay();
delay();
delay();
if(Key1==0) //????°??ü°??????÷?ú?????????ú?¨??
{
unchar point;
delay();
delay();
delay();
delay();
delay();
delay();
while(!Key1);
delay();
delay();
delay();
delay();
//for(point=0;point<1;point++)
send_COM();
Key1=1;
name.buf[0]=Dis_Data_buffer[3];
name.buf[1]=Dis_Data_buffer[4];
name.buf[2]=Dis_Data_buffer[5];
name.buf[3]=Dis_Data_buffer[6];
sprintf(buf,"%x",Dis_Data_buffer[2]);
// sprintf(buf,"%.2f",name.f);
LCD_Write_String(0,1,buf);
}
}
while(1);
EA=0;
ES=0;
}
//es??????±????á?°?ì??·???????×???·??? ???????±???á?°?ì ????????????±????±????????·????ò????????????
//--------------------------------------------------------------------------------------------------
// ?????????? serial()?®?????????????í????
// ?????????? ?????®??????????????????
//--------------------------------------------------------------------------------------------------
void SerialInt(void) interrupt 4
{ //L0=0;
//unchar FIFO;
ES=0;
if(RI) //???í????????
{
RI=0; //????????±ê????
//FIFO=SBUF; //?????®??????
L7=0;
overflag=1;
for(n=0;n<17;n++)
{//Dis_Data_buffer[17]=0;
Dis_Data_buffer[n] = SBUF; }//??????????×?·??®??????????
if(Dis_Data_buffer[0]==0x01) LCD_Write_Char(8,0,'6'); //?????????ò?ó????
/*if(n>18) //?????????ú,?????????????ò???????×???·
{
n = 0;
orderflag=0;
overflag=1;
} */
}
else TI=0;
ES = 1;
}[/mw_shl_code]
我的目的是发送命令到仪表,然后从仪表接收返回来的数据,可是只收到3个字节就没了,之前我用51单片机试过可以实现,但是换成stc5a60s2,串口接收返回的数据不全,希望大家帮帮我,怎么回事 |