完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
CH554使用进行u***串口透传,怎么操作FT232的USB转串口芯片,案例中只有CH34X,PL2303,CP210x。怎么添加FT232的支持?谢谢 了
如果在原例程上修改添加更好不过了。 |
|
相关推荐
4个回答
|
|
您好
开发特定USB设备的主机时,可以使用一些上位机软件抓取USB设备和上位机的通信,然后使用MCU模拟这个PC的通信过程。 在枚举获取描述符部分,FT232和其他设备一样,在设置波特率等方面可能不同。这边提供一段FT232波特率等配置的代码,按照这样的顺序发送SETUP包,就是配置FT232的过程,希望能有所帮助。 unsigned char Baud_buf1_5[8]={0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; unsigned char Baud_buf6[8]={0x02,0x01,0x00,0x00,0x81,0x00,0x00,0x00}; unsigned char Baud_buf7[8]={0x40,0x09,0x10,0x00,0x00,0x00,0x00,0x00}; unsigned char Baud_buf8[8]={0xc0,0x05,0x00,0x00,0x00,0x00,0x02,0x00}; //无 unsigned char Baud_buf9[8]={0x40,0x04,0x07,0x00,0x00,0x00,0x00,0x00}; //无 unsigned char Baud_buf10[8]={0x40,0x01,0x01,0x01,0x00,0x00,0x00,0x00}; unsigned char Baud_buf11[8]={0x40,0x01,0x02,0x02,0x00,0x00,0x00,0x00}; unsigned char Baud_buf12[8]={0x40,0x02,0x00,0x00,0x00,0x00,0x00,0x00}; //无 //unsigned char Baud_buf13[8]={0x40,0x03,0xc4,0x09,0x00,0x00,0x00,0x00}; unsigned char Baud_buf14[8]={0x40,0x03,0xc4,0x09,0x00,0x00,0x00,0x00}; //特特率 unsigned char Baud_buf15[8]={0x40,0x01,0x02,0x02,0x00,0x00,0x00,0x00}; //无 unsigned char Baud_buf16[8]={0x40,0x01,0x01,0x01,0x00,0x00,0x00,0x00}; //无 unsigned char Baud_buf17[8]={0x40,0x04,0x07,0x02,0x00,0x00,0x00,0x00}; //设置数据位、停止位、校验位等 unsigned char Baud_buf18[8]={0x40,0x02,0x00,0x00,0x00,0x00,0x00,0x00}; //流控设置 unsigned char Baud_buf19[8]={0x40,0x06,0x00,0x00,0x00,0x00,0x00,0x00}; //配置FT232R波特率 void FT232R_Baud_Config( UINT32 baud ) { unsigned char s=0,ix; unsigned short int len; FT232R_Baud_Set(Baud_buf1_5); FT232R_Baud_Set(Baud_buf1_5); FT232R_Baud_Set(Baud_buf6); FT232R_Baud_Set(Baud_buf7); FT232R_Baud_Set(Baud_buf8); FT232R_Baud_Set(Baud_buf10); FT232R_Baud_Set(Baud_buf11); FT232R_Baud_Set(Baud_buf12); baud = 10*3000000/baud; //分频 baud = (baud+5)/10; //做四舍五入 Baud_buf14[2]=baud&0xff; Baud_buf14[3]=(baud>>8)&0xff; Baud_buf14[4]=(baud>>16)&0xff; FT232R_Baud_Set(Baud_buf14);//这一次的波特率 FT232R_Baud_Set(Baud_buf17); FT232R_Baud_Set(Baud_buf18); FT232R_Baud_Set(Baud_buf19); } |
|
|
|
你好,根据你提供的数组,我添加到CH554_uart2uart的工程,当前实现了FT232插入时检测设备,并且能接收一段我开发板发送的字符,但是当开发板已经发送结束了,CH554还是一直接收到FT232发送的东西,并且串口打印是乱码的。
下面是工程中我添加的FT232设置波特率部分函数 UINT8 FT232_Baud_Config(UINT32 baud) { UINT8 s; UINT16 tmp; TxBuffer[0] = 0x40; TxBuffer[1] = 0x00; TxBuffer[2] = 0x00; TxBuffer[3] = 0x00; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0x40; TxBuffer[1] = 0x00; TxBuffer[2] = 0x00; TxBuffer[3] = 0x00; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0x02; TxBuffer[1] = 0x01; TxBuffer[2] = 0x00; TxBuffer[3] = 0x00; TxBuffer[4] = 0x81; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0x40; TxBuffer[1] = 0x09; TxBuffer[2] = 0x10; TxBuffer[3] = 0x00; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0xc0; TxBuffer[1] = 0x05; TxBuffer[2] = 0x00; TxBuffer[3] = 0x00; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x02; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0x40; TxBuffer[1] = 0x01; TxBuffer[2] = 0x01; TxBuffer[3] = 0x01; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0x40; TxBuffer[1] = 0x01; TxBuffer[2] = 0x02; TxBuffer[3] = 0x02; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0x40; TxBuffer[1] = 0x02; TxBuffer[2] = 0x00; TxBuffer[3] = 0x00; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); tmp=(10*3000000/baud); tmp = (tmp+5)/10; TxBuffer[0] = 0x40; TxBuffer[1] = 0x03; TxBuffer[2] = (UINT8)(tmp&0Xff); TxBuffer[3] = (UINT8)((tmp>>8)&0xff); TxBuffer[4] = (UINT8)((tmp>>16)&0xff); TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0x40; TxBuffer[1] = 0x04; TxBuffer[2] = 0x07; TxBuffer[3] = 0x02; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0x40; TxBuffer[1] = 0x02; TxBuffer[2] = 0x00; TxBuffer[3] = 0x00; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); TxBuffer[0] = 0x40; TxBuffer[1] = 0x06; TxBuffer[2] = 0x00; TxBuffer[3] = 0x00; TxBuffer[4] = 0x00; TxBuffer[5] = 0x00; TxBuffer[6] = 0x00; TxBuffer[7] = 0x00; s = HostCtrlTransfer( NULL, NULL ); return s; } 下面是用SSCOM串口工具打印的乱码信息: 求助,当前该如何修改程序?问题是出在哪里呢? |
|
|
|
|
|
|
|
您好,我尝试着过滤数据包中的0x01和0x60,但是这样做会导致我数据包丢包,是否有可能对FT232进行设置,不要一直发送0x01和0x60这两个字符?
|
|
|
|
只有小组成员才能发言,加入小组>>
522 浏览 1 评论
CH579M+RT-Thread,RTC从Sleep模式唤醒失败是什么原因?
2904 浏览 2 评论
2400 浏览 1 评论
870浏览 2评论
689浏览 1评论
riscv-none-embed-objcopy: \'PWM_Output.elf\': No such file这个咋解决,
418浏览 1评论
531浏览 1评论
请教一下,Mounriver 编译不成功:找不到库文件,怎么整
814浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 20:43 , Processed in 1.080271 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号