串口通讯前几个字节丢失的问题
/*interrupt sevice*/
void interrupt far asyncint()
{
InBuffer[buffin++]= inportb(BaseAddCOM4);
if(buffin>=INBUFFNUM)
buffin = 0;
outportb(0x20,0x20);
}
/*Read char from buffer*/
unsigned char read_char(void)
{
unsigned unch;
if(buffout!=buffin)
{
unch = InBuffer[buffout];
buffout++;
if(buffout>=OUTBUFFNUM)
buffout = 0;
return(unch);
}
}
main()
{
/*前略,就开了接收中断*/
for(i=0;i<7;i++)
{
ucChar[i] = read_char();
ucChar1[i]=~ucChar[i];
printf("%x ",ucChar[i]);
}
}
下位机发回来7字节数据,而我只能接收到后面3-4个字节得数,请指点!