Using SD cards with microcontrollers; where to find good inf

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
Post Reply
User avatar
eekee
Member
Member
Posts: 891
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Using SD cards with microcontrollers; where to find good inf

Post by eekee »

I want to hook up an SD card to a BBC micro:bit. (It's a tiny ARM microcontroller.) Our wiki links this OpenLab Pro page which seems to have most of the info, but has a Valles Marineris size hole in the most crucial bit of info a hardware hacker needs: which pin is which? It gives perfectly good pinout tables for SD cards, and it has nicely-written descriptions on how to connect and use them, but uses completely different pin names for each of these things. The pinouts show the data lines as DAT0 to DAT3, the descriptions exclusively refer to MISO and MOSI. The descriptions talk about the CS (chip select) line, but there is no such acronym in the pinouts. Etc, etc. I could make some guesses, but would prefer not to risk my devices over such a terrible omission in a free tutorial.

If anyone knows a forum where I can ask about this sort of thing, I'd be grateful. Actual info on the topic would be nice too, if anyone here happens to know.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Using SD cards with microcontrollers; where to find good

Post by Octocontrabass »

That page is explaining how to interface with SD cards using SPI, so you should be looking at the SPI column for the pinout, not the SD column.

I'm not sure why the article mixes names for the pins, but MISO refers to microcontroller input / SD card output, and MOSI refers to microcontroller output / SD card input. In the pinouts, you can see the SD card's DO and DI pins, which are its data output and input pins, respectively.

You may also find these specification documents useful. (If you need the full specification, you can probably "borrow" a copy using your favorite search engine.)
Cyao
Member
Member
Posts: 78
Joined: Tue Jun 07, 2022 11:23 am
Libera.chat IRC: Cyao
Location: France
Contact:

Re: Using SD cards with microcontrollers; where to find good

Post by Cyao »

I've got this good article about SDcards http://elm-chan.org/docs/mmc/mmc_e.html, its covers almost everything used to do read and writes. For the full list of commands, just look in the specs that Octocontrabass gove you :)
User avatar
eekee
Member
Member
Posts: 891
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Using SD cards with microcontrollers; where to find good

Post by eekee »

Octocontrabass wrote:That page is explaining how to interface with SD cards using SPI, so you should be looking at the SPI column for the pinout, not the SD column.
I'm afflicted with a strange sort of blindness sometimes; I actually didn't see the SPI column despite looking several times. At least I've got an explanation now. I've recently found my health problems match the symptoms of cerebral hypoxia. One of the symptoms is a difficulty learning complex tasks, and that's exactly what I have. Once information is in my brain, I can use it fairly well on a good day, but my ability to take in new information is throttled.

Thanks for the explanation. Now I know it's there, I should be able to get on with it all right, for the most part. Most of what I'm trying to do isn't too complex. I'm just compiling pforth (which is written in C) with the microcontroller's standard runtime which has a ridiculously large feature set. It just lacks anything to do with mass storage and display. I guess I'll probably embarrass myself again at some point, probably when looking at the documentation for my little screen. I'll try to do it without snark next time, but I said that last time. Different issue; this one is changing a long-standing habit. It's amazing how easy it is to create snark when I'm too unwell to even read properly. Recognizing and processing new information must really use a lot of the brain's processing power.
Octocontrabass wrote:I'm not sure why the article mixes names for the pins, but MISO refers to microcontroller input / SD card output, and MOSI refers to microcontroller output / SD card input. In the pinouts, you can see the SD card's DO and DI pins, which are its data output and input pins, respectively.
Thanks. Good to have confirmation on that.

Thanks for the links too, both of you.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
Post Reply