一个绝对另类的技术问题。(串口发送在p2,p3,p4的机器上一点问题没有,486dx33上就不行。)
houzy 2003-08-30 01:15:22
/*初始化*/
outportb(PORT1 + 1 , 0); /* Turn off interrupts - Port1 */
oldport1isr = getvect(INTVECT); /* Save old Interrupt Vector for */
/* later recovery */
setvect(INTVECT, PORT1INT); /* Set Interrupt Vector Entry */
/* COM1 - 0x0C */
/* COM2 - 0x0B */
/* COM3 - 0x0C */
/* COM4 - 0x0B */
/* PORT 1 - Communication Settings */
outportb(PORT1 + 3 , 0x80); /* SET DLAB ON */
outportb(PORT1 + 0 , 0x30); /* Set Baud rate - Divisor Latch Low Byte */
/* Default 0x03 = 38,400 BPS */
/* 0x01 = 115,200 BPS */
/* 0x02 = 56,700 BPS */
/* 0x06 = 19,200 BPS */
/* 0x0C = 9,600 BPS */
/* 0x18 = 4,800 BPS */
/* 0x30 = 2,400 BPS */
outportb(PORT1 + 1 , 0x00); /* Set Baud rate - Divisor Latch High Byte */
outportb(PORT1 + 3 , 0x1b); /* 8 Bits, No Parity, 1 Stop Bit */
outportb(PORT1 + 2 , 0xC7); /* FIFO Control Register Interfacing the Serial / RS232 Port V5.0 http://www.senet.com.au/~cpeacock*/
outportb(PORT1 + 4 , 0x0B); /* Turn on DTR, RTS, and OUT2 */
outportb(0x21,(inportb(0x21) & 0xEF)); /* Set Programmable Interrupt */
/* Controller */
/* COM1 (IRQ4) - 0xEF */
/* COM2 (IRQ3) - 0xF7 */
/* COM3 (IRQ4) - 0xEF */
/* COM4 (IRQ3) - 0xF7 */
outportb(PORT1 + 1 , 0x01); /* Interrupt when data received */
if(key1==F4) { /* F4 发送 */
i=1;
gettext(2,5,78,7,textSave); /* left,top,right,bottom */
/* copy the content to textSave */
s_data[0]=003; /*报头 */
for(bufferout=0;bufferout<strlen(textSave);bufferout+=2){
s_data[i]=textSave[bufferout];/* 正文从s_data[2]开始 */
i++;
}
s_data[i]=004; /*报尾 */
s_data[i+1]='\0';
gotoxy(2,18);
textcolor(YELLOW);textbackground(BLUE);
cputs(s_data);
gotoxy(CurX,CurY);
/*循环发送*/
for(bufferout=0;bufferout<strlen(s_data);bufferout++){
c=s_data[bufferout];
while(!(inportb(PORT1+5)&&0x20));/*发送就绪可 判断*/
outportb(PORT1, c);
}
/*清空接收显示区*/
clearreceived();
gotoxy(4,17);
textbackground(BLUE);textcolor(7);
cprintf("发送中....若长时间未收到发送成功信息,请重发!");/* 收不到发送成功报文后,报错 */
gotoxy(CurX,CurY);
continue;
}
以上为程序初始化和发送部分代码,在奔腾机以上运行决无问题。到了目标机486dx33上,接收没问题,就是每次循环发送字符串中的字符时,都只能发出第一个,太奇怪了,郁闷死了。我调试用的机器是p4 2.8G,难道是目标机cpu太慢的缘故???????/