Woops, the above has VCC and GND both connected to ground - Instead, connect VCC to the red power rail!
Connect Vcc to the power supply, 3V or 5V is fine. Use the same
voltage that the microcontroller logic is based off of. For most
Arduinos, that is 5V
- Connect GND to common power/data ground
- Connect the SCK pin to the SPI clock pin on your Arduino. We'll be using Digital #13 which is also the hardware SPI pin on an Uno
- Connect the MISO pin to the SPI MISO pin on your Arduino. We'll be using Digital #12 which is also the hardware SPI pin on an Uno.
- Connect the MOSI pin to the SPI MOSI pin on your Arduino. We'll be using Digital #11 which is also the hardware SPI pin on an Uno.
- Connect the CS pin to the SPI CS pin on your Arduino. We'll be using Digital #10 but any pin can be used later
To begin reading and writing data, you will need to download Adafruit_FRAM_SPI from the Arduino Library Manager.
Open up the Arduino Library Manager:
Search for the Adafruit FRAM SPI library and install it
Place the Adafruit_FRAM_SPI library folder your arduinosketchfolder/libraries/ folder.
You may need to create the libraries subfolder if its your first library. Restart the IDE.
We also have a great tutorial on Arduino library installation at:
Open up File->Examples->Adafruit_FRAM_SPI->MB85RS64V and upload to your Arduino wired up to the sensor
The test is fairly simple - It first verifies that the chip has been found. Then it reads the value written to location #0 in the memory, prints that out and write that value + 1 back to location #0. This acts like a restart-meter: every time the board is reset the value goes up one so you can keep track of how many times its been restarted.
Afterwards, the Arduino prints out the value in every location (all 8KB!)
The library we have is simple and easy to use
You can create the FRAM object using software-SPI (each pin can be any I/O) with
Adafruit_FRAM_SPI fram = Adafruit_FRAM_SPI(FRAM_SCK, FRAM_MISO, FRAM_MOSI, FRAM_CS);or use hardware SPI
Adafruit_FRAM_SPI fram = Adafruit_FRAM_SPI(FRAM_CS);which means the other 3 pins are the hardware SPI defined pins for your chip. Check the SPI Reference page for details on which pins are which for your Arduino!
Hardware SPI is faster (the chip can handle up to 20MHz), but you have to use fixed pins. Software SPI is not as fast (maybe 1MHz max on an UNO), but you can switch pins around.
You can initialize the SPI interface and chip with begin()
fram.begin()It will return true or false depending on whether a valid FRAM chip was found
Then to write a value, call
fram.writeEnable(true);to write an 8-bit value to the address location
Later on of course you can also read with
fram.read8(address);which returns a byte reading. For writing, you must enable writing before you send data to the chip, its for safety! However you can write as much as you want between the writeEnable calls
We dont cover how to protect subsections of the FRAM chip. It's covered a bit more inside the Datasheet.
For advanced users, we have two functions to set/get the Status Register. IF you want to set the status register dont forget that WP must be logical high!