375b做文件復(fù)制問題

我用375B做文件復(fù)制.將一個(gè)U盤中的文件復(fù)制到另一個(gè)目錄中,硬件是S3C44B0X RAM是8M 使用了SaveVariable來保存和恢復(fù)變量,但我在使用中如果將變量備份緩沖區(qū)定義大于80字節(jié)時(shí).輸出!!!ENTER ABRET 如果定義成80字節(jié)的話能復(fù)制但只能復(fù)制第一次讀取的扇區(qū)數(shù)的內(nèi)容第二次讀取的內(nèi)容就變成為亂碼了.也就是說SaveVariable變量的保存和恢復(fù)沒有成功.我用的庫是CH375HFM庫同時(shí)貼上我的代碼 unsigned char mFile0Info[ 80 ]; unsigned char mFile1Info[ 80 ]; int usbtest(void) { UINT16 CH375vSectorSize; UINT8 i, c, SecCount,mReadOver; UINT8 td; UINT16 mFileSize; UINT32 NewSize, count; /* 因?yàn)镽AM容量有限,所以NewSize限制為16位,實(shí)際上如果文件較大,應(yīng)該分幾次讀寫并且將NewSize改為UINT32以便累計(jì) */ UINT8 *pCodeStr; CH375vSectorSize=512; uart_printf("Usb for S3C44B0x\n"); uart_printf("Serial Baud rate is %d\n", SERIAL_BAUD); uart_printf(table_begin); uart_printf("System Initialized.\n"); mDelaymS( 50 ); /* 延時(shí)100毫秒 */ uart_printf( "CH375 IS TEST \n" ); CH375Reset( ); // mDelaymS(50 ); /* 延時(shí)50ms */ xWriteCH375Cmd( 0x06 ); //發(fā)送測試命令 xWriteCH375Data( 0x55 ); td=xReadCH375Data( ); //返回?cái)?shù)據(jù) uart_printf("Scode1 %xh\n", td); xWriteCH375Cmd( 0x06 ); //發(fā)送測試命令 xWriteCH375Data( 0xaa );//發(fā)送測試碼 td=xReadCH375Data( ); //返回?cái)?shù)據(jù) uart_printf("Scode2 %xh\n", td); i = CH375LibInit( ); /* 初始化CH375程序庫和CH375芯片,操作成功返回0 */ mStopIfError( i ); /* 其它電路初始化 */ CH375_PORT_INIT( ); uart_printf("\nCH375_Init over !!"); while ( 1 ) { uart_printf( "\ninput U disk!\n" ); while ( CH375DiskStatus != DISK_CONNECT ) /* 查詢CH375中斷并更新中斷狀態(tài),等待U盤插入 */ mDelaymS( 10 );

/* 檢查U盤是否準(zhǔn)備好,有些U盤不需要這一步,但是某些U盤必須要執(zhí)行這一步才能工作 */ for ( i = 0; i < 10; i ++ ) { /* 有的U盤總是返回未準(zhǔn)備好,不過可以被忽略 */ uart_printf( "Ready ?\n" ); if ( CH375DiskReady( ) == ERR_SUCCESS ) break; /* 查詢磁盤是否準(zhǔn)備好 */ } /* 查詢磁盤物理容量 */ uart_printf( "DiskSize\n" ); i = CH375DiskSize( ); mStopIfError( i ); uart_printf( "TotalSize = %d MB \n", (unsigned int)( mCmdParam.DiskSize.mDiskSizeSec >> 11 ) );

/* 讀取原文件 */ uart_printf( "Open source file\n" ); /* 打開源文件 */ //mCopyCodeStringToIRAM( mCmdParam.Open.mPathName, "\\TEST.C" ); strcpy( (char *)mCmdParam.Open.mPathName, "\\C51\\CH375HFT.C" ); i = CH375FileOpen( ); /* 打開文件 */ mStopIfError( i ); mFileSize = CH375vFileSize; mCmdParam.SaveVariable.mSaveVariable = 0x01; mCmdParam.SaveVariable.mBuffer = &mFile0Info[ 0 ]; CH375SaveVariable( ); /* 保存源文件信息 */ uart_printf( "Create destination file\n" ); /* 創(chuàng)建目標(biāo)文件 */ //mCopyCodeStringToIRAM( mCmdParam.Create.mPathName, "\\TESTSAVE.C" ); strcpy( (char *)mCmdParam.Open.mPathName, "\\C51\\TESTSAVE.C" ); i = CH375FileCreate( ); mStopIfError( i ); mCmdParam.SaveVariable.mSaveVariable = 0x01; mCmdParam.SaveVariable.mBuffer = &mFile1Info[ 0 ]; CH375SaveVariable( ); /* 保存目標(biāo)文件信息 */

mReadOver = 0; while( 1 ) { uart_printf("============================\n"); // uart_printf("restore source file info\n"); mCmdParam.SaveVariable.mSaveVariable = 0x00; mCmdParam.SaveVariable.mBuffer = &mFile0Info[ 0 ]; CH375SaveVariable( ); /* 恢復(fù)源文件信息 */ // uart_printf("read\n"); CH375vFileSize += CH375vSectorSize - 1; /* 默認(rèn)情況下,以扇區(qū)方式讀取數(shù)據(jù)時(shí),無法讀出文件尾部不足1個(gè)扇區(qū)的部分,所以必須臨時(shí)加大文件長度以讀取尾部零頭 */ mCmdParam.ReadX.mSectorCount =16; //讀取16扇 mCmdParam.ReadX.mDataBuffer = &FILE_DATA_BUF[ 0 ]; i = CH375FileReadX( ); mStopIfError( i ); CH375vFileSize -= CH375vSectorSize - 1;

SecCount = mCmdParam.ReadX.mSectorCount; /* 備份實(shí)際讀取的扇區(qū)數(shù) */ if( SecCount < 16 ) mReadOver = 1; // 當(dāng)讀取的扇區(qū)數(shù)小于16時(shí)說明文件己結(jié)束

uart_printf("save source file info\n"); mCmdParam.SaveVariable.mSaveVariable = 0x01; mCmdParam.SaveVariable.mBuffer = &mFile0Info[ 0 ]; CH375SaveVariable( ); /* 保存源文件信息 */ /*==================================================================*/ // uart_printf("restore destination file info\n"); mCmdParam.SaveVariable.mSaveVariable = 0x00; mCmdParam.SaveVariable.mBuffer = &mFile1Info[ 0 ]; CH375SaveVariable( ); /* 恢復(fù)目標(biāo)文件信息 */ // uart_printf("write\n"); mCmdParam.WriteX.mSectorCount = SecCount; mCmdParam.WriteX.mDataBuffer = &FILE_DATA_BUF[ 0 ]; i = CH375FileWriteX( ); mStopIfError( i ); // uart_printf("save destination file info\n"); mCmdParam.SaveVariable.mSaveVariable = 0x01; mCmdParam.SaveVariable.mBuffer = &mFile1Info[ 0 ]; CH375SaveVariable( ); /* 保存目標(biāo)文件信息 */

if( mReadOver ) { uart_printf(" copy file over\n"); CH375vFileSize = mFileSize; mCmdParam.Close.mUpdateLen = 1; i = CH375FileClose( ); mStopIfError( i ); break; } } [Emot]1[/Emot]

1:你在用完一個(gè)文件,開始操作第二個(gè)文件前調(diào)用CH375DirtyBuffer( );把磁盤緩沖區(qū)的內(nèi)容清除 2:為驗(yàn)證是不是文件指針飛掉了,您可以在讀寫文件前調(diào)用CH375FileLocate( void ); 函數(shù)將文件指針偏移固定扇區(qū)進(jìn)行操作.


這是我們的提供的示例程序,經(jīng)過測試,應(yīng)該不會有問題 試試只對源文件進(jìn)行讀操作,看看是否能夠完整讀出文件


我試過只對源文件讀操作,發(fā)現(xiàn)只有前幾次能讀出數(shù)據(jù)后幾次數(shù)據(jù)就成亂碼了我對讀取的文件用二制打開發(fā)現(xiàn)只有前4096字節(jié)是準(zhǔn)確的.不管改變每次讀幾個(gè)扇區(qū).一開始我是二扇.到4096字節(jié)后就成亂碼了.后來我改為16扇發(fā)現(xiàn)是文件最后幾個(gè)扇會成為亂碼.如果一次將文件全部都讀取就是正常的


這樣,你把你的編譯好的MAP文件帖上來看下,以及你的硬件資源說明下.包括RAM,FLASH等等


我的硬件ARM是S3C44BOX 工作在64MHZ FLSAH是SST39VF1601 RAM是HY57V641620 是8M的 USB 芯片CH375B

以下是我編譯好的MAP文件 ARM Linker, RVCT3.1 [Build 919] for uVision [Standard]

================================================================================

Section Cross References

main.o(.text) refers to CH375SEC.O(.text) for CH375FileReadX main.o(.text) refers to CH375MAI.O(.text) for CH375GetVer main.o(.text) refers to 44blib.o(.text) for delay main.o(.text) refers to main.o(.bss) for FILE_DATA_BUF main.o(.text) refers to CH375MAI.O(.data) for CH375IntStatus main.o(.text) refers to main.o(.data) for .data main.o(.text) refers to CH375DSZ.O(.text) for CH375DiskSize main.o(.text) refers to strcpy.o(.text) for strcpy main.o(.text) refers to CH375SAV.O(.text) for CH375SaveVariable main.o(.text) refers to strlen.o(.text) for strlen 8led.o(.text) refers to iic.o(.text) for iic_init 8led.o(.text) refers to aeabi_sdiv.o(.text) for __aeabi_idivmod 8led.o(.text) refers to 44blib.o(.text) for delay 8led.o(.text) refers to 8led.o(.data) for f_szDigital iic.o(.text) refers to iic.o(.data) for f_nGetACK uhal.o(.text) refers to 44blib.o(.text) for timer_start 44blib.o(.text) refers to aeabi_sdiv.o(.text) for __aeabi_idivmod 44blib.o(.text) refers to dflt_noclz.o(x$fpl$dflt) for __aeabi_i2d 44blib.o(.text) refers to ddiv.o(x$fpl$ddiv) for __aeabi_ddiv 44blib.o(.text) refers to daddsub_noclz.o(x$fpl$dadd) for __aeabi_dadd 44blib.o(.text) refers to dfix.o(x$fpl$dfix) for __aeabi_d2iz 44blib.o(.text) refers to 44blib.o(.data) for .data 44blib.o(.text) refers to c89vsprintf.o(.text) for __c89vsprintf 44blib.o(.text) refers to strlen.o(.text) for strlen 44blib.o(.text) refers to atoi.o(.text) for atoi 44blib.o(.text) refers to rt_ctype_table.o(.text) for __rt_ctype_table 44blib.o(.text) refers to uhal.o(.text) for uhal_init_interrupts s3c44b0x.o(STACK) refers (Special) to stkheap2.o(.text) for __use_two_region_memory s3c44b0x.o(HEAP) refers (Special) to stkheap2.o(.text) for __use_two_region_memory s3c44b0x.o(RESET) refers to s3c44b0x.o(STACK) for Stack_Top s3c44b0x.o(RESET) refers to __main.o(!!!main) for __main s3c44b0x.o(RESET) refers (Special) to stkheap2.o(.text) for __use_two_region_memory s3c44b0x.o(.text) refers to s3c44b0x.o(HEAP) for Heap_Mem s3c44b0x.o(.text) refers to s3c44b0x.o(STACK) for Stack_Mem s3c44b0x.o(.text) refers (Special) to stkheap2.o(.text) for __use_two_region_memory lcd.o(.text) refers to c89vsprintf.o(.text) for __c89vsprintf lcd.o(.text) refers to lcd.o(.data) for gCurRow dir.o(.text) refers to toupper.o(.text) for toupper dir.o(.text) refers to disk.o(.text) for GetDiskInfo dir.o(.text) refers to fdt.o(.text) for FindFDTInfo dir.o(.text) refers to fat.o(.text) for FATAddClus dir.o(.text) refers to dir.o(.data) for .data disk.o(.text) refers to rwsec.o(.text) for CacheInit disk.o(.text) refers to aeabi_sdiv.o(.text_udiv) for __aeabi_uidivmod disk.o(.text) refers to disk.o(.bss) for DiskInfo fat.o(.text) refers to disk.o(.text) for GetDiskInfo fat.o(.text) refers to aeabi_sdiv.o(.text_udiv) for __aeabi_uidivmod fat.o(.text) refers to rwsec.o(.text) for OpenSec fdt.o(.text) refers to disk.o(.text) for GetDiskInfo fdt.o(.text) refers to rwsec.o(.text) for OpenSec fdt.o(.text) refers to aeabi_sdiv.o(.text_udiv) for __aeabi_uidivmod fdt.o(.text) refers to fat.o(.text) for FATGetNextClus file.o(.text) refers to toupper.o(.text) for toupper file.o(.text) refers to dir.o(.text) for _GetFDTInfo file.o(.text) refers to fdt.o(.text) for FindFDTInfo file.o(.text) refers to fat.o(.text) for FATDelClusChain file.o(.text) refers to disk.o(.text) for GetDiskInfo file.o(.text) refers to aeabi_sdiv.o(.text_udiv) for __aeabi_uidivmod file.o(.text) refers to rwsec.o(.text) for OpenSec file.o(.text) refers to file.o(.bss) for .bss rwsec.o(.text) refers to disk.o(.text) for GetDiskInfo rwsec.o(.text) refers to rwsec.o(.bss) for DiskCache zlg_ffs.o(.text) refers to aeabi_sdiv.o(.text_udiv) for __aeabi_uidivmod zlg_ffs.o(.text) refers to h1_alloc.o(.text) for malloc zlg_ffs.o(.text) refers to h1_free.o(.text) for free zlg_ffs.o(.text) refers to zlg_ffs.o(.constdata) for .constdata CH375MAI.O(.text) refers to main.o(.text) for xWriteCH375Cmd CH375MAI.O(.text) refers to CH375MAI.O(.data) for .data CH375MAI.O(.text) refers to main.o(.bss) for DISK_BASE_BUF CH375SEC.O(.text) refers to main.o(.text) for xWriteCH375Cmd CH375SEC.O(.text) refers to CH375MAI.O(.text) for CH375s17 CH375SEC.O(.text) refers to main.o(.bss) for mCmdParam CH375SEC.O(.text) refers to CH375MAI.O(.data) for CH375v19 CH375DSZ.O(.text) refers to CH375MAI.O(.text) for CH375DiskConnect CH375DSZ.O(.text) refers to CH375MAI.O(.data) for CH375DiskStatus CH375DSZ.O(.text) refers to main.o(.bss) for DISK_BASE_BUF CH375SAV.O(.text) refers to main.o(.bss) for mCmdParam CH375SAV.O(.text) refers to CH375MAI.O(.data) for CH375vStartCluster rt_ctype_table.o(.text) refers to rt_locale_intlibspace.o(.text) for __rt_locale rt_ctype_table.o(.text) refers to lc_ctype_c.o(locale$$code) for _get_lc_ctype malloc.o(.text) refers to rt_heap_descriptor_intlibspace.o(.text) for __rt_heap_descriptor malloc.o(.text) refers (Special) to hguard.o(.text) for __heap_guard malloc.o(.text) refers (Special) to init_alloc.o(.text) for _init_alloc free.o(.text) refers to rt_heap_descriptor_intlibspace.o(.text) for __rt_heap_descriptor free.o(.text) refers (Special) to hguard.o(.text) for __heap_guard h1_alloc.o(.text) refers to rt_heap_descriptor_intlibspace.o(.text) for __rt_heap_descriptor h1_alloc.o(.text) refers to init_alloc.o(.text) for __Heap_Full h1_alloc.o(.text) refers (Special) to h1_init.o(.text) for __Heap_Initialize h1_free.o(.text) refers to rt_heap_descriptor_intlibspace.o(.text) for __rt_heap_descriptor h1_alloc_mt.o(.text) refers to init_alloc.o(.text) for __Heap_Full h1_alloc_mt.o(.text) refers to rt_heap_descriptor_intlibspace.o(.text) for __rt_heap_descriptor h1_alloc_mt.o(.text) refers (Special) to h1_init.o(.text) for __Heap_Initialize h1_free_mt.o(.text) refers to rt_heap_descriptor_intlibspace.o(.text) for __rt_heap_descriptor heap2.o(i.___Heap_ProvideMemory_realtime) refers to fdtree.o(i._FDTree_Delete) for _FDTree_Delete heap2.o(i.___Heap_ProvideMemory_realtime) refers to fdtree.o(i._FDTree_Insert) for _FDTree_Insert heap2.o(i._malloc_realtime) refers to rt_heap_descriptor_intlibspace.o(.text) for __rt_heap_descriptor heap2.o(i._malloc_realtime) refers to fdtree.o(i._FDTree_FindFirst) for _FDTree_FindFirst heap2.o(i._malloc_realtime) refers to init_alloc.o(.text) for __Heap_Full heap2.o(i._malloc_realtime) refers to fdtree.o(i._FDTree_RemoveNode) for _FDTree_RemoveNode heap2.o(i._malloc_realtime) refers to fdtree.o(i._FDTree_Insert) for _FDTree_Insert heap2.o(i._realloc_realtime) refers to rt_heap_descriptor_intlibspace.o(.text) for __rt_heap_descriptor heap2.o(i._realloc_realtime) refers to h1_free.o(.text) for free heap2.o(i._realloc_realtime) refers to h1_alloc.o(.text) for malloc heap2.o(i._realloc_realtime) refers to fdtree.o(i._FDTree_Delete) for _FDTree_Delete heap2.o(i._realloc_realtime) refers to fdtree.o(i._FDTree_Insert) for _FDTree_Insert heap2.o(i._realloc_realtime) refers to rt_memcpy_w.o(.text) for __aeabi_memcpy4 heap2.o(i._free_realtime) refers to rt_heap_descriptor_intlibspace.o(.text) for __rt_heap_descriptor heap2.o(i._free_realtime) refers to fdtree.o(i._FDTree_Delete) for _FDTree_Delete heap2.o(i._free_realtime) refers to fdtree.o(i._FDTree_I


如果我在循環(huán)中在每次讀取源文件時(shí)對讀取緩沖區(qū)操作前調(diào)用CH375DirtyBuffer( );把磁盤緩沖區(qū)的內(nèi)容清除 能讀出源文件從串口輸出能看到文件內(nèi)容是正確的.但寫入的文件卻打不開是壞的


只有登錄才能回復(fù),可以選擇微信賬號登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频