UINT8 i; //mCopyCodeStringToIRAM( mCmdParam.Open.mPathName, "/MY_ADC.TXT" ); strcpy( (char *)mCmdParam.Open.mPathName, "/MY_ADC.TXT" ); i =CH375FileOpen( ); if ( i == ERR_SUCCESS ) { mCmdParam.ByteLocate.mByteOffset = 0xffffffff; // 移到文件的尾部 CH375ByteLocate( ); mStopIfError( i ); } else if ( i == ERR_MISS_FILE ) { // mCopyCodeStringToIRAM( mCmdParam.Create.mPathName, "/MY_ADC.TXT" ); strcpy( (char *)mCmdParam.Create.mPathName, "/MY_ADC.TXT" ); i = CH375FileCreate( ); /* 新建文件并打开,如果文件已经存在则先删除后再新建 */ mStopIfError( i ); } WriteToReg_ADC(0X38); pstr=Read_ADC16BitValue(); //usart_transmit(pstr); b=pstr&0x0FF; usart_transmit(b); a=pstr>>8; usart_transmit(a); //mCmdParam.ByteWrite.mByteBuffer[0]=b; //mCmdParam.ByteWrite.mByteBuffer[1]=a; //for(i=0;i<2;i++) //{ mCmdParam.ByteWrite.mByteBuffer[h]=b; mCmdParam.ByteWrite.mByteBuffer[h+1]=a; //} h+=2; if(h==30) { mCmdParam.ByteWrite.mByteCount = 28; /* 写入数据的字符数,单次读写的长度不能超过MAX_BYTE_IO,第二次调用时接着刚才的向后写 */ i = CH375ByteWrite( ); /* 向文件写入数据 */ mStopIfError( i ); h=0; }
我用的是字节读写模式,读来的16位的数据高八位给a,低八位给b,然后存入mCmdParam.ByteWrite.mByteBuffer中,如果满28字节则写盘,但是我读的数据不对,请看这程序对吗?