用以下程序?qū)懳募绻麑懙淖止?jié)比較多,寫不進(jìn)去,咋回事兒??(好像是寫100字節(jié)好使,再多了就不大行了),我這程序應(yīng)該沒問題吧
ulong addr=0; uchar yehao=1; uchar zongyesu=0; uchar zuihouyeduansu=0;
zongyesu = (uchar)((suzi-1)/256) + 1; zuihouyeduansu = suzi % 256;
//寫文件 while(XieWenJian(((uchar far*)&temp), 6)) //如果沒成功,一直寫 { printf("寫開始6字節(jié)沒成功\n\r"); } // XieWenJian(((uchar far*)&temp), 6); addr = GYRAM; while( yehao < zongyesu ) { // XieWenJian((uchar far*)addr, 256*5); while(XieWenJian((uchar far*)addr, 256*5)) { printf("寫yehao = %bu段未成功\n\r", yehao); } addr += 256*5; yehao++; } // XieWenJian((uchar far*)addr, zuihouyeduansu*5); while(XieWenJian((uchar far*)addr, zuihouyeduansu*5)) { printf("寫最后頁未成功\n\r"); } addr = GYRAM + suzi*5L; XieWenJian((uchar far*)addr, 0); //更新文件長度
//----------------------------------------------------------------------------- // 寫入文件數(shù)據(jù) // 成功返回0 uchar XieWenJian(uchar far* ucBuf, uint uiZiJieSu) { UINT16 ui = 0; EA = 0; CH376ByteWrite( ucBuf, uiZiJieSu, &ui ); //有些U盤可能會(huì)要求在寫數(shù)據(jù)后等待一會(huì)才能繼續(xù)操作,所以,如果在某些U盤中發(fā)生數(shù)據(jù)丟失現(xiàn)象,建議在每次寫入數(shù)據(jù)后稍作延時(shí)再繼續(xù) EA = 1; mDelaymS( 1 );
if (uiZiJieSu == ui) { return 0; } else { return 1; } }
//-----------------------------------------------------------------------------