Ich versuche gerade die CID der MMC auszulesen (sd_mmc_spi_get_cid()) und bekomme lauter 0x00 zurück. sd_mmc_spi_get_csd() liefert dagegen ein einwandfreies Ergebnis. Ich frag mich: ist das ein Fehler im Framework oder werden die CSDs und CIDs nicht immer vom Hersteller gesetzt? Da ich vier versch. Karten mit demselben Ergebnis (CID) habe, tippe ich eher auf das erste. µC: AVR32 UC3A Framework: UC3A Software-Framework 1.4.0. Karte Nr.1 XMore 1GB - keine CID: 16 x 0x00 - CSD: OK Karte Nr.2 Fujuitsu 256MB - keine CID: 16 x 0x00 - CSD: OK Karte Nr.3 Sandisk 128MB - keine CID: 16 x 0x00 - keine CSD: 16 x 0x00 Karte Nr.4 Panansonic 16MB - keine CID: 16 x 0x00 - keine CSD: 16 x 0x00
Bin jetzt einen halben Schritt weiter. die Fkt. wird an der Stelle -->
verlassen. Jemand eine Idee?
Bool sd_mmc_spi_get_cid(U8 *buffer)
{
U8 retry;
unsigned short data_read;
// wait for MMC not busy
if (KO == sd_mmc_spi_wait_not_busy())
return KO;
spi_unselectChip(SD_MMC_SPI, SD_MMC_SPI_NPCS); // select SD_MMC_SPI
// issue command
r1 = sd_mmc_spi_command(MMC_SEND_CID, 0);
// check for valid response
if(r1 != 0x00)
{
spi_unselectChip(SD_MMC_SPI, SD_MMC_SPI_NPCS); // unselect
SD_MMC_SPI
sd_mmc_spi_init_done = FALSE;
--> return KO;
}
// wait for data block start
retry = 0;
while((r2 = sd_mmc_spi_send_and_read(0xFF)) != MMC_STARTBLOCK_READ)
{
if (retry > 8)
{
spi_unselectChip(SD_MMC_SPI, SD_MMC_SPI_NPCS); // unselect
SD_MMC_SPI
return KO;
}
retry++;
}
// store valid data block
for (retry = 0; retry <16; retry++)
{
spi_write(SD_MMC_SPI,0xFF);
spi_read(SD_MMC_SPI,&data_read);
buffer[retry] = data_read;
}
spi_write(SD_MMC_SPI,0xFF); // load CRC (not used)
spi_write(SD_MMC_SPI,0xFF);
spi_write(SD_MMC_SPI,0xFF); // give clock again to end transaction
spi_unselectChip(SD_MMC_SPI, SD_MMC_SPI_NPCS); // unselect SD_MMC_SPI
return OK;
}
U8 sd_mmc_spi_command(U8 command, U32 arg)
{
U8 retry;
spi_write(SD_MMC_SPI,0xFF); // write dummy byte
spi_write(SD_MMC_SPI,command | 0x40); // send command
spi_write(SD_MMC_SPI,arg>>24); // send parameter
spi_write(SD_MMC_SPI,arg>>16);
spi_write(SD_MMC_SPI,arg>>8 );
spi_write(SD_MMC_SPI,arg );
spi_write(SD_MMC_SPI,0x95); // correct CRC for first
command in SPI (CMD0)
// after, the CRC is ignored
// end command
// wait for response
// if more than 8 retries, card has timed-out and return the received
0xFF
retry = 0;
r1 = 0xFF;
while((r1 = sd_mmc_spi_send_and_read(0xFF)) == 0xFF)
{
retry++;
if(retry > 10) break;
}
return r1;
}
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.