can I use sd card pins for something else between writes?

Hi,

(a question I’ve also posted on the Arduino forum)

I’m working on a datalogging project using a Seeeduino Stalker. I’ve got this working fine with the fat16 library from code.google.com/p/fat16lib/. My project involves reading various analog inputs via a couple of multiplexers, displaying the values on an lcd screen and logging to the SD card.

My question is this: Is it possible to use pins 11-13 for something else (for example setting the mux pins) at the times when the SD card is not being written to? I’d basically like to free up a few pins for something else. At present it seems that pins 11 and 12 are active all the time, no matter whether or not the card is actually being written to at the time. What I’d like to achieve is something like:

pin 10 appears to be the card’s CS pin, so something like this seems logical, but various permutations I’ve tried haven’t worked so far:

Does this seem reasonable, or am I completely misunderstanding how the sd card access works? At the moment it seems that pins 10-13 are always tied up by the sd card interface, and unavailable for anything else.
I’ve tried to search for an answer to this, but haven’t had any luck so far - any help much appreciated! I’m new to this and picking it up as I go along.

Thanks very much,
Jo

Seems possible, but how can you know what will happen to the mux pins when pin 11-13 used back for SD card?

I’ve now solved it. Given that the other stuff I wanted to do with these pins didn’t involve the SPI interface, my problem boiled down “how do I turn off the SPI when it’s not in use?”. After an hour or two of searching and experimentation, it can be done like this:

[code]#include <SPI.h>

void setup() {
// do setup stuff here
SPI.end();
}

void loop() {
// do non-SPI stuff here - in my case set my mux bits
SPI.begin();
// do SPI stuff here - open file, write to file, close file, etc
SPI.end();
}[/code]

In my case it doesn’t matter what happens to the mux pins while the SD card stuff is happening, as I’m not taking any readings at that point in time.

Cheers,
Jo