ch374 初始化0x81错误

你好,请问一下,ch374 初始化0x81错误,用以下程序测试的时候,发现得出下面结果,请问对不对 测试用程序:

printf("Read 0x04 Register is %02x.\n",CH374_READ_REGISTER(0x04)); delay_nms( 100 ); CH374_WRITE_REGISTER(0x40,0x48); delay_nms( 100 ); CH374_WRITE_REGISTER(0x41,0x49); delay_nms( 100 ); CH374_WRITE_REGISTER(0x42,0x50); delay_nms( 100 ); CH374_WRITE_REGISTER(0x43,0x51); delay_nms( 100 ); printf("Read 0x05 Register is %02x.\n",CH374_READ_REGISTER(0x05)); delay_nms( 100 ); printf("Read 0x06 Register is %02x.\n",CH374_READ_REGISTER(0x06)); delay_nms( 100 ); printf("Read 0x07 Register is %02x.\n",CH374_READ_REGISTER(0x07)); delay_nms( 100 ); printf("Read 0x08 Register is %02x.\n",CH374_READ_REGISTER(0x08)); delay_nms( 100 ); printf("\n"); printf("Read 0x40 Register is %02x.\n",CH374_READ_REGISTER(0x40)); delay_nms( 100 ); printf("Read 0x41 Register is %02x.\n",CH374_READ_REGISTER(0x41)); delay_nms( 100 ); printf("Read 0x42 Register is %02x.\n",CH374_READ_REGISTER(0x42)); delay_nms( 100 ); printf("Read 0x43 Register is %02x.\n",CH374_READ_REGISTER(0x43));

测试结果:

Start Read 0x04 Register is 59fa. Read 0x05 Register is fa. Read 0x06 Register is fa. Read 0x07 Register is f0fa. Read 0x08 Register is fa.

Read 0x40 Register is 48fa. Read 0x41 Register is 49fa. Read 0x42 Register is 50fa. Read 0x43 Register is 51fa. Error: 81

读取的数据肯定不正确,请检查下单片机和我们芯片的硬件连线以及芯片是否正常工作


可是我在应用EXAM\HOST \host.c的时候 能够响应以下东西,请问,对不对。如果对的话能不能说明硬件没有问题?

Reset Device Start Full-Speed Device GetDeviceDescr: 12 01 10 01 00 00 00 40 04 02 25 60 00 01 01 02 03 01 SetUsbAddress: GetConfigDescr: 09 02 20 00 01 01 00 80 32 09 04 00 00 02 08 06 50 00 07 05 01 02 40 00 01 07 05 81 02 40 00 00 SetUsbConfig: USB device ready now do something, read / write ...... Wait Device Out


那肯定你软件移植上面出了问题,或者你的I/O定义上面出了问题。建议你去仔细查下你的硬件以及移植的软件有什么区别。


但是还有一点问题,在在应用EXAM\HOST \host.c的时候加入 printf("Read 0x04 Register is %02x.\n",CH374_READ_REGISTER(0x04)); delay_nms( 100 ); CH374_WRITE_REGISTER(0x40,0x48); delay_nms( 100 ); CH374_WRITE_REGISTER(0x41,0x49); delay_nms( 100 ); CH374_WRITE_REGISTER(0x42,0x50); delay_nms( 100 ); CH374_WRITE_REGISTER(0x43,0x51); delay_nms( 100 ); printf("Read 0x05 Register is %02x.\n",CH374_READ_REGISTER(0x05)); delay_nms( 100 ); printf("Read 0x06 Register is %02x.\n",CH374_READ_REGISTER(0x06)); delay_nms( 100 ); printf("Read 0x07 Register is %02x.\n",CH374_READ_REGISTER(0x07)); delay_nms( 100 ); printf("Read 0x08 Register is %02x.\n",CH374_READ_REGISTER(0x08)); delay_nms( 100 ); printf("\n"); printf("Read 0x40 Register is %02x.\n",CH374_READ_REGISTER(0x40)); delay_nms( 100 ); printf("Read 0x41 Register is %02x.\n",CH374_READ_REGISTER(0x41)); delay_nms( 100 ); printf("Read 0x42 Register is %02x.\n",CH374_READ_REGISTER(0x42)); delay_nms( 100 ); printf("Read 0x43 Register is %02x.\n",CH374_READ_REGISTER(0x43));

得出如下结果


Start CH374 Host Read 0x04 Register is c900. Read 0x05 Register is 4000. Read 0x06 Register is 5000. Read 0x07 Register is 300. Read 0x08 Register is 00.

Read 0x40 Register is 4800. Read 0x41 Register is 4900. Read 0x42 Register is 5000. Read 0x43 Register is 5100.

Reset Device Start Full-Speed Device GetDeviceDescr: 12 01 10 01 00 00 00 40 04 02 25 60 00 01 01 02 03 01 SetUsbAddress: GetConfigDescr: 09 02 20 00 01 01 00 80 32 09 04 00 00 02 08 06 50 00 07 05 01 02 40 00 01 07 05 81 02 40 00 00 SetUsbConfig: USB device ready now do something, read / write ...... Wait Device Out


还有就是我在仿真状态下能够进入Wait Udisk,然后不管拔插U盘都无响应,在插入U盘时中断引脚为低电平,但是就是不响应


1、用printf输出一个8位数据,格式有误,应为:printf( "%02x\n", ( unsinged short )dat ); 2、按读写寄存器的结果,与374的通讯是正常的 3、0x81是CH374LibInit返回的吧?换一个板子试试呢 4、检测不到U盘插拔,检查一下中断线定义


....汗,看起来想是我的测试程序,我用的没问题,0x81肯定是读写时序不对,或是速度快了,或是虚焊,别的就没了


谢谢大家关心,找到问题了,确实是硬件以及移植的软件有区别的,修改就好了 不过现在出现新的问题的,就是在仿真状态下能过建立文件,但是烧些进芯片就是0x81错误,郁闷 我用的芯片是SST89E516RD


仍然是这种问题,还需要你自己查找,我们只能给您提供一个解决问题的方向


仿真和硬件的区别在于延时以及RAM的分配不一样,还需要你去查下这2个方面就可以了。


问题以解决,复位的时候时序有点问题,现在在仿真和烧写后都可以识别U盘了,能够创建文件 但又出现了新问题,对文件的读写不正确,能够创建文件。


你是按照扇区方式读写U盘还是字节的方式?建议你先去按照字节方式读写U盘,还有你说读写不正确是读取到的数据内容不正确还是其他方面不正确,请详细说明。


我是的51单片机只有768个外部RAM,所以只能用字节的方式读写。 我更改my_buffer的时候得出不同结果(当CH374HFT.C里面数据为abcdefg) UINT8X my_buffer[ 4]; /* 外部RAM的文件数据缓冲区 */ Start Wait Udisk Ready? Open Read Size=7,Len=4,Sec=0 Close line 1: Create Write Modify Close Take out

当UINT8X my_buffer[ 10];的时候 Start Wait Udisk Ready? Open Read Size=7,Len=47,Sec=1 就不动了


我们的数据是存在一个结构体变量里面的,调用字节读写数据应该是在这个里面:mCmdParam.ByteRead.mByteBuffer


只有登录才能回复,可以选择微信账号登录