LabVIEW Embedded

cancel
Showing results for 
Search instead for 
Did you mean: 

Blackfin BF537 Micro SD via SPI

Hey everyone,

I need some help interfacing a Micro SD card with a Blackfin BF537 EZ-Kit Lite, which I've connected to the board via the SPI port.  Using the example code, I can do some basic I/O with the SPI that I can read on a scope.  At this point, I have a breakout board connected to the appropriate pins, but I don't know how to proceed with executing some read/write commands.  Does anyone know of any VIs that implement SPI protocol to do this?

Thanks for any help you could provide.
0 Kudos
Message 1 of 13
(9,760 Views)
Hello!

I have working code for accessing SD Cards over the SPI port. However this code doesn't work with all cards (I haven't been able to get a SanDisk Ultra II card to work). What exactly do you need (the functionality is included in a large project which I cannot give away, but I could give you some of the SD Card methods - any maybe also the FAT driver).

best regards,
Markus
0 Kudos
Message 2 of 13
(9,746 Views)
Hi guyline,

I assume the example you're referring to is the "SPI and UART.lvproj" found in the NI Example Finder. This gives the structure in which to perform read/write commands and the Blackfin SPI VIs should be enough to implement the SPI protocol. If you're looking for something specific to communicating with a Micro SD card, it looks like Markus can help you out. Are you generally just having some difficulty using the SPI VIs and need some assistance? Thanks.


Message Edited by lion-o on 06-17-2008 07:25 PM
0 Kudos
Message 3 of 13
(9,723 Views)
Hey,

Sorry I haven't responded for a while.  I've been working on some various ideas with varying degrees of success.  I've gotten the card to initialize in SPI mode, but I'm having issues with getting the proper ACMD41 response - I keep getting an improper command error as a result, followed by a series of CRC errors.

Markus:  Could you tell me what SD card you've been working with?  Perhaps working with a different model might help this process out.
0 Kudos
Message 4 of 13
(9,580 Views)
Hi guyline,

Could you attach your code or a screenshot of your code as well as the SD Card your using and any appropriate links. That way we might be able to offer some suggestions to help you get this thing working.
0 Kudos
Message 5 of 13
(9,552 Views)
Hello again!

My code does work with a Kingston 1GB SD Card and a Lexar 256MB SD Card. Except for the not working SanDisk Ultra II 1GB I haven't tested any other cards.

I've my initialization VI attatched. Note that you will need to supply your own SD Send Initial 10 Clocks, SD Send Command, Receive Response, etc. VIs to use this VI.

best regards, Markus
0 Kudos
Message 6 of 13
(9,469 Views)
Hey,

Thanks a lot, Markus!  I got your initialize protocol to work, and I believe that I'm successfully writing to the card.  I haven't been able to get reading to work correctly, but you should be glad to know that everything I've done works so far with the SanDisk Ultra II in MMC protocol - I don't know why it works under that protocol and not SD.



0 Kudos
Message 7 of 13
(9,445 Views)
Great to hear, thanks! I haven't looked at the MMC protocol, maybe I should give it a try...

Do you also have some performance limits far away from SPI & SD speed? Maximum write speed I can get is somewhere around 8kB/sec.

best regards, Markus
0 Kudos
Message 8 of 13
(9,436 Views)
Hi Markus,

I'm also trying to implement SD Card R/W over SPI, and have been somewhat successful.  My problem is that my reads and writes are very slow (I wish I could get 8KB/s speeds!) and I continually lose the connection and have to re-init.  I was wondering if you could let me know what parameters you are using to open and configure the SPI port?  I am setting "Set Dataflow Method" to 2, "Set Master" to 1, "Set Clock Phase" to 0, and "Set Clock Polarity" to 0.  I notice that you are using Phase and Polarity of 1, but I can't even get the SD Card to respond when I do this.  I also can't get speeds of more than 1MHz, nevermind the 10MHz you seem to be getting.

Thanks for any help you can provide!

Jason
0 Kudos
Message 9 of 13
(9,404 Views)
I'm initializing the SPI with:

* Set Transfer Init Mode = 1
* Set Baud Rate = 400000 (for SD-Card initialization, 25 MHz for SD-Card operation)
* Set Clock Phase = 1
* Set Clock Polarity = 1 (SD-Cards should only work in 0/0 or 1/1, which may depend on the hardware interface)
* Set LSB First = 0
* Set Word Size = 8
* Send Zeros = 0
* Set Master = 1

It is running in bidirectional interrupt mode, and dataflow method is set to 2.

If you can't get more than 1 MHz SPI clock, you should check the signals on the SD-Card. If they aren't clean, you will get performance or CRC problems.

Also note that I have deactivated the CRC checks on the SD-Card. For the commands you only need a valid CRC for CMD0, further commands are not checked for CRC per default (at least by the cards that work for me). I had CRC for data blocks activated, but the CRC calculation was *very* slow (somewhere around 500ms per 512 byte block) so I removed it for performance reasons.
0 Kudos
Message 10 of 13
(9,396 Views)