You can easily wire this breakout to any microcontroller, we'll be using a Metro
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!