使用最新官網(wǎng)例程?
版本:2.4 上傳時(shí)間:2024-03-11
下面是錯誤定位代碼:
int?main(void) { u32?i; u32?Sector_Nums; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); SystemCoreClockUpdate(); Delay_Init(); USART_Printf_Init(115200); printf("SystemClk:%d\r\n",?SystemCoreClock); printf("ChipID:%08x\r\n",?DBGMCU_GetCHIPID()); while(eMMC_Init()) { printf("eMMC?Card?Error!\r\n"); delay_ms(1000); } show_eMMCcard_info(); printf("eMMC?Card?initial?OK!\r\n"); Sector_Nums?=?((u32)?(eMMCCardInfo.SectorNums)); eMMC_Change_Tran_Mode(); for?(i?=?0;?i?<?512;?i++) { buf[i]?=?i; } for?(i?=?0;?i?<?Sector_Nums;?i++) { if?(SD_WriteDisk(buf,?i,?1)) { printf("Wr?%d?sector?fail\n",?i); } else { printf("Wr?%d?sector?success\n",?i); } if?(SD_ReadDisk(Readbuf,?i,?1)) { printf("Rd?%d?sector?fail\n",?i); } else { printf("Rd?%d?sector?success\n",?i); } if?(memcmp(buf,?Readbuf,?512)) { printf("?%d?sector?Verify?fail\n",?i); break; } } printf("end\n"); while(1); }
在主函數(shù)中,
eMMC_Change_Tran_Mode();
之前的步驟均可以正常運(yùn)行,并且可以拿到卡的CID、CSD等卡參數(shù),讀到卡容量和扇區(qū)大小。但是調(diào)用
SD_WriteDisk(buf,i,1)
SD_ReadDisk(Readbuf,i,1)
等函數(shù)就會失敗,直接返回fail。
請問應(yīng)該如何解決?這個(gè)問題是否跟分區(qū)有關(guān)?需要切換到EMMC的UAR區(qū)才能進(jìn)行讀寫?但是我看ST的參考EMMC例程似乎也沒有進(jìn)行切換,就可以順利讀寫了?
熱門產(chǎn)品 :
CH339: 7端口多功能USB HUB控制器芯片