Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

How to initialize SD-Card with SPI Command?

Hi, I implemented the Altera SPI Core in my SoPC. Altera provides one access routine "alt_avalon_spi_command()". How exactly can I implement the typical SD-Card Initialization in my Code?

Altera SPI Core: http://www.altera.com/literature/ug/ug_embedded_ip.pdf Chapter 8-8

I thought the process of initialization is:

1. set cs = low

2. send cmd0 to slave

3. wait for response

How can I use the access routie of Altera in Eclipse. Please give an advice. I am stuck on this problem.

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I was able to solve the problem. But now, when I try to read the MBR. I am only able to read the first 4-5 bytes of MBR. The other bytes are all 0xff.

    Could it be due to the speed of the SPI? The SPI speed is 200 KHz. I don't change the speed value at any time. I know that 400 KHz is max speed when initializing the SD Card. After initializing the SD Card, the SPI speed can be set (up to 25 MHz i guess)

    I don't know what else I can try to solve this problem. I would appreciate your help :)