我用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; }
望指教,謝謝!!