I really like the idea of having extra memory because I am currently struggling with limited SRAM on the Spark Core. However the proposed solution of using some of the IO pins to interface to the external memory is not feasible for me because they are already in use.
Could it be possible to add an extra memory chip on top the flash chip on the Spark Core itself, e.g. the one proposed by @timb: Fujitsu MB85RS1MT (FRAM)?
I know it is not nice solution but maybe it is doable and helps me for the short term. I donât have experience with the SPI interface so I wonder how to do the address selection (CS) of the MB85RS1MT in this case.
@kennethlimcp, does your solution requires connection towards other IO pins of the Spark Core?
If that is the case then it is not feasible for me because i only have one IO pin left over.
nika8991 & kennethlimcp, timb is working on an shield that has both FRAM and microSD:
However, nika8991, multiple SPI devices need separate chip select lines no matter what. Perhaps you need to consider using an I2C I/O expander to regain some pins.
i guess he has too much on his plate? Iâm just gonna go ahead and make mine as a learning project for me to make an actual working PCB that i can really use on the core
Mineâs gonna be MicroSD + 2-3 slots for FRAM.
Iâm actually working on the list of stuff i need to buy as a batch and at the same time fabricate the prototype board with some in-house facilities
Targeting to have it working by end of April latest!
My SPI lines are connected correctly and power is stable. But I fond some interesting problem from my side.
When youâll use too long filename thenSD library is unable to read/write on SD card. For example: âmyawesomeofflinedata.logâ failes, but when youâll short name âmy.logâ then it works like a charm. If yourâre unable to reproduction situation then I can send a code example privately.
Also, is it possible to get free size of SD card? Currently is possible to get whole SD card size.
I donât know about this library but on Arduino, the standard SD library only works with the old DOS standard 8.3 files names. There is another library that extends that called LongNames.
markoâpraakli, bko is correct. The SD library only handles DOS 8.3 filenames. Part of the reason for this is that Microsoft is known to hold the patent on long filenames so libraries typically avoid potential conflicts by not including support for them. Support for long file names also consumes more resources.
I hesitate to ask this here as it seems this thread has gotten more into the new shield, but I am having some issues with the library that BDub ported. ( I am flashing through the webIDE, btw)
First off, I canât seem to change the SS to any other Analog. I have tried A0 and A1 and the both give me initialization errors.
When I do use A2, however, I am unable to do any reads or writes. I can init the card, print out info from it and even list all of the files, but file open seems to just fail. I have tried two cards to no avail. Has anyone seriously used this lib on the spark and if soâŚhow?
I initially ported all of the examples and tested them all, and then @peekay123 added the soft SPI implementation. It should play well along side the hard SPI but maybe there is a problem with it. Try to go back to the last commit and see if it works any better please
Whelp, never mind. I should get some sleep. Copypasta issue ignoring that the examples use different classes for the file objects(File and SdFile). Also, forgot to set the SS pin as output manually before trying to init SPI with that as SS. Thanks for the help guys!
BDub, I tested the library extensively with both software and hardware SPI and I found no problems whatsoever. When used in hardware SPI mode, it functions as if no software SPI code was added. I am perplexed at billprozacâs problem with the SS line.
kennethlimcp, I think you meant SD.begin(A0), not Serial.begin(A0)!
billprozac, which example program are you running? The examples are using the default pin settings for the SPI, including using A2 as SS. I will be adding a new speed test example that allows the selection of either software or hardware SPI and the pins associated with each. In the meantime, letâs try to figure out what is causing problems in your situation.
Looks like he just didnât define the pinMode(A0,OUTPUT); Iâm not sure why the A2 didnât work though. The Spark code sets that output up for you. All is well now I guess though Thanks for the reply peekay!
Sorry for all of the confusion. I started with the SDInfo which worked fine, so I added the file read and write from the example, not noticing that the File objects from the read/write use File, and the root file object in the info example uses SdFile. Once I realized this, I created a File object from the SdFile and it all works.
Regarding the SS issue above, I think I clearly documented the insane idiocy on my part of not setting the A0 pin to output, thus not allowing the SDCard the use that Analog as SS. It might be worth adding a comment to the examples that shows using some non-hw SS for those of us that are a little denser
I basically combined the Info and read/write example into the following:
/*
SD card test
This example shows how use the utility libraries on which the'
SD library is based in order to get info about your SD card.
Very useful for testing a card when you're not sure whether its working or not.
The circuit:
* SD card attached to SPI bus as follows:
Refer to "libraries/SdFat/Sd2Card_config.h"
created 28 Mar 2011
by Limor Fried
modified 16 Mar 2011
by Tom Igoe
modified for Maple(STM32 micros)/libmaple
17 Mar 2012
by dinau
*/
// include the SD library:
#include "application.h"
#include "SD.h"
// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;
// change this to match your SD shield or module;
const int chipSelect = A0; // Using a pin other than the hardware SS
void error(const char* str)
{
Serial.print("error: ");
Serial.println(str);
if (card.errorCode()) {
Serial.print("SD error: ");
Serial.print(card.errorCode(), HEX);
Serial.print(',');
Serial.println(card.errorData(), HEX);
}
while(1) {
SPARK_WLAN_Loop();
};
}
void setup()
{
Serial.begin(115200);
//Init new SS pin
pinMode(chipSelect, OUTPUT);
while (!Serial.available()) SPARK_WLAN_Loop();
while (Serial.available()) Serial.read();
Serial.print("\nInitializing SD card...");
if (!card.init(SPI_FULL_SPEED)) error("card.init failed");
// initialize a FAT volume
if (!volume.init(&card)) error("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
Serial.print("Type is FAT");
Serial.println(volume.fatType(), DEC);
uint32_t volumesize;
volumesize = volume.blocksPerCluster(); // clusters are collections of blocks
volumesize *= volume.clusterCount(); // we'll have a lot of clusters
volumesize *= 512; // SD card blocks are always 512 bytes
Serial.print("Volume size (bytes): ");
Serial.println(volumesize);
Serial.print("Volume size (Kbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
Serial.print("Volume size (Mbytes): ");
volumesize /= 1024;
Serial.println(volumesize);
if (!root.openRoot(&volume)) error("openRoot failed");
}
void loop(void) {
uint32_t t;
double r;
Serial.println("Type any character to start");
while (!Serial.available()) SPARK_WLAN_Loop();
while (Serial.available()) Serial.read();
if (!file.open(&root, "boo.txt", O_CREAT | O_TRUNC | O_RDWR)) {
error("open failed");
}
File myFile(file, "boo.txt");
if (myFile){
Serial.print("Writing to boo.txt...");
myFile.println("w00t!");
Serial.println("done.");
Serial.println("Reading boo.txt:");
myFile.seek(0);
// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
}
file.close();
}