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( ); /* 新建文件并打開,如果文件已經(jīng)存在則先刪除后再新建 */ 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; /* 寫入數(shù)據(jù)的字符數(shù),單次讀寫的長度不能超過MAX_BYTE_IO,第二次調(diào)用時接著剛才的向后寫 */ i = CH375ByteWrite( ); /* 向文件寫入數(shù)據(jù) */ mStopIfError( i ); h=0; }
我用的是字節(jié)讀寫模式,讀來的16位的數(shù)據(jù)高八位給a,低八位給b,然后存入mCmdParam.ByteWrite.mByteBuffer中,如果滿28字節(jié)則寫盤,但是我讀的數(shù)據(jù)不對,請看這程序?qū)幔?/p>