┬ÁTasker Forum > NXPTM LPC2XXX and LPC17XX

SD card: Boot sector not readable

(1/3) > >>


I am just trying to adapt parts of mass_storage.c from version 8 to my project (derived from version 4, LPC2468).
The SD card I am using is a Kingston SDHC 4GB class 4 card.
MCIClk has been raised to 18MHz. The card shall run in 4-bit-mode, no DMA so far.

The problem is that the bootsector cannot be read.
In _fnGetSector() the condition
    (MCIStatus & RxDataAvailbl)
never is met, which results in an infinite loop.

The SDHC card has been formatted (FAT32) by WINDOWS, hence it has no password and is not locked I should think.

The initialisation phase is passed without obvious problems.

Coming to Cmd16, I found that the command array is
static const unsigned char ucSET_BLOCK_LENGTH_CMD16[5]  = {SET_BLOCKLEN_CMD16, 0x00, 0x02, 0x00, 0x02};
It seems that the block size here is >512 bytes which results in setting the BLOCK_LEN_ERROR bit.
But as SDHC cards always use a block size of 512 bytes this may not be important.

READ_SINGLE_BLOCK_CMD17 is passed with ucresult==0.
But with the following function
the infinite loop in _fnGetSector() is reached.

Can anybody thing of a reason why the boot sector cannot be read?


HI Martin

Have you tried with slower speed to see whether the problem is the same?

In my code I found

while ((MCIStatus & (DataEnd | RxDataAvailbl)) != DataEnd) {        // while data is still being received

which looks to be the loop that you are referring to. Is your loop different?



Hi Mark,

yes, that is the loop.
Independently of whether SD_CONTROLLER_DMA is defined or not it comes to an infinite loop in _fnGetSector().
Either at

--- Code: ---    while (!(MCIStatus & DataEnd)) {    // wait until the DMA has completed the transfer to the destination buffer
--- End code ---
or at

--- Code: ---    while ((MCIStatus & (DataEnd | RxDataAvailbl)) != DataEnd) {         // while data is still being received
--- End code ---

The reason for that is that I had changed initialization in SET_SPI_SD_INTERFACE_FULL_SPEED().
I had NOT set the MCI_CLK_PwrSave bit for register MCIClock and this caused the malfunction.
That is a little bit annoying because MCICLK (18MHz) is needed as a masterclock in the project and setting the bit means that clock output is only enabled when the bus is active.
Is there a chance to have the clock output always enabled and nevertheless access the SD card?



Hi Martin

I don't see any restrictions as to allowing the MCICLK to be output all of the time (not setting the power save bit) - also I found no errata concerning this signal.

It should be optional whether the clock is output all the time or is only output when the bus is in use and I would expect that it should be able to operate like this.

Furthermore I understand that the MCIStatus would operate irrespective of whether the clock is being output (or connected) since the output clock is used by the external card and not by the internal controller.

Are you sure that there can't be another explanation for this?



Hi Mark

no, I am not sure, but I did not find another explanation so far.
Until I have found one, I am afraid I will have to toggle the bit.



[0] Message Index

[#] Next page

Go to full version