1 将SPI时钟速度调到16M
if (!SD.begin(SS, SPI, 16000000))
{
Serial.println("Card Mount Failed");
return;
}
DSTATUS ff_sd_initialize(uint8_t pdrv)
{
char token;
unsigned int resp;
unsigned int start;
ardu_sdcard_t * card = s_cards[pdrv];
if (!(card->status & STA_NOINIT)) {
return card->status;
}
AcquireSPI card_locked(card, 16000000);
....
char sdCommand(uint8_t pdrv, char cmd, unsigned int arg, unsigned int* resp)
{
...
// Serial.printf("%s.%d : %u. token = %d
","sd_diskio",__LINE__,millis(),token);
if (token == 0xFF) {
log_w("no token received");
sdDeselectCard(pdrv);
sdDeselectCard(pdrv);// 变更此处的延时处理
// delay(1);
sdSelectCard(pdrv);
sdSelectCard(pdrv);
continue;
} else if (token & 0x08) {
log_w("crc error");
sdDeselectCard(pdrv);
sdDeselectCard(pdrv);// 变更此处的延时处理
// delay(1);
sdSelectCard(pdrv);
sdSelectCard(pdrv);
continue;
} else if (token > 1) {
log_w("token error [%u] 0x%x", cmd, token);
break;
}
...
}