最近在做一个项目,涉及存储,采用TF卡,考虑节约体积。昨晚上把驱动写完后,对TF卡读写进行测试,1s一次读,写,擦除操作,大约一两分钟的时间,突然发现屏幕上没有数据了,重新上电也没用。把卡拔下来,插在电脑上居然都发现不了盘。上网查了下,有的说是卡的保护区,固件什么的被整坏了,我了个去,是这么回事吗?
程序代码一直处在下面的while中:
/*!< SD CARD */
/*!< Send ACMD41 SD_APP_OP_COND with Argument 0x80100000 */
/*!< Send ACMD41 再次确认卡的操作电压范围*/
while ((!validvoltage) && (count < SD_MAX_VOLT_TRIAL))
{
/*!< SEND CMD55 APP_CMD with RCA as 0 */
SDIO_CmdInitStructure.SDIO_Argument = 0x00;
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD;
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus = CmdResp1Error(SD_CMD_APP_CMD);
if (errorstatus != SD_OK)
{
return(errorstatus);
}
/*SDIO卡主机广播发送SEND_APP_OP_COND(ACMD41)命令
Asks the accessed card to send its operating condition
register (OCR) con tent in the response on the CMD
line. 发送ACMD41*/
SDIO_CmdInitStructure.SDIO_Argument = SD_VOLTAGE_WINDOW_SD | SDType;
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SD_APP_OP_COND;
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus = CmdResp3Error(); // check for r3 -- OCR
if (errorstatus != SD_OK)
{
Printf("Error: ACMD41: Get SD (OCR) Failed
");
return(errorstatus);
}
response = SDIO_GetResponse(SDIO_RESP1);
validvoltage = (((response >> 31) == 1) ? 1 : 0);
count++;
Printf("ACMD41: Get SD (OCR) Success! validvoltage = %d
", validvoltage );
}
得到的validvoltage值得一直都是0,正常情况下一般只要几次就能通过。
这是什么意思了? 照这样看,用TF卡看来不合适,不宜存放重要数据。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>