CH376寫數(shù)據(jù)不完

Start Wait Udisk/SD Ready ? DiskQuery: free cap = 2093 MB Open Create Write begin Write ADC data Current total is 99 Current total is 154 Current total is 209 Current total is 263 Current total is 318 Current total is 373 Current total is 428 Current total is 483 Current total is 538 Current total is 593 Current total is 646 Current total is 701 Current total is 756 Current total is 810 Current total is 865 Current total is 920 Current total is 975 Current total is 1030 Current total is 1085 Current total is 1140 Current total is 1194 Current total is 1249 Current total is 1304 Current total is 1359 Current total is 1413 Current total is 1468 Current total is 1523 Current total is 1578 Current total is 1632 Current total is 1687 Current total is 1742 Current total is 1797 Current total is 1852 Current total is 1907 Current total is 1962 Current total is 2017 Current total is 2072 Current total is 2127 Current total is 2182 Current total is 2236 Current total is 2291 Current total is 2346 Current total is 2401 Current total is 2455 Current total is 2510 Current total is 2565 Current total is 2620 Current total is 2674 Current total is 2729 Current total is 2784 Current total is 2839 Current total is 2894 Current total is 2949 Current total is 3004 Current total is 3059 Current total is 3114 Current total is 3169 Current total is 3224 Current total is 3278 Current total is 3333 Current total is 3388 Current total is 3443 Current total is 3497 Current total is 3552 Current total is 3607 Current total is 3662 Current total is 3716 Current total is 3771 Current total is 3826 Current total is 3881 Current total is 3936 Current total is 3991 Current total is 4046 Current total is 4101 Current total is 4156 Current total is 4211 Current total is 4266 Current total is 4320 Current total is 4375 Current total is 4430 Current total is 4485 Current total is 4539 Current total is 4594 Current total is 4649 Current total is 4704 Current total is 4757 Current total is 4812 Current total is 4867 Current total is 4922 Current total is 4977 Current total is 5032 Current total is 5087 Current total is 5142 Current total is 5197 Current total is 5252 Current total is 5307 Current total is 5361 Current total is 5416 Current total is 5471 Current total is 5526 Current total is 5580 Current total is 5635 Current total is 5690 Current total is 5745 Current total is 5800 Current total is 5855 Current total is 5910 Current total is 5965 Current total is 6020 Current total is 6075 Current total is 6130 Current total is 6184 Current total is 6239 Current total is 6294 Current total is 6349 Current total is 6403 Current total is 6458 Current total is 6513 Current total is 6568 Current total is 6622 Current total is 6677 Current total is 6732 Current total is 6787 Current total is 6842 Current total is 6897 Current total is 6952 Current total is 7007 Current total is 7062 Current total is 7117 Current total is 7172 Current total is 7226 Current total is 7281 Current total is 7336 Current total is 7391 Current total is 7445 Current total is 7500 Current total is 7555 Current total is 7610 Current total is 7664 Current total is 7719 Current total is 7774 Current total is 7829 Current total is 7884 Current total is 7939 Current total is 7994 Current total is 8049 Current total is 8104 Current total is 8159 Current total is 8214 Current total is 8268 Current total is 8323 Current total is 8378 Current total is 8433 Current total is 8487 Current total is 8542 Current total is 8597 Current total is 8652 Current total is 8706 Current total is 8761 Current total is 8816

在我拔除優(yōu)盤會報錯FA U盤里出現(xiàn)一個文件AHY_ADC.TXT,但是沒有任何內(nèi)容 是不是因為沒有更新數(shù)據(jù)長度呢?? 請幫我分析分析原因. 例子是參考CH376EVT里的EXAM8,沒有作任何修改啊~~難道是U盤原因?


熱門產(chǎn)品 : USB3.0 HUB控制器:CH634

1、必須更新文件長度 2、例程中采用for循環(huán)總次數(shù)是360,監(jiān)控一下次數(shù)是不是正確的


文件寫完之后要關(guān)閉文件,并且更新文件長度,否則文件當(dāng)中是沒有數(shù)據(jù)的。


printf( "Write begin\n" ); total += sprintf( FileDataBuf + total, "在本次添加數(shù)據(jù)之前,該文件已有數(shù)據(jù)的長度是 %ld 字節(jié)\xd\xa", NewSize ); /* 將新數(shù)據(jù)添加到緩沖區(qū)的尾部,累計緩沖區(qū)內(nèi)的數(shù)據(jù)長度 */ mFlushBufferToDisk( 0 ); /* 自動刷新緩沖區(qū),檢查緩沖區(qū)是否已滿,滿則寫盤 */ printf( "Write ADC data\n" ); TR0=1; /* 用定時器0的計數(shù)值代替ADC數(shù)據(jù) */ for ( month = 1; month != 4; month ++ ) { /* 因為測試板上沒有實時時鐘芯片,所以用循環(huán)方式模擬月份 */ for ( date = 1; date != 10; date ++ ) { /* 因為測試板上沒有實時時鐘芯片,所以用循環(huán)方式模擬日期 */ year = 2004; /* 假定為2004年 */ hour = TL1 & 0x1F; /* 因為測試板上沒有實時時鐘芯片,所以用定時器1的計數(shù)代替進行演示 */ /* adc = get_adc_data( ); */ adc = ( (UINT16)TH0 << 8 ) | TL0; /* 因為測試板上沒有ADC,所以用定時器0的計數(shù)代替ADC數(shù)據(jù)演示 */ total += sprintf( FileDataBuf + total, "Year=%04d, Month=%02d, Date=%02d, Hour=%02d, ADC_data=%u\xd\xa", year, (UINT16)month, (UINT16)date, (UINT16)hour, adc ); /* 將二制制數(shù)據(jù)格式為一行字符串 */ if ( month == 6 && ( date & 0x0F ) == 0 ) mFlushBufferToDisk( 1 ); /* 強制刷新緩沖區(qū),定期強制刷新緩沖區(qū),這樣在突然斷電后可以減少數(shù)據(jù)丟失 */ else mFlushBufferToDisk( 0 ); /* 自動刷新緩沖區(qū),檢查緩沖區(qū)是否已滿,滿則寫盤 */ printf( "Current total is %d\n", total ); /* 用于監(jiān)控檢查 */ } } printf( "Write end\n" ); //total += sprintf( FileDataBuf + total, " ********************************* " ); /* 將新數(shù)據(jù)添加到緩沖區(qū)的尾部,累計緩沖區(qū)內(nèi)的數(shù)據(jù)長度 */ //total += sprintf( FileDataBuf + total, "這次的ADC數(shù)據(jù)到此結(jié)束,程序即將退出\xd\xa" ); /* 將新數(shù)據(jù)添加到緩沖區(qū)的尾部,累計緩沖區(qū)內(nèi)的數(shù)據(jù)長度 */ CH376FileOpen( "\MY_ADC.TXT" ); mFlushBufferToDisk( 1 ); /* 強制刷新緩沖區(qū),因為系統(tǒng)要退出了,所以必須強制刷新 */ printf( "Close\n" ); s = CH376FileClose( FALSE ); /* 關(guān)閉文件,扇區(qū)模式通常不自動更新文件長度,因為強制刷新緩沖區(qū)時已經(jīng)更新了文件長度,所以這里不需要自動更新文件長度 */ mStopIfError( s ); 我把程序做了點修改, 用串口助手觀察結(jié)果如下: Start Wait Udisk/SD Ready ? DiskQuery: free cap = 2093 MB Open Create Write begin Write ADC data Current total is 99 Current total is 154 Current total is 209 Current total is 263 Current total is 318 Current total is 373 Current total is 428 Current total is 483 Current total is 538 Current total is 593 Current total is 646 Current total is 701 Current total is 756 Current total is 810 Current total is 865 Current total is 920 Current total is 975 Current total is 1030 Current total is 1085 Current total is 1140 Current total is 1194 Current total is 1249 Current total is 1304 Current total is 1359 Current total is 1413 Current total is 1468 Current total is 1523 Write end Current file size is 1600085842 Error: B4 這個mFlushBufferToDisk( 1 )會導(dǎo)致關(guān)閉文件嗎?因為B4代表文件已關(guān)閉 我打開U盤,看不到MY_ADC.TXT文件,這是什么原因呢??


1、CH376FileOpen有返回值,程序中怎么沒有檢測 2、mFlushBufferToDisk不會關(guān)閉文件,只有CH376FileClose才會 3、寫完數(shù)據(jù)后,為什么調(diào)CH376FileOpen呢?這時文件本身就是打開的,建議先不要修改程序的流程,調(diào)試成功后再根據(jù)需要修改


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

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