sknoogleplex
New Member
I'm using an LPC2148 and trying to interface it with a (non-HC) SD card. Specifically, I'm using this Olimex board.
The summary of my problem is that the card only responds with 0xff.
I've been using the demo code from **broken link removed**, **broken link removed**, and have been heavily reading NXP's Accessing SD/MMC card using SPI on LPC2000 along with manuals on SD. I can compile and run jcwren's code on my board, but either it doesn't work, or I'm not sure about exactly what commands will access the sd card. (A "file mount" and then "file ls" locks up the board using his code.) The SD card works fine with a PC card reader. I'm a grad student working on a project that I need to finish in a few months. I've been stuck on this same problem for about 20 hours and am at that point where I don't know what else to try.
Does anyone know of any reasons why I might only be getting 0xff responses or have references to any code that I could reasonably use from my linux (gcc etc.) environment, i.e. compile a .hex file, and upload it to my board to do _something_ with the sd card? (Reading or writing any byte anywhere, is fine.)
To clarify, here's what my code is doing (as far as I can tell):
-Setting pins 0.17, 0.18, and 0.19 to use the SSP (SCLK, MISO, and MOSI)
-Pulling pin 0.20, CS high.
-Setting the SPI clock to run at about 400 KHz
-Turning on SSP master mode
-Writing out 8 0xff bytes to SSPDR
-Waiting almost a second (in some tests)
-Reading 8 bytes out from SSPDR
-Pulling CS down. (Clearing pin 0.20)
-Waiting about another second (again, in some tests)
-Sending CMD0 (idle/reset) to the card (0x40, 0x00, 0x00, 0x00, 0x00, 0x95)
>>>Looping through the 6 bytes in order
>>>Make sure Tx buffer is not full and SPI is not busy
>>>Write the byte
>>>Wait until receive buffer has something
>>>Read receive buffer
-Waiting another second (in some tests)
-Loop forever
>>>Write an 0xff byte
>>>Read receive buffer
>>>(print the read value out - it's always 0xff)
My code is pretty ugly right now and all assembly (this is necessary eventually although I'd be extremely happy to have something working in c too - I just need to diagnose the problem), but if someone really wants to see it, I can clean it up and post a link.
Any help is _very_ appreciated. Thanks.
Ryan
The summary of my problem is that the card only responds with 0xff.
I've been using the demo code from **broken link removed**, **broken link removed**, and have been heavily reading NXP's Accessing SD/MMC card using SPI on LPC2000 along with manuals on SD. I can compile and run jcwren's code on my board, but either it doesn't work, or I'm not sure about exactly what commands will access the sd card. (A "file mount" and then "file ls" locks up the board using his code.) The SD card works fine with a PC card reader. I'm a grad student working on a project that I need to finish in a few months. I've been stuck on this same problem for about 20 hours and am at that point where I don't know what else to try.
Does anyone know of any reasons why I might only be getting 0xff responses or have references to any code that I could reasonably use from my linux (gcc etc.) environment, i.e. compile a .hex file, and upload it to my board to do _something_ with the sd card? (Reading or writing any byte anywhere, is fine.)
To clarify, here's what my code is doing (as far as I can tell):
-Setting pins 0.17, 0.18, and 0.19 to use the SSP (SCLK, MISO, and MOSI)
-Pulling pin 0.20, CS high.
-Setting the SPI clock to run at about 400 KHz
-Turning on SSP master mode
-Writing out 8 0xff bytes to SSPDR
-Waiting almost a second (in some tests)
-Reading 8 bytes out from SSPDR
-Pulling CS down. (Clearing pin 0.20)
-Waiting about another second (again, in some tests)
-Sending CMD0 (idle/reset) to the card (0x40, 0x00, 0x00, 0x00, 0x00, 0x95)
>>>Looping through the 6 bytes in order
>>>Make sure Tx buffer is not full and SPI is not busy
>>>Write the byte
>>>Wait until receive buffer has something
>>>Read receive buffer
-Waiting another second (in some tests)
-Loop forever
>>>Write an 0xff byte
>>>Read receive buffer
>>>(print the read value out - it's always 0xff)
My code is pretty ugly right now and all assembly (this is necessary eventually although I'd be extremely happy to have something working in c too - I just need to diagnose the problem), but if someone really wants to see it, I can clean it up and post a link.
Any help is _very_ appreciated. Thanks.
Ryan