Topic: a newbie Q: can I use sd card pins for something else between writes? (Read 3216 times)previous topic - next topic

Josephiah

I'm working on a datalogging project using a Seeeduino Stalker (basically a clone with a microSD on-board, using the SPI interface over pins 10-13). I've got this working fine with the fat16 library from http://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:

Does this seem reasonable, or am I completely misunderstanding how the sd card access works?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.

Yes, with SPI you will share the clock, MOSI, and MISO pins between devices, with the seperate Chip Select lines determining which devices do something with the data going out (MOSI) or if the devices will send something back (MISO).

Josephiah

Thanks CrossRoads. After a little more digging around, I think my problem boils down to finding a "SD card interface - STOP TALKING!" command - so time for some perusal of the fat16 documentation. Will report back if/when I find what I want.

Do you mean how many things can you connect to the clock, MOSI, and MISO lines at the same time?That will depend on how far apart they are, what kind of current load they present to the atmega's output driver, etc.,how fast you are trying to communicate (the SPI mode can be varied for different speeds), and how connected (one long daisy chain?).

Josephiah

In my case I want to do something with the pins that doesn't use SPI (i.e. just bog-standard digitalWrites to control my mux inputs), in between the times when I access the SD card. At the moment I can't seem to do anything at all with those pins - any digitalWrites are just ignored.

So how do I disable the SPI interface from using pins 11-13 when it's not actually accessing the card?

I've been wading through the playground, the forum, and the fat16 documentation, but to no avail. Any ideas?

"In my case I want to do something with the pins that doesn't use SPI (i.e. just bog-standard digitalWrites to control my mux inputs), in between the times when I access the SD card."When you turn SPI back on, will you use the SPI chip select to let the mux know the signals are not to be used?Perhaps run CS thru an inverter - when CS goes Low for SPI, the inverted CS will keep the mux deseleced, and when CS is High for SPI the inverted CS will be Low, enabling the mux.Or, AND the inverted CS with your MUX enable signal.

Josephiah

Nice idea - and I would use it except that I'm severely limited in the components I have or can get hold of (I'm working at a hospital in northern Pakistan just now - the system is for monitoring a solar water heater system I'm working on).

For this set up it doesn't matter, as the mux settings are only important at the times I take the readings - I'm not so worried about what they do in between.