1.我首先用的是ch375hf6.lib和ch375hf6.h 2.當(dāng)我在main函數(shù)里設(shè)一個(gè)unsigned char xdata buf[512]的時(shí)候,出現(xiàn)xdata=1111,然后下載到stc11F16XE中運(yùn)行出現(xiàn)異常,程序根本不運(yùn)行 3.當(dāng)我吧xdata buf[512]改為xdata buf[256]時(shí),程序可以開始運(yùn)行,但是不能正常進(jìn)行扇區(qū)讀寫。 4.此時(shí)我以為是單片機(jī)內(nèi)部擴(kuò)展ram的問(wèn)題,于是換了個(gè)內(nèi)部擴(kuò)展ram為4k的STC90C58RD+。 但是此時(shí)在超級(jí)終端中出現(xiàn)亂碼(波特率正確)!
請(qǐng)各位大俠幫小弟看看問(wèn)題出在哪,到底是ch375hf6.lib和ch375hf6.h要修改,還是ram的大小問(wèn)題?謝謝了
PS:沒(méi)有define FILE_DATA_BUF_LEN 512 只有define DISK_BASE_BUF_LEN 512
main函數(shù)如下:
#include #include #include "uart.h" #include "myfun.h"
#define CH375_CMD_PORT_ADDR 0x8DF1 /* CH375命令端口的I/O地址 */ #define CH375_DAT_PORT_ADDR 0x8CF0 /* CH375數(shù)據(jù)端口的I/O地址 */
#include "ch375hf6.h"
unsigned char i,j,len;
unsigned char xdata buf[512];
sfr BUS_SPEED=0xa1;
void delay(unsigned int time) { while(time--); }
void main() { BUS_SPEED=0x27;//調(diào)整總線速度 UART_Init(); UART_Send_Str("串口通信測(cè)試...\n");
if(!CH375LibInit()) { UART_Send_Str("初始化CH375程序庫(kù)及CH375芯片成功!\n"); UART_Send_Str("插入U(xiǎn)盤\n");
UART_Send_Str("開始檢測(cè)U盤是否插入...\n"); while(CH375DiskConnect()!=ERR_SUCCESS) { delay(3000); } UART_Send_Str("U盤已經(jīng)插入\n");
UART_Send_Str("開始檢測(cè)U盤是否就緒...\n"); while(CH375DiskReady()!=ERR_SUCCESS) { delay(1000); } UART_Send_Str("U盤已經(jīng)就緒,可以操作\n");
UART_Send_Str("獲取磁盤物理總?cè)萘?..\n"); CH375DiskSize(); UART_Put_Inf("硬盤物理總?cè)萘繛?扇區(qū)):",mCmdParam.DiskSize.mDiskSizeSec);
UART_Send_Str("獲取磁盤信息...\n"); CH375DiskQuery(); UART_Put_Inf("磁盤總?cè)萘?兆):",mCmdParam.Query.mTotalSector/2048); UART_Put_Inf("剩余容量(兆):",mCmdParam.Query.mFreeSector/2048); strcpy(mCmdParam.Open.mPathName,"\\TEST.TXT"); UART_Send_Str("打開文件/目錄:"); UART_Send_Str(mCmdParam.Open.mPathName); UART_Send_Str("\n");
if(CH375FileOpen()==ERR_SUCCESS) { UART_Send_Str("打開文件/目錄成功\n");
UART_Put_Inf("當(dāng)前文件的偏移量為:",CH375vCurrentOffset);
UART_Send_Str("以扇區(qū)模式寫入:\n"); mCmdParam.Locate.mSectorOffset=1; CH375FileLocate(); UART_Put_Inf("當(dāng)前文件的偏移量為:",CH375vCurrentOffset); for(i=0;i { buf[i]='a'; } mCmdParam.WriteX.mDataBuffer=buf; mCmdParam.WriteX.mSectorCount=1; CH375FileWriteX();
mCmdParam.WriteX.mDataBuffer=buf; mCmdParam.WriteX.mSectorCount=0; CH375FileWriteX(); } else { UART_Send_Str("打開文件/目錄失敗\n"); } } else { UART_Send_Str("初始化CH375程序庫(kù)及CH375芯片失??!\n"); } while(1); }