TWR-K70 SDHC get wrong data from SD card

cancel
Showing results for 
Search instead for 
Did you mean: 

TWR-K70 SDHC get wrong data from SD card

203 Views
Contributor II

Hello,

There is an inexplicable issue about K70 SDHC. I am developing SD card driver for K70. But it fails to identify SD card. At the beginning, driver can get correct OCR,CID,RCA,CSD registers from SD card. But it get wrong SCR and data from SD card. I found that the driver can get correct response from SDHC0_CMD line, but get wrong value from SDHC_DAT lines. Pleas help me debug the issue. Thanks.

Hardware environment (4 boards):

    TWR-K70F120M CPU board (700-27166 REV A, SCH-27166 REV C2)

    TWR-SER2 Board (700-26185 REV B, SCH-26185 REV D)

    Primary Elevator (700-26006 REV D, SCH-26006 REV H)

    Secondary Elevator (700-26493 REV B, SCH-26493 REV A)

Pin Control Register setting:
    PORTE_PCR0[0x4004d000] = 0x443 /* portE, pin0, ALT4, SDHC0_D1 */
    PORTE_PCR1[0x4004d004] = 0x443 /* portE, pin1, ALT4, SDHC0_D0 */
    PORTE_PCR2[0x4004d008] = 0x443 /* portE, pin2, ALT4, SDHC0_DCLK */
    PORTE_PCR3[0x4004d00c] = 0x443 /* portE, pin3, ALT4, SDHC0_CMD */
    PORTE_PCR4[0x4004d010] = 0x443 /* portE, pin4, ALT4, SDHC0_D3 */
    PORTE_PCR5[0x4004d014] = 0x443 /* portE, pin5, ALT4, SDHC0_D2 */
    PORTE_PCR28[0x4004d070] = 0x143 /* portE, pin28, ALT1, SDHC0_CD */

Use internal SDMA transfer to read SCR, some SDHC registers setting:

Send CMD55:
    DSADDR = 0x00000000, BLKATTR= 0x00010000
    CMDARG = 0x12340000, XFERTYP= 0x371a0000
    PRSSTAT= 0xff880008, PROCTL = 0x00000020
    SYSCTL = 0x0000010f, WML = 0x08800810

Send CMD51:

    DSADDR = 0x80567450, BLKATTR= 0x00010008
    CMDARG = 0x00000000, XFERTYP= 0x333a0011
    PRSSTAT= 0xff880008, PROCTL = 0x00000020
    SYSCTL = 0x000e010f, WML = 0x08800802
respones =0x00000920 
SCR=0x[33-c0-8e-d0-bc-00], the value may be different at next reading.

Correct SCR should be [02-35-80-00-01-00]. 

Please help analyze the issue is hardware issue (pin setting, jumper?) or software issue. Do you have K70 SDHC driver sample code?

Thanks, 

Miles

Labels (1)
0 Kudos
2 Replies

21 Views
NXP Employee
NXP Employee

Hi,

You can try using MQX 4.2. MQX™ Classic Software Solutions|NXP 

In MQX RTOS is available the (E)SDHC I/O Driver. This I/O driver covers the (e)SDHC peripheral module and provides low-level communication interface for various types of cards including SD, SDHC, SDIO, SDCOMBO, SDHCCOMBO, MMC, and CE-ATA.

After install MQX you can find some example projects that you can use as reference.

Have a nice day!

Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

21 Views
Contributor II

Hi Sol,

I have downloaded MQX 4.2 and found the SDHC sample code located in below folder:

  "\Freescale_MQX_4_2\usb_v2\example\device\msd\kinetis_sdhc"

Is it right? The example code uses PIO mode, does not use DMA mode. PIO mode can work but throughput is too low.

Do you have example code which uses DMA mode?

Thanks,

Miles

0 Kudos