[求助]U盤初始化失敗,幫幫忙啊!

我用8051控制ch375,液晶顯示進(jìn)行檢測,發(fā)現(xiàn)U盤的初始化始終沒法完成,初始化程序如下

ch375writecmd(0x51); del_5ms(); if(waitstatu()==0x14) { putstr(0," usb int success"); } else { putstr(0," usb int error! "); }

底層的3個讀寫函數(shù)是

unsigned char waitstatu(void) //等待并讀取狀態(tài) { ch375_int=1; while(ch375_int); ch375writecmd(0x22); EA=1; return ch375readdata(); }

void ch375writecmd(unsigned char cmd) { P1=cmd; ch375_a0=1; ch375_rd=1; ch375_wr=0; ch375_cs=0; ; ch375_wr=1; ch375_cs=1; }

void ch375writedata(unsigned char value) { P1=value; ch375_a0=0; ch375_rd=1; ch375_wr=0; ch375_cs=0; ; ch375_wr=1; ch375_cs=1; }

unsigned char ch375readdata(void) { unsigned char value; P1=0xff; ch375_rd=0; ch375_wr=1; ch375_a0=0; ch375_cs=0; ; value=P1; ; ch375_rd=1; ch375_cs=1; return value; }

望指教,謝謝!!

unsigned char waitstatu(void) //等待并讀取狀態(tài) { ch375_int=1; while(ch375_int); ch375writecmd(0x22); EA=1; return ch375readdata(); }

void ch375writecmd(unsigned char cmd) { P1=cmd; ch375_a0=1; ch375_rd=1; ch375_cs=0; ch375_wr=0; ; ch375_wr=1; ch375_cs=1; ch375_a0=0; }

void ch375writedata(unsigned char value) { P1=value; ch375_a0=0; ch375_rd=1; ch375_cs=0; ch375_wr=0; ; ch375_wr=1; ch375_cs=1; }

unsigned char ch375readdata(void) { unsigned char value; P1=0xff; ch375_wr=1; ch375_a0=0; ch375_cs=0; ch375_rd=0; ; value=P1; ; ch375_rd=1; ch375_cs=1; return value; } 還有就是你單片機用的是多少M的晶振?還有就是USB線要盡量的短點


你的三個讀寫子程序時序有點問題: 你按下面改下試試: void ch375writecmd(unsigned char cmd) { P1 = cmd; ch375_a0 = 1; ch375_rd=1; ch375_cs=0; ch375_wr=0; ch375_cs=0; ch375_wr=1; ch375_cs=1; ch375_a0=0;; P1 = 0xff; }

void ch375writedata(unsigned char value) { P1= value; ch375_cs=0; ch375_wr=0; ch375_cs=0;

ch375_wr=1; ch375_cs=1; P1= 0xff; }

unsigned char ch375readdata(void) { unsigned char value; P1=0xff; ch375_cs= 0; ch375_rd = 0; ch375_cs=0; value=P1; ch375_rd=1; ch375_cs=1; P1= 0xff; return( value); }


單片機晶振是11.0592,


   用上面的讀寫函數(shù)替換了,還是不行,返回值還是2CH


我直接將ch375芯片與單片機連接,這樣能否使用文件級子程序中的CH375LibInit( )和CH375DiskReady( ) 如果能的話,U盤的初始化是在哪個函數(shù)中的,使用文件級子程序庫時,芯片與單片機的接口連接是怎樣的?


使用文件級子程序庫,單片機系統(tǒng)需要具備不少于4KB到7KB的程序空間,不少于600字節(jié)的RAM.將庫添加到工程中,就可以使用CH375LibInit( )和CH375DiskReady( )兩個函數(shù),CH375DiskReady( )這個函數(shù)是查詢磁盤準(zhǔn)備好,成功后就可以對U盤操作.芯片與單片機的接口連接支持并口和串口連接,FILELIB5中有串口操作的例子,FILELIB4中是并口連接的例子.具體的庫說明可以看CH375EVT/CH375HF.PDF


你可以不可以將你的晶振提高點,例如換成22。1184,因為速度太慢也會出現(xiàn)問題


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

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