1.我首先用的是ch375hf6.lib和ch375hf6.h 2.當我在main函數(shù)里設(shè)一個unsigned char xdata buf[512]的時候,出現(xiàn)xdata=1111,然后下載到stc11F16XE中運行出現(xiàn)異常,程序根本不運行 3.當我吧xdata buf[512]改為xdata buf[256]時,程序可以開始運行,但是不能正常進行扇區(qū)讀寫。 4.此時我以為是單片機內(nèi)部擴展ram的問題,于是換了個內(nèi)部擴展ram為4k的STC90C58RD+。 但是此時在超級終端中出現(xiàn)亂碼(波特率正確)!
請各位大俠幫小弟看看問題出在哪,到底是ch375hf6.lib和ch375hf6.h要修改,還是ram的大小問題?謝謝了
PS:沒有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("串口通信測試...\n");
if(!CH375LibInit()) { UART_Send_Str("初始化CH375程序庫及CH375芯片成功!\n"); UART_Send_Str("插入U盤\n");
UART_Send_Str("開始檢測U盤是否插入...\n"); while(CH375DiskConnect()!=ERR_SUCCESS) { delay(3000); } UART_Send_Str("U盤已經(jīng)插入\n");
UART_Send_Str("開始檢測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("當前文件的偏移量為:",CH375vCurrentOffset);
UART_Send_Str("以扇區(qū)模式寫入:\n"); mCmdParam.Locate.mSectorOffset=1; CH375FileLocate(); UART_Put_Inf("當前文件的偏移量為:",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程序庫及CH375芯片失?。n"); } while(1); }