UploadImages/WCH20061017162851.rar
文件在這里,一般寫2K后就比較容易出現(xiàn),用的U盤是清華紫光的。
UploadImages/WCH20061017162851.rar
文件在這里,一般寫2K后就比較容易出現(xiàn),用的U盤是清華紫光的。
說一下,USB電壓為4.9V。測(cè)試的時(shí)候也用過延時(shí),沒有效果!請(qǐng)馮工等幫忙看看。
這個(gè)writeFileByte()函數(shù)可以看下嗎?
unsigned char writeFileByte(char * buf, uchar writeBytes, uchar * retBytes) { unsigned char xdata ret, i, j;
i = 0; do { j = (writeBytes - i > MAX_BYTE_IO) ? MAX_BYTE_IO : (writeBytes - i); //每次能寫入的最大字節(jié)數(shù)
mCmdParam.ByteWrite.mByteCount = j; memcpy(mCmdParam.ByteWrite.mByteBuffer, buf + i, j); ret = CH375ByteWrite();
if (ERR_SUCCESS != ret) break;
i += j; // 指向當(dāng)前待寫入的位置 } while (i < writeBytes);
*retBytes = i;
return ret; }
unsigned char modifyFileDate(void) { mCmdParam.Modify.mFileDate = MAKE_FILE_DATE((uint)now_time.year, now_time.month, now_time.day); mCmdParam.Modify.mFileTime = MAKE_FILE_TIME(now_time.hour, now_time.minute, now_time.second); mCmdParam.Modify.mFileSize = 0xffffffff; /* 不修改文件長(zhǎng)度 */ mCmdParam.Modify.mFileAttr = 0xff; /* 不修改文件屬性 */
return CH375FileModify(); }
unsigned char readFileByte(char * buf, UINT8 readBytes, UINT8 * retBytes) { unsigned char xdata ret, i, j;
i = 0; do { j = (readBytes - i > MAX_BYTE_IO) ? MAX_BYTE_IO : (readBytes - i); // 每次能讀出的最大字節(jié)數(shù)
mCmdParam.ByteRead.mByteCount = j; ret = CH375ByteRead();
if (ERR_SUCCESS != ret) break;
memcpy(buf + i, mCmdParam.ByteRead.mByteBuffer, mCmdParam.ByteRead.mByteCount); i += mCmdParam.ByteRead.mByteCount; //指向當(dāng)前待讀取的位置
if (j > mCmdParam.ByteRead.mByteCount) // 已讀到文件的結(jié)尾 break;
} while (i < readBytes);
buf[i] = '\0'; *retBytes = i;
return ret; }
原來是數(shù)據(jù)的長(zhǎng)度超過了30字節(jié)。