Hello forum, its good to be here. Im currently looking forward to using an spi flash for csv file storage as a migration from using SD cards, however its been tough for me to find any related resources. Im currently using winbond 25Q64FVSIG or GD25Q16C interfaced with ATMEGA328P and both are currently responding to storing strings and floats. Any resources or help/advise will be of great help.
Thank you
Are you storing these values directly in the SPI FLASH or have you got a file system on there?
Your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem
currently im storing them directly, however what i want is to have a file system to store the values on csv file
I have used:
with Winbond devices on an UNO. If you are creating a file for writing, then you need to "pre-create" it with it's maximum size (or greater).
Pauls docs say:
Performance oriented design does impose some usage limitations. Files are created with a fixed size which can never change or grow. Once created, files can not be renamed or deleted (except for erasing the entire chip).
You can then use standard fopen, fclose etc and write your CSV formatted text to files as you wish.
Well noted, currently trying it out
Hello @markd833, i managed to use the library as suggested. However theres a problem i noticed; when i tried to create and then delete files,i reached a point when i cannot create a file any more and this may be due to not enough space on the SPIFlash. Where does the problem come from? is the problem the library or thats how the SPIFlash behaves.
Thanks
That sounds right for that library. There is a limitation hinted at in my post #5 above. Once you create a file (and declare the maximum size of the file), all that space is allocated on the flash chip for that file in one go. Each file you create reserves another chunk of space on the flash chip and so on until you eventually run out of space.
You can "erase" a file, which basically sets the contents of the whole file to the default value of 0xFF, but it will still occupy the same space on the flash chip.
The only way to reset everything as it were, is to erase the chip with the erase() function.
Your Winbond 25Q64FVSIG should have 8MBytes of storage available. That should be plenty for most applications. It may be the way you are storing the data that's contributing to the problem.
You mentioned CSV files, are you creating a new file each time your 328P powers up?
The library clearly states that you cannot delete files, recovering the space, except by erasing the entire chip. You can erase all the data in a file, if it has been created as "erasable".
True, i was creating new files in a while loop and i realized this later. Also i tried to erase the flash and everything came back to normal, thanks for the explanation for it made sense.
However, as im trying to read the strings i stored on the file on a flash ic, the output of my buffer seems to be empty. Below is my snipet;
/************* Sample of the code snipet ********************/
char buffer[256]; //stores content to be read from the file
checkForSPIFlash(); //this chip selects the spiflash
file = SerialFlash.open("data.csv"); //open the csv file
if(file){
file.write("Hello from the arduino forum",256);
file.read(buffer,256);
Serial.println(buffer);
}else{
Serial.println("File Does not exist");
}
To be more specific the data.csv file already exists on the spiflash ic
I would hazard a guess that when you open the file, the file pointer is pointing to the start of the file. When you write your string , the file pointer advances to the end of what you have written.
When you then do your read, you are reading from the current file pointer position - i.e. the first byte after the data just written. That will likely return a bunch of 0xFF's - the default erased value.
If you want to read back what you have written, then you should be able to use the seek() function to reposition the file pointer back to the start of the file.
Maybe try:
file.write("Hello from the arduino forum",256);
file.seek(0);
file.read(buffer,256);
Thanks much for this help, i managed to get all the answers i needed for now.
It finally worked as i required
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.