FRAM SPI using MB85RS128A

I am currently having trouble with reading and writing on FRAM using SPI.
I am using Adafruit_FRAM_SPI library.
This is my code below :

#include <SPI.h>
#include "Adafruit_FRAM_SPI.h"

/* Example code for the Adafruit SPI FRAM breakout */
uint8_t FRAM_CS = 10;

//Adafruit_FRAM_SPI fram = Adafruit_FRAM_SPI(FRAM_CS);  // use hardware SPI

uint8_t FRAM_SCK= 13;
uint8_t FRAM_MISO = 12;
uint8_t FRAM_MOSI = 11;
//Or use software SPI, any pins!
Adafruit_FRAM_SPI fram = Adafruit_FRAM_SPI(FRAM_SCK, FRAM_MISO, FRAM_MOSI, FRAM_CS);

uint16_t          addr = 0;

void setup(void) {
  Serial.begin(9600);
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens
  
  if (fram.begin()) {
    Serial.println("Found SPI FRAM");
  } else {
    Serial.println("No SPI FRAM found ... check your connections\r\n");
    while (1);
  }
  
  // Read the first byte
  uint8_t test = fram.read8(0x0);
  Serial.print("Restarted "); Serial.print(test); Serial.println(" times");

  // Test write ++
  fram.writeEnable(true);
  fram.write8(0x0, test+1);
  fram.writeEnable(false);

  fram.writeEnable(true);
  fram.write(0x1, (uint8_t *)"FTW!", 5);
  fram.writeEnable(false);

  // dump the entire 8K of memory!
  uint8_t value;
  for (uint16_t a = 0; a < 16384; a++) {
    value = fram.read8(a);
    if ((a % 32) == 0) {
      Serial.print("\n 0x"); Serial.print(a, HEX); Serial.print(": ");
    }
    Serial.print("0x"); 
    if (value < 0x1) 
      Serial.print('0');
    Serial.print(value, HEX); Serial.print(" ");
  }
}

void loop(void) {

}

I am getting this as output :
Unexpected Device: Manufacturer ID = 0x4, Product ID = 0x409

Flash Size = 0x0

No SPI FRAM found ... check your connections

I am aware that ID = 0x4 means a product by Fujitsu which is correct in my case.
But why is the SPI FRAM unfound? I have checked thru the connection and they should be correct.
Can anyone help me out with this issue?
The FRAM that I am using is MB85RS128A and I am using Arduino Uno and Seeduino Xiao sense.
Thank you in advance.

Your type of chip isn't supported by the library you're using. It has a list of supported devices in Adafruit_FRAM_SPI.cpp beginning at line 40. The library refuses to work with unsupported devices.

BTW, why are you using bit-bang SPI instead of hardware SPI? Your FRAM will be way out of the performance you would expect from something with "RAM" in it's name.

Question, how does the FRAM know you are addressing it. If it does not know it will not respond. Contrary to popular beleif SPI requires 4 wires to work properly. SCK, MOSI, MISO, and "CS". The first three go to each device on the SPI bus but you need an additional CS\ for each chip. If this does not solve your problem post an annotated schematic showing all connections, power, ground, and power sources. Also post links to technical information on each hardware device.

Thank you very much. I went to read the code and realized that as well.
I am just using the example code from the library to test the chip.
Still at the very beginning of this project. I appreciate your help.
I would be grateful if you could give me a link or guide on how to read and write on the FRAM.
I am trying to do data logging using FRAM.

This is my first time trying to do SPI on a RAM device so I am not quite sure. I have done SPI before between 2 MCUs but not an external ram. I found out the problem is that the library that I am using does not support the chip that I am using.
Link for the library: Arduino Test | Adafruit SPI FRAM Breakouts | Adafruit Learning System
Thank you for your reply.

And which one are you using with the FRAM? If you connected it directly to the UNO you might have damaged it as the datasheet says it's a 3.3V device and none of it's pins is 5V tolerant.

Using the Xiao nRF52840 you should change the pin usage to be able to use the hardware SPI. Insert your chip in the library's table as it seems to be otherwise compatible with the library.

Alright, I will make the purchase of the compatible chip for the Adafruit library first.
Thank you!
Btw, is it possible to store sensor data collected by the Xiao nRf52840 to the FRAM for data logging?

I didn't tell you so. Of course you're free to buy another chip but if you don't fix the other problems you won't be happy with it.

Yes, this is possible. You have to decide if it's suitable for your project.

1 Like

The ones I have are 32K x 8 on a breakout board. They are rated at 5V. I use them instead of the SD cards because of the consistent reliability problems I have had with with SD memory cards. Nice part they will probably not wear out they are good for more than 10 billion read/write cycles (1010)—equivalent to writing to the memory cell at 1 second intervals for 300 years.

1 Like

Could you share your reading and writing code with me :upside_down_face:
I am quite new to this. Trying to do some data logging from the data on the Xiao nRf52840 sense.
Much appreciated!!

This is the original library I used. It has been modified to fit my application. Rob Tillaart has posted several great libraries and they always seem to work. Hopefully it works for you as well as it does for me. I put the libraries in the same folder as my code because they are not that stable over time. Many times I tried to compile code from a few years back and the library is no longer working so I save the ones with the code, then it compiles years later.

//    FILE: FRAM.cpp
//  AUTHOR: Rob Tillaart
// VERSION: 0.3.1
//    DATE: 2018-01-24
// PURPOSE: Arduino library for I2C FRAM
//     URL: https://github.com/RobTillaart/FRAM_I2C
//
//  HISTORY:
//  0.1.0   2018-01-24  initial version
//  0.1.1   2019-07-31  added support for Fujitsu 64Kbit MB85RC64T (kudos ysoyipek)
//  0.2.0   2020-04-30  refactor, add writeProtectPin code
//  0.2.1   2020-06-10  fix library.json
//  0.2.2   2020-12-23  arduino-CI + unit test + getWriteProtect()
//  0.2.3   2021-01-ii  fix getMetaData (kudos to PraxisSoft
//  0.3.0   2021-01-13  fix #2 ESP32 + WireN support
//  0.3.1   2021-02-05  fix #7 typo in .cpp


#include "FRAM.h"
const uint8_t FRAM_SLAVE_ID_ = 0x7C;

Thank you sir.
I will take a look at it. I am trying to use SPI for my project.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.