AnsweredAssumed Answered

SD_ReadBlock weird behaviour

Question asked by Wapers on Dec 30, 2013
Latest reply on Dec 30, 2013 by Wapers
Hello Community,

I am trying to implement FatFS via SDIO interface on a STM32F2xx uC, I've checked a few examples online that use DMA and interrupts, however for the purpose of self learning and simplicity I have decided to implement my own using SDIO polling mode, I will later move on implementing the rest.

I am using a lot of functions from stm32f2xx_eval_sdio.c of the Standard Peripheral Library. The initialization part works ok, I can read the CID and CSD registers and print out the capacity of the SD used, the only part that seems to fail is enabling four bit mode, as if I enable it, a transmission causes an Start Bit error on the interface, indicating that one of the D0-D3 lines didn't transmit an start bit. To avoid this, I commented the function that enables the bus wide mode and I am working on 1 bit mode.

The main problem I have is the SD_ReadBlock function. I use a Disk Editor (HxD) tool in order to check that the boot sector on the uSD card is ok, when I try to read the sector on my card by using this code:

SD_Card Status = SD_OK;
uint8_t Buffer[512];
 
memset(Buffer, 0xD0, sizeof(Buffer)); // 0xD0 so I can notice those bytes changes.
 
Status = SD_ReadBlock(Buffer, 0, 512);

Buffer contains 447 zeros, some more data that is not the same I see on the Disk Editor, another bunch of zeros and finally at offset 510d 0x55AA.

FatFs succeeds to verify the bytes at offset 510, 0x55AA, but it fails to verify the Fat File System string as the buffer always contains zeroes there, therefore FatFs doesn't detect a valid FAT file system on the SD card.

The uC is working at 60MHz and the SDIO clock is enabled, per the Configuration Tool 1.2.0 xls file.

Outcomes