现用ch376芯片接收cp2102-(usb转232芯片)发来的数据,有时候会出现接收误码,接收的长度是正确的,但是接收数据出现误码情况 我用串口调试打印情况如下
receive ok! count=6 data: 55 66 77 88 99 00 receive ok! count=6 data: 55 66 77 88 99 00 receive ok! count=6 data: 55 66 77 88 99 00 receive ok! count=6 data: 55 66 7f 7f 7f 7f receive ok! count=6 data: 55 66 77 88 99 00 receive ok! count=6 data: 55 66 7f 7f 7f 7f receive ok! count=6 data: 55 66 77 88 99 00 receive ok! count=6 data: 55 66 77 88 99 7f
正确的接收数据应该是55 66 77 88 99 00 但是ch376有时会接收到7f 这个数据,出现误码,麻烦帮忙分析下
unsigned char rd_usb_data( unsigned char *buf ) { /* 从CH37X读出数据块 */ unsigned char i, len; xWriteCH376Cmd(CMD_RD_USB_DATA0); len=xReadCH376Data(); /* 后续数据长度 */ for ( i=0; i!=len; i++ ) *buf++=xReadCH376Data(); return( len ); }
u8 xReadCH376Data( void ) /* 从CH376读数据 */ { mDelayuS(1); /* 确保读写周期大于0.6uS */ return( CH376_ReadWrite( 0xff) ); }
延时函数什么的都应该是准的,程序里面实测过的。 表示有点想不通会出现ch376接收误码,出现的几率还蛮大的,但是接收的长度都是正确的,表示无法理解