我按照資料上的例子寫扇區(qū)。。可是寫第2組的數(shù)據(jù)時(shí)。。INT就不會變低了。。最后讀狀態(tài)的結(jié)果是1F。。。有誰知道原因嗎。。。我的優(yōu)盤是金士頓。。。用ARM做的 一下是我的程序: USB_WriteCommand(CHECK_EXIST);//測試工作狀態(tài) USB_WriteData(0xee); //輸入任意數(shù)據(jù) *addr=USB_ReadData(); //按位取反輸出
USB_WriteCommand(0x15); //設(shè)置工作模式 USB_WriteData(0x06); //自動(dòng)探測 USB_WriteCommand(0x16); //查詢USB設(shè)備連接狀態(tài) USB_WriteCommand(0x22); //獲取狀態(tài) 15H IS CONNECT *addr=USB_ReadData();
USB_WriteCommand(DISK_INIT); //初始化USB設(shè)備 USB_WriteCommand(0x22); //獲取狀態(tài) 14 IS SUCCESSFUL *addr=USB_ReadData(); USB_WriteCommand(DISK_SIZE); USB_WriteCommand(0x22); //獲取狀態(tài) 14 IS SUCCESSFUL *addr=USB_ReadData(); USB_WriteCommand(RD_USB_DATA); *addr=USB_ReadData(); for (i=0;i!=8;i++) // 根據(jù)長度讀取數(shù)據(jù) { *addr= USB_ReadData(); /* 讀出數(shù)據(jù)并保存 */ addr++; } USB_WriteCommand(SET_PKT_P_SEC); /* 設(shè)置USB存儲器的每扇區(qū)數(shù)據(jù)包總數(shù) */ USB_WriteData(0x39); USB_WriteData(8); /* 設(shè)置每扇區(qū)數(shù)據(jù)包總數(shù) */ bram=read_ram; ///寫扇區(qū) USB_WriteCommand(0x56);//寫扇區(qū)命令 USB_WriteData(0x00);//寫入4個(gè)數(shù)據(jù),LBA地址 USB_WriteData(0x00); USB_WriteData(0x00); USB_WriteData(0x00); USB_WriteData(0x01);//扇區(qū)數(shù) for(i=8;i!=0;i--) {while(IO0PIN&0x010000); USB_WriteCommand(0x22); //獲取狀態(tài)1EH *addr=USB_ReadData(); if (*addr==USB_INT_DISK_WRITE) {USB_WriteCommand(WR_USB_DATA7); //寫入數(shù)據(jù)塊 USB_WriteData(0x40);//數(shù)據(jù)塊長度為64 mDelay1_2uS(20); for(k=0;k<64;k++) {USB_WriteData(*bram); //寫入的數(shù)據(jù) bram++; } USB_WriteCommand(DISK_WR_GO); //繼續(xù)寫命令 } //else break; /* 返回錯(cuò)誤狀態(tài) */ } while(IO0PIN&0x010000); USB_WriteCommand(0x22); //獲取狀態(tài) 14H *addr=USB_ReadData();