CH375A中斷問(wèn)題

那你先插上U盤(pán)在庫(kù)初始化之后,375的INT腳有變低嗎??


在CH375Reset( );后沒(méi)有中斷,中斷信號(hào)一直是高! 在ucErr = CH375LibInit( );中有一次中斷,讀取以后一直都是高電平信號(hào)! 請(qǐng)問(wèn)這個(gè)有問(wèn)題嗎?


CH375LibInit()函數(shù)應(yīng)該沒(méi)有中斷才對(duì)啊,那你讀取之后有沒(méi)有去看下中斷狀態(tài)是多少??


開(kāi)始忘記讀了,現(xiàn)在讀了一下.讀到的是DISK_CONNECT,表示設(shè)備已經(jīng)連接!這樣是不對(duì)的嗎?


跟蹤測(cè)試了以下,初始化順序如下: (1)發(fā)送命令0x06(檢測(cè)CH375工作是否正常),寫(xiě)入數(shù)據(jù)0x65,讀到數(shù)據(jù)為0x9A; (2)發(fā)送命令0x06(檢測(cè)CH375工作是否正常),寫(xiě)入數(shù)據(jù)0x9A,讀到數(shù)據(jù)為0x65; (3)發(fā)送命令0x01(讀取芯片及固件版本),讀到數(shù)據(jù)為0xA4; (4)發(fā)送命令0x15(設(shè)置U盤(pán)工作模式),寫(xiě)入數(shù)據(jù)0x06; (5)連續(xù)10次延時(shí)xDelay100uS (6)讀到數(shù)據(jù)為0x15(檢測(cè)到USB設(shè)備連接事件). (7)產(chǎn)生USB中斷 我跟蹤的過(guò)程就是這個(gè)樣子的! 其中第(3)個(gè),我在數(shù)據(jù)手冊(cè)上看到說(shuō)明,采用CH375A,返回的應(yīng)該是0XA2; 為什么返回的是0xA4?? 是不是這個(gè)有問(wèn)題呢? 但是為什么我只是在讀寫(xiě)U盤(pán)操作會(huì)出問(wèn)題,其他操作比如bListAll()和CH375DiskQuery()都正常?


我只有明天上午上班了就放假了,所以期待貴公司技術(shù)人員能幫我看看初始化是不是有問(wèn)題! 非常感謝!


那你看到你程序停在什么地方嗎??,還有就是檢測(cè)U盤(pán)連接應(yīng)該是這樣做: i = CH375LibInit( ); /* 初始化CH375程序庫(kù)和CH375芯片,操作成功返回0 */ /* 其它電路初始化 */ while ( 1 ) { while ( CH375DiskStatus != DISK_CONNECT ) xQueryInterrupt( ); mDelaymS( 200 ); /* 延時(shí),可選操作,有的USB存儲(chǔ)器需要幾十毫秒的延時(shí) */ 如果你按照你說(shuō)的先插下U盤(pán)不可以的話,那你一定要檢測(cè)你程序停在什么地方


每次都是死在: void xQueryInterrupt( void ) /* 查詢中斷狀態(tài),等待硬件中斷 */ { while ( CH375IntStatus == 0 ); /* 子程序庫(kù)調(diào)用該子程序之前CH375IntStatus=0,硬件中斷后,由中斷服務(wù)程序置為非0的實(shí)際中斷狀態(tài)后返回 */ } 里面,檢測(cè)不到中斷了! 但是也奇怪哈! 為什么bListAll()和CH375DiskQuery()都正常? 這也一樣有中斷啊,而寫(xiě)數(shù)據(jù)和讀數(shù)據(jù)就死掉了! 我自己的U盤(pán)是Diamond的,卻可以正常的操作,而且我也跟蹤進(jìn)去了,流程和我說(shuō)的是一樣的,為什么有一些就不行呢?   而且按照技術(shù)資料的說(shuō)明,理論上應(yīng)該只可能是先插上是正常,而后插上可能會(huì)出問(wèn)題,現(xiàn)在怎么反了,先插上還不行,非得要后插上才能正常讀寫(xiě)文件!   感覺(jué)怪怪的!


你把下面的程序: while ( 1 ) { while ( CH375DiskStatus != DISK_CONNECT ) xQueryInterrupt( ); mDelaym(200 ); 換為: while ( 1 ) { while ( CH375DiskStatus != DISK_CONNECT ) CH375DiskConnect( );mDelaymS( 200 );


函數(shù)xQueryInterrupt( ); 我沒(méi)有調(diào)用過(guò),是在貴公司的子函數(shù)庫(kù)里面調(diào)用的函數(shù)! 現(xiàn)在怎么改呢?


子函數(shù)庫(kù)里面是在哪里調(diào)用這個(gè)函數(shù)呢?是不是可以改一下你們的子程序庫(kù)呢? 我的調(diào)用的子程序庫(kù)是"CH375HF9.LIB"


上面的這個(gè)函數(shù)是在庫(kù)里面做好的,你可以直接調(diào)用


函數(shù)xQueryInterrupt( );原來(lái)原函數(shù)是在CH375HF9.H里面,但是因?yàn)槲覀児こ汤锩姘凑漳銈兲峁┑念^文件,會(huì)提示出錯(cuò),也是為了和我們公司的編寫(xiě)程序規(guī)范,我把該頭文件里面原函數(shù)全部提到了我自己建立的CH375HF.C里面!而具體再哪里調(diào)用了xQueryInterrupt( ),都是由你們的子函數(shù)庫(kù)決定的!我自己沒(méi)有調(diào)過(guò)該函數(shù)!  現(xiàn)在問(wèn)題是先插上U盤(pán),則除了讀寫(xiě)文件不能正常操作,而讀磁盤(pán)信息和列舉文件都正常.是不是哪里有問(wèn)題?


那你讀寫(xiě)U盤(pán)的函數(shù)在什么地方??


讀寫(xiě)U盤(pán)的函數(shù)都是在CH375HF.C里面! 系統(tǒng)上電的時(shí)候,只是初始化CH375,初始化過(guò)程如下: CH375Reset( ); mDelaymS(100); ucErr = CH375LibInit( ); mDelaymS(100); for(j = 0; j < 5; j++) { if (CH375DiskStatus == DISK_CONNECT) break; mDelaymS(100); } if(j == 5) { #ifdef __LANGUAGE_CHINESE__ GUI_MsgBox((INT8U *)"沒(méi)有檢測(cè)到U盤(pán)!"); #else GUI_MsgBox((INT8U *)"Not find UDisk!"); #endif BuzzerCon(1, 600000); delay(0x00500000); g_pCurMenu = g_pRootM->child; g_pCurWin = g_pCurMenu->pWin; GUI_UpdataWindow(); } else { mDelaymS(300 ); /* 延時(shí),可選操作,有的USB存儲(chǔ)器需要幾十毫秒的延時(shí) */ if(j != 5) { for ( i = 0; i < 3; i ++ ) { /* 有的U盤(pán)總是返回未準(zhǔn)備好,不過(guò)可以被忽略 */ mDelaymS( 100 ); if ( CH375DiskReady( ) == ERR_SUCCESS ) break; } } }

當(dāng)需要從SDRAM拷貝文件到U盤(pán)中時(shí),再開(kāi)始執(zhí)行寫(xiě)文件操作,操作如下: INT8U bRdSDRAMToUDisk(void) { extern WINDOWS gWinHandle; P_FAT_DIR_INFO mFileDir; BMCmdFileStart fileHead; BSchedule TmpSchedule; INT8U ucPathName[MAX_PATH_LEN]; INT32U uiFileIndex, uiSizeRead = 0, ulTmpData = 0; INT8U ucErr, ucSectorCount, ucFlag = 1;//, ucCharNum; INT32S iErr, i;

uiFileIndex = bfGetCurrentFileIndex(); bfOpenFile(uiFileIndex, 0, &g_pFile); bfReadFile(g_pFile, (INT8U *)&fileHead, BMCMD_FILE_START_SIZE, &uiSizeRead); bfCloseFile(g_pFile); bfOpenFile(uiFileIndex, 0, &g_pFile);

ucPathName[0] = '/'; for(i = 0; i < 8; i++) { if ( fileHead.ucFileName[i] >= 'a' && fileHead.ucFileName[i] <= 'z' ) //轉(zhuǎn)換成大寫(xiě)字母 fileHead.ucFileName[i] = fileHead.ucFileName[i] - ( 'a' - 'A' ); ucPathName[i + 1] = fileHead.ucFileName[i]; if((fileHead.ucFileName[i] == '\0') || (fileHead.ucFileName[i] == '.')) { break; } } //ucCharNum = strlen((char *)fileHead.ucFileName); if(fileHead.ucFileName[i - 1] == '.') { ucPathName[i ] = 'U'; ucPathName[i + 1] = 'L'; ucPathName[i + 2] = 'E'; ucPathName[i + 3] = '\0'; } else { ucPathName[i + 1] = '.'; ucPathName[i + 2] = 'U'; ucPathName[i + 3] = 'L'; ucPathName[i + 4] = 'E'; ucPathName[i + 5] = '\0'; } ucErr = bCheckFileExist((INT8U*)&ucPathName[0]); if(ucErr != ERR_SUCCESS) ucFlag = 0; else { #ifdef __LANGUAGE_CHINESE__ gWinHandle.title = "文件存儲(chǔ)中......"; #else #ifdef __LANGUAGE_SPANISH__ gWinHandle.title = "Guardar archivo"; #else gWinHandle.title = "Saving file..."; #endif #endif GUI_WindowsDraw((WINDOWS *)&gWinHandle); for(i = 0; i < MAX_PATH_LEN; i++) { mCmdParam.Create.mPathName[i] = ucPathName[i]; if(ucPathName[i] == '\0') break; } ucErr = CH375FileCreate(); if(ucErr == ERR_SUCCESS) { TmpSchedule.ulLast = 0; TmpSchedule.ulAll = fileHead.uiFileSize; TmpSchedule.ulStep = fileHead.uiFileSize / 100; if(fileHead.uiFileSize > FILE_DATA_BUF_LEN) { ucSectorCount = (FILE_DATA_BUF_LEN >> 9); while(1) { iErr = bfReadFile(g_pFile, (INT8U *)&FILE_DATA_BUF[0], FILE_DATA_BUF_LEN, &uiSizeRead); if(iErr == BFERR_FILE_NOT_OPENED_FOR_READ) { #ifdef __LANGUAGE_CHINESE__ GUI_MsgBox((INT8U *)"文件未打開(kāi)!"); #else #ifdef __LANGUAGE_SPANISH__ GUI_MsgBox((INT8U *)"No est?listo para lectura"); #else GUI_MsgBox((INT8U *)"The file is not open!"); #endif #endif delay(0x00500000); ucFlag = 0; break; } else { mCmdParam.Write.mSectorCount = ((uiSizeRead + 511) >> 9); if(mCmdParam.Write.mSectorCount) { ucErr = CH375FileWrite( ); if(ucErr == ERR_SUCCESS) { ulTmpData += uiSizeRead; TmpSchedule.ulCurrent = ulTmpData; GUI_DrawScheduleBar(32, 38, (BSchedule *)&TmpSchedule); } else { #ifdef __LANGUAGE_CHINESE__ GUI_MsgBox((INT8U *)"存儲(chǔ)文件失敗!"); #else #ifdef __LANGUAGE_SPANISH__ GUI_MsgBox((INT8U *)"?rror al guardar archivo!"); #else GUI_MsgBox((INT8U *)"Failed to store the file!"); #endif #endif delay(0x00500000); ucFlag = 0; break; } } if(mCmdParam.Write.mSectorCount < ucSectorCount) { break; } } } } else { iErr = bfReadFile(g_pFile, (INT8U *)&FILE_DATA_BUF[0], FILE_DATA_BUF_LEN, &uiSizeRead); if(iErr == BFERR_FILE_NOT_OPENED_FOR_READ) { #ifdef __LANGUAGE_CHINESE__ GUI_MsgBox((INT8U *)"文件未打開(kāi)!"); #else #ifdef __LANGUAGE_SPANISH__ GUI_MsgBox((INT8U *)"No est?listo para lectura"); #else GUI_MsgBox((INT8U *)"The file is not open!"); #endif #endif delay(0x00500000); ucFlag = 0; } else { mCmdParam.Write.mSectorCount =((uiSizeRead + 511 ) >> 9); ucErr = CH375FileWrite( ); if(ucErr == ERR_SUCCESS) { ulTmpData += uiSizeRead; TmpSchedule.ulCurrent = ulTmpData; GUI_DrawScheduleBar(32, 38, (BSchedule *)&TmpSchedule); } else { #ifdef __LANGUAGE_CHINESE__ GUI_MsgBox((INT8U *)"存儲(chǔ)文件失敗!"); #else #ifdef __LANGUAGE_SPANISH__ GUI_MsgBox((INT8U *)"?rror al guardar archivo!"); #else GUI_MsgBox((INT8U *)"Failed to store the file!"); #endif #endif delay(0x00500000); ucFlag = 0; } } } ucErr = CH375FileQuery( ); if(ucErr == ERR_SUCCESS) { mFileDir = (P_FAT_DIR_INFO)( (INT8U *)(&DISK_BASE_BUF[0]) + CH375vFdtOffset ); mFileDir->DIR_CrtDate = MAKE_FILE_DATE(fileHead.Time.usYear, fileHead.Time.ucMonth, fileHead.Time.ucDay); mFileDir->DIR_CrtTime = MAKE_FILE_TIME(fileHead.Time.ucHour, fileHead.Time.ucMin, fileHead.Time.ucSec); mFileDir->DIR_LstAccDate = MAKE_FILE_DATE(fileHead.Time.usYear, fileHead.Time.ucMonth, fileHead.Time.ucDay); } mCmdParam.Modify.mFileAttr = 0x20; // 存檔文件 mCmdParam.Modify.mFileTime = MAKE_FILE_TIME(fileHead.Time.ucHour, fileHead.Time.ucMin, fileHead.Time.ucSec); mCmdParam.Modify.mFileDate = MAKE_FILE_DATE(fileHead.Time.usYear, fileHead.Time.ucMonth, fileHead.Time.ucDay); mCmdParam.Modify.mFileSize = fileHead.uiFileSize; ucErr = CH375FileModify( ); /* 修改當(dāng)前文件的信息,修改日期和長(zhǎng)度 */ if(ucErr != ERR_SUCCESS) { #ifdef __LANGUAGE_CHINESE__ GUI_MsgBox((INT8U *)"文件屬性修改失敗!"); #else GUI_MsgBox((INT8U *)"Failed to modify attribute!"); #endif delay(0x00500000); ucFlag = 0; } } else { #ifdef __LANGUAGE_CHINESE__ GUI_MsgBox((INT8U *)"創(chuàng)建文件失敗!"); #else GUI_MsgBox((INT8U *)"Create file failure!"); #endif delay(0x00500000); ucFlag = 0; } mCmdParam.Close.mUpdateLen = 0; ucErr = CH375FileClose( ); } bfCloseFile(g_pFile); gSystem.ulSysStatus[gSystem.ulSysStatusCur] = STATUS_WAITING; g_pCurMenu = g_pRootM->child; //將系統(tǒng)界面切換到主界面 chenaihua 2006-03-11 g_pCurWin = g_pCurMenu->pWin; GUI_UpdataWindow(); CH375DirtyBuffer(); return ucFlag; }

當(dāng)需要從U盤(pán)拷貝文件到SDRAM中時(shí),執(zhí)行讀文件操作,操作如下: INT8U bRdUDiskToSDRAM(INT32U ulIndex) { extern WINDOWS gWinHandle; BSchedule TmpSchedule; BF_FileAttribute *pFileProp; INT8U i, j, ucErr, ucErrFlag = 1; INT16U usSecCount, ulCurCount = 0; INT32U ulTmpData = 0, ulFileCurSize; INT8U ucPathName[MAX_PATH_LEN]; INT32S iErr;

for (i = 0; i < MAX_PATH_LEN; i++) { ucPathName[i] = g_ucFilePath[i]; if(g_ucFilePath[i] == '\0') break; } for(j = 0 ; j < 16; j++) { ucPathName[i + j] = g_ucUFileName[ulIndex][j]; } ucErr = bChec


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

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