Using SST26VF064B as a flash memory/buffer for an arduino?

Hello. For my aruino project I have an arduino that is controlled by a desktop application on a computer via the serial port. The application needs to send about 1-3 MB worth of commands for control, which need to be saved and after that executed one by one from the arduino. That's why I got the SST26VF064B serial flash memory (8MB in size). First, this is a 3.3v SPI chip so I will need a level shifer to shift 5v to 3.3v (right?). Is there a library which I can use to read/write bytes on this thing? All I found was this : https://github.com/LowPowerLab/SPIFlash . Can this work with it or can you recommend something else? Also, another problem is that on my arduino (UNO) I'm using all but 3 digital pins (pins for hardware serial and 9 more are used), and SPI requires 4 pins. Since I will only have one slave connected to the master, do I really need a SS pin? Can I drop it out since I don't have enough pins available on the board?

Yes, you can usually hardwire the chip's CS to ground. But that doesn't work for all. A memory chip may need CS to go high to indicate the end of a write.

If you have any other sensors using SPI then you can put them on the same data and clock pins.

Note that external memory cannot hold code, only the internal flash memory can. If you want to store command sequences, you need an interpreter for these commands.

If you already are short on pins, consider to use a bigger board (Mega...), or to spread your program onto multiple controllers. It's easier to write code for time-critical applications, when the controller has not to do many other things at the same time.

DrDiettrich: Note that external memory cannot hold code, only the internal flash memory can. If you want to store command sequences, you need an interpreter for these commands.

I didn't mean directly code, but rather my own type of commands that are a few bytes, which when read by the arduino instruct it on doing a said action with the connected peripherals.

MorganS: Yes, you can usually hardwire the chip's CS to ground. But that doesn't work for all. A memory chip may need CS to go high to indicate the end of a write.

If you have any other sensors using SPI then you can put them on the same data and clock pins.

I don't use SPI anywhere else on my board now. I will try to use one pin that is connected to 2 things while not using both of them at once.

Anyways, I have a spare arduino to test out the chip and see if it works. Unfortunately, I haven't been able to make a successful read/write action to it. I've tried with these 2 libraries: https://github.com/LowPowerLab/SPIFlash and http://www.rinkydinkelectronics.com/library.php?id=65

Yet both of them fail to extract the manufacturer ID from the chip. The documentation of the chip is here: http://ww1.microchip.com/downloads/en/DeviceDoc/20005119G.pdf

I have wired up the following pins from the chip to the arduino. Chip pin 1 (CE) -> Arduino pin 9, pin 2 (SO) -> arduino pin 12, pin 6 (SCK) -> arduino pin 13, pin 5 (SI) -> arduino pin 11. All of the connections (except the SO pin from the chip) are going trough a 5 -> 3.3v level shifter to safely lower the arduino's 5v signal to the chip-friendly 3.3v. The schematic of the level shifter, if you're wondering, can be found here: http://www.incrediblediy.com/2013/02/simple-33v5v-level-shifter.html (SO pin from the chip gets shifted from 3.3v to 5v from the second schematic on the link).

The program which I'm running from the arduino to connect to the flash chip is the pure examples of the libraries I said above (with modifying some values based on my pin setup). What did I possibly get wrong so that I can't read/write/extract manufacturing id from the flash?

Taking a deeper look it seems that I have forgot to ground the WP (wire protect) pin and connect the HOLD pin to + 3.3v. Yet that didn't seem to help and the arduino is still failing to do anything with the chip. Any ideas? I could just get the SST25 cip instead of the SST26 which I have right now, because there are already libraries that are said to work with that exact chip. The problem is that the shipping will take time which I cannot waste.

Why would you choose pin 9 for SO? Serial Out from the chip should always go to the SPI MISO pin.

Those SPI pins are special. You must arrange your schematic to use them, no alternatives.

KingOfAllChunks: I have wired up the following pins from the chip to the arduino. Chip pin 1 (CE) -> Arduino pin 9, pin 2 (SO) -> arduino pin 12, ...

What I said might be easy to misunderstand, sorry. Chip pin 2 which is Serial output connects to arduino pin 12, not 9. Pin 12 for UNO is MISO. I use arduino pin 9 for chip enable (SS) of the flash chip.

That looks like a complex chip on the datasheet. It's a little more work than a simple SPI interface but it should not be too difficult. All I can suggest is following the datasheet and trying to get the simplest possible version working - can you get it to read out its ID or lock bits?

MorganS: That looks like a complex chip on the datasheet. It's a little more work than a simple SPI interface but it should not be too difficult. All I can suggest is following the datasheet and trying to get the simplest possible version working - can you get it to read out its ID or lock bits?

What can it possibly require other than SPI? I've been trying to read the ID constantly. Yet always failing. When I took out an oscilloscope to measure if any signals actually get in and out of the chip I found out something rather strange. The actual MOSI signals are very different depending on the library used for flash chips. When using https://github.com/LowPowerLab/SPIFlash, I can see very small signals in length that are send to the chip (that go from 0v to negative 0.1v in range). This is in no way normal and no wonder that the chip doesnt respond with anything. However, when trying with http://www.rinkydinkelectronics.com/library.php?id=65, there are no signals at all. The MOSI pin gets pulled high for 0.5s and back low again (0v-5v). These measurements are all taken when trying to extract the manufacturer ID, using the exact same examples as provided by the libraries (with chaining the SS pin to match with mine). I'm starting to think that there might not be a problem on a hardware level but rather on a software one. However, since I don't have the knowledge to make my own library or directly control the chip, I'm left with what is already made for this or a similar chip. Can you recommend another library that should work or something else that might help me get this chip going.

The standard SPI library that comes with your Arduino should be sufficient to test the chip. Post your code (and any new oscilloscope results) and we can fix it.

MorganS: The standard SPI library that comes with your Arduino should be sufficient to test the chip. Post your code (and any new oscilloscope results) and we can fix it.

Well I don't know what exactly to send trough SPI. I have never used SPI before. I looked in the chip documentation but couldn't see SPI commands.

Figure 5-29 in the datasheet shows the simplest read command for reading the status register. Just SPI.write(5); and then the next byte you read will be the status register.