-1

Hello I have been working with Arduinos and SD cards recently and I was able to use the SPI pins and a library to retrieve and send data from an SD card using an Arduino. I have been building a transistor computer with some D flip-flops for RAM. I was wondering how I would extract data from a txt file on the sd card with my logic gate transistor computer. I know the pinout for the SPI on the SD card: 1. CS 2. Data In 3. GND 4. 5v 5. clk 6. GND 7. Data out 8. unused 9. unused

So I know how to connect 5v and ground. What I am not sure is what to connect CS, CLK and the data pins to. DO I connect the clk pin to my 555 timer and have it run at the same speed as my logic gate transistor computer? Say I wanted to write "10001001" to the first txt file on the SD card. What would I send to the data pin and CS pins of the SPI/SD card?

  • 1
    Do you know how to implement SPI *without* the SD card? – Ignacio Vazquez-Abrams Jul 27 '16 at 19:26
  • I know certain things like mosi and miso – user2279603 Jul 27 '16 at 19:27
  • what about sclk? –  Jul 27 '16 at 19:28
  • 2
    It doesn't work that way. You would need to build a 'computer' the size of your house using flip-flops & gates to be able to do anything useful with an SD card. – brhans Jul 27 '16 at 19:29
  • You need to implement all of this: http://elm-chan.org/docs/mmc/mmc_e.html ; you need either a small processor or quite a lot of state machines. – pjc50 Jul 27 '16 at 19:32
  • Computers normally don't use SD cards in spi mode, just fyi – Passerby Jul 27 '16 at 19:39
  • It's a hard task you have ahead of you: after you setup SPI between your MCU and the card, you need to identify the card type (SD cards and SDHC ones work differently), then initialize it, and then you can start issuing commands to read/write from/to the card's blocks. If you want to deal with files, you need to also deal with a file-system layer. You will need to extend the init process to deal with the MBR, partitions, then read the file-system cluster size and lots of other complexities. If you want to do that from scratch, study the source code of a library. Search for "elm petit fs". – Marcovecchio Jul 27 '16 at 19:56

1 Answers1

2

So I know how to connect 5v and ground

Not correct, SD card requires 3.3 Volts to work, as 5 Volts will fry them. That includes voltages on control and data pins - so your 5V logic gate transistor computer would require level shifter.

For SPI communication you could implement SPI in hardware or just use 4 GPIOs - 3 outputs and one input. This is usually called "software SPI". Talking to sdcards over SPI is not exactly simple, too.

Turbo J
  • 9,969
  • 1
  • 20
  • 28