我在使用普中提供的sscom32软件进行串口通信的时软件会报错:WriteFile function failed (win error code: 6). 我也是刚入门不久请哪位大神指点一下该怎么改这个错误啊。不胜感谢!
我的代码是这样的:
sbit led=P2^0;
typedef unsigned int u16;
typedef unsigned char u8;
//Bausrate=4800
void UsartInit(){
TMOD|=0x20;//we use T1
TH1=0xF3;// since we are using mode 2 reloadable timer
TL1=0xF3;
PCON=0x80;
TR1=1;
SCON=0x50; //0b01010000
ES=1;
EA=1;
}
void main(){
UsartInit();
while(1);
}
//Usart commnication mode
void Usart() interrupt 4{
u8 receiveData;
receiveData=SBUF;
RI=0;//clear since theb hardware wil have the RI=1 automaticly
SBUF=receiveData;//ssend the data back
while(!TI);//to check if the transmission finished
TI=0;
}