I2C Fram circuit not worked (MB85RC256)

Good afternoon, I'm developing a board with a set of sensors.
I use a 256 kbit FRAM (MB85RC256) to store the data.
In the beginning I used an already assembled breakboard, and it worked correctly. I'm currently implementing the FRAM hip directly on the pcb, which has caused me some problems.
The controller of my circuit is an atmega328p, in the serial print it returns the memory address correctly (0x50), however, when I try to print the available memory using the "FRAM.h" library it returns 0.
I can't write or read data either.
I think there's something wrong with my circuit. I tried changing the memory and that didn't work either.

My circuit:

As you can see, in my circuit I have a 3.3V supply for the sensors and for the FRAM, a 3.3V i2c pull-up resistor with a 4.7K resistor. And an i2c to 5V converter, which is the power supply for my Atmega.
The sensors are working correctly in this configuration, but the memory is not.

FRAM Breakboard circuit (Adafruit):

Serial print:

Recebido: C:\Users\Matheus Markies\AppData\Local\Temp\.arduinoIDE-unsaved2024322-16248-98p6p7.uy5q7\FRAM9_test\FRAM9_test.ino
FRAM_LIB_VERSION: 0.7.0
   KB  :	0
BYTES  :	512
Write	0	1
Write	1	1
Write	2	2
Write	3	2
Write	4	3
Write	5	3
Write	6	4
Write	7	4
Write	8	5
Write	9	5
Write	10	6
Write	11	6
Write	12	7
Write	13	7
Write	14	8
Write	15	8
Write	16	9
Write	17	9
Write	18	10
Write	19	10
Write	20	11
Write	21	11
Write	22	12
Write	23	12
Write	24	13
Write	25	13
Write	26	14
Write	27	14
Write	28	15
Write	29	15
Write	30	16
Write	31	16
Write	32	17
Write	33	17
Write	34	18
Write	35	18
Write	36	19
Write	37	19
Write	38	20
Write	39	20
Write	40	21
Write	41	21
Write	42	22
Write	43	22
Write	44	23
Write	45	23
Write	46	24
Write	47	24
Write	48	25
Write	49	25
Write	50	26
Write	51	26
Write	52	27
Read	0	1	164
Read	1	1	30
Read	2	2	24
Read	3	2	27
Read	4	3	22
Read	5	3	31
Read	6	4	24
Read	7	4	24
Read	8	5	27
Read	9	5	31
Read	10	6	26
Read	11	6	26
Read	12	7	25
Read	13	7	23
Read	14	8	29
Read	15	8	28
Read	16	9	0
Read	17	9	0
Read	18	10	0
Read	19	10	0
Read	20	11	0
Read	21	11	

Test-Fram.ino:

//
//    FILE: FRAM9_test.ino
//  AUTHOR: Rob Tillaart
// PURPOSE: demo FRAM9 memory test
//     URL: https://github.com/RobTillaart/FRAM_I2C


#include "FRAM.h"

FRAM9 fram;

uint32_t start;
uint32_t stop;

uint32_t sizeInBytes = 0;


void setup()
{
  Serial.begin(115200);
  Serial.println(__FILE__);
  Serial.print("FRAM_LIB_VERSION: ");
  Serial.println(FRAM_LIB_VERSION);

  Wire.begin();

  int rv = fram.begin(0x50);
  if (rv != 0)
  {
    Serial.print("INIT ERROR: ");
    Serial.println(rv);
  }

  //  get size
  Serial.print("   KB  :\t");
  Serial.println(fram.getSize());
  Serial.print("BYTES  :\t");
  Serial.println(fram.getSizeBytes());
  sizeInBytes = fram.getSizeBytes();

  delay(100);

  test();

  Serial.println("done...");
}


void loop()
{
}


void test()
{
  //  addr goes from 0 .. 512
  //  value goes from 0.. 255

  uint8_t value = 0x00;
  for (uint32_t addr = 0; addr < sizeInBytes; addr++)
  {
    if (addr % 2 == 0) value++;
    fram.write8(addr, value);
    Serial.print("Write\t");
    Serial.print(addr);
    Serial.print("\t");
    Serial.println(value);
  }

  // read back
  value = 0x00;
  for (uint32_t addr = 0; addr < sizeInBytes; addr++)
  {
    if (addr % 2 == 0) value++;
    uint8_t x = fram.read8(addr);
    if (x != value)
    {
      Serial.print("Read\t");
      Serial.print(addr);
      Serial.print("\t");
      Serial.print(value);
      Serial.print("\t");
      Serial.println(x);
    }
  }

}

//  -- END OF FILE --

FRAM link: https://pt.aliexpress.com/i/4000117998517.html

Parts purchased from aliexpress have a good chance of being fake, reject or nonfunctional. Buy from a reputable supplier.

I thought the problem was also with the supplier, but I tested it with a memory taken from the FRAM Breakboard itself afterwards, and it didn't work either.

Good test! That suggests the problem is in your design and or construction techniques.

Decoupling cap C1 on the schematic should be 10 to 100 nF, not 10uF.

Not only that but they need to be ceramic types, not any other type.
See
my decoupling tutorial to find out why

And ideally you need one per chip, or at least one between two chips.

Where is the rest of the schematic ?

It is possible that a I2C Scanner sketch sees a chip, but reading and writing is not possible. It happens more on this forum. In most cases the I2C bus is too slow, has too much noise, the voltage levels do not match, or there is OLED display on the I2C bus.

I am looking at the level shifter :eyes:
Are you saying that the FRAM is working when it is connected to the ATmega chip and not when it is behind the level shifter ?
The FRAM works at 3.3V and 5V, it would be better to use it with 5V and connect it to the ATMega.
Did you buy the level shifter from AliExpress ?
Both the datasheet and Sparkfun have 100pF for the capacitor at VREF2. You have 100nF.

Are there other things with pullup resistors ?
It is possible to measure the current for SDA and SCL by measuring the short circuit current.
Upload a sketch with only Wire.begin() in setup() and a empty loop().
Measure the current from SDA to GND, and from SCL to GND. They should be the same and they should not exceed the 3mA.

Yes, it doesn't work with the level shifter.

No, only i2c on 3.3v and 5v

All give 1.6mA

CL05A104KA5NNNC These are 0.1uF capacitors for decoupling the systems.

5V/60k + 5V/4k7 + 3.3V/4k7 = 1.8 mA
That matches with your measurements.

The datasheet for the voltage regulator says: "It is recommended to use X7R or X5R dielectric capacitor if 1.0μF ceramic capacitor is selected as input/output capacitors".
You have 10μF, but they are X5R, so I assume that they are okay.

Can you measure after the 200k what the voltage of VREF2 is ? Perhaps there is something on the PCB that conducts electricity and leaks away some current. I assume that it should be between 4.5 and 5.0V.

Do you have the newest version of the FRAM library ? A bug was fixed in January.

If the other I2C chips are okay, then perhaps the FRAM chip is sensitive for timing or noise problems.
Maybe others would like to see the PCB layout. SDA should not go side-by-side with SCL over the PCB for more than 10cm.
How about a redesign with a ATmega chip at 8MHz and running at 3.3V, so the level shifter is no longer needed ?

I measured a voltage of 3.4V.

I've just done a more interesting test on this library.
I put my FRAM Breakboard directly into an Arduino Nano, and got the same error.
That means the library is faulty, right?

I2C Scanner:

I even intend to do this in the future. I chose to keep it at 0 5V for safety reasons, since I already had experience developing the circuit for 5V.

I did another test through the library: GitHub - sosandroid/FRAM_MB85RC_I2C: Arduino library for I2C FRAM - Fujitsu MB85RC & Cypress FM24, CY15B

Captuasdfrar

/**************************************************************************/
/*!
    @file     FRAM_I2C_store_anything.ino
    @author   SOSAndroid (E. Ha.)
    @license  BSD (see license.txt)

    Example sketch that stores and retreive any kind of data.

    @section  HISTORY

    v1.0 - First release
	v1.0.1 - fix constructor call error
*/
/**************************************************************************/

#include <Wire.h>
#include <math.h>

#include <FRAM_MB85RC_I2C.h>


//define a struct of various data types
typedef struct MYDATA_t {
	bool data_0;
	float data_1; 
	long data_2; 
	int data_3;
	byte data_4;
};

//define a struct joining MYDATA_t to an array of bytes to be stored
typedef union MYDATA4I2C_t {
 MYDATA_t datastruct;
 uint8_t I2CPacket[sizeof(MYDATA_t)];
};

MYDATA4I2C_t mydata; //data to be written in memory
MYDATA4I2C_t readdata; //data read from memory

//random address to write from
uint16_t writeaddress = 0x025;

//Creating object for FRAM chip
FRAM_MB85RC_I2C mymemory;

void setup() {

	Serial.begin(9600);
	while (!Serial) ; //wait until Serial ready
	Wire.begin();
	
	byte arraySize = sizeof(MYDATA_t);
	
    Serial.println("Starting...");
		
	mymemory.begin();
		
	
//---------init data - load array
	mydata.datastruct.data_0 = true;
	Serial.print("Data_0: ");
	if (mydata.datastruct.data_0) Serial.println("true");
	if (!mydata.datastruct.data_0) Serial.println("false");
	mydata.datastruct.data_1 = 1.3575;
	Serial.print("Data_1: ");
	Serial.println(mydata.datastruct.data_1, DEC);
	mydata.datastruct.data_2 = 314159L;
	Serial.print("Data_2: ");
	Serial.println(mydata.datastruct.data_2, DEC);
	mydata.datastruct.data_3 = 142;
	Serial.print("Data_3: ");
	Serial.println(mydata.datastruct.data_3, DEC);	
	mydata.datastruct.data_4 = 0x50;
	Serial.print("Data_4: 0x");
	Serial.println(mydata.datastruct.data_4, HEX);
	Serial.println("...... ...... ......");
	Serial.println("Init Done - array loaded");
	Serial.println("...... ...... ......");



//----------write to FRAM chip
	byte result = mymemory.writeArray(writeaddress, arraySize, mydata.I2CPacket);

    if (result == 0) Serial.println("Write Done - array loaded in FRAM chip");
    if (result != 0) Serial.println("Write failed");
	Serial.println("...... ...... ......");
	
	
//---------read data from memory chip
	result = mymemory.readArray(writeaddress, arraySize, readdata.I2CPacket);
    if (result == 0) Serial.println("Read Done - array loaded with read data");
    if (result != 0) Serial.println("Read failed");
	Serial.println("...... ...... ......");
	
//---------Send data to serial
	Serial.print("Data_0: ");
	if (readdata.datastruct.data_0) Serial.println("true");
	if (!readdata.datastruct.data_0) Serial.println("false");
	Serial.print("Data_1: ");
	Serial.println(readdata.datastruct.data_1, DEC);
	Serial.print("Data_2: ");
	Serial.println(readdata.datastruct.data_2, DEC);
	Serial.print("Data_3: ");
	Serial.println(readdata.datastruct.data_3, DEC);	
	Serial.print("Data_4: 0x");
	Serial.println(readdata.datastruct.data_4, HEX);
	Serial.println("...... ...... ......");
	Serial.println("Read Write test done - check data if successfull");
	Serial.println("...... ...... ......");	

	
}

void loop() {
	// nothing to do
}

The pictured solder joints don't look promising. They need to be cleaned up and checked for solder bridges and proper continuity. Adafruit and Sparkfun have excellent tutorials on soldering.

Without a doubt, this wasn't one of my best jobs... :sweat_smile:

I found something interesting here.
I made the breakboard circuit from scratch and put in the fram, and it worked!

I need to adapt it to my pcb now, as there must be some more complicated error in it.
I used 10K pull-up resistors, do you think that might have made it work?

The PCA9306 is a weird chip with a large resistor to VREF2. I don't know if 3.4V for VREF2 is good.
But I have to tell you that I don't understand why they made VREF2 that way.

Hi, i see you have the WP Pin not connected for the FRAM, WP must be set to LOW so that you can write on it, and it must be on HIGH to read.

If this is for the MB85RC256V then the device datasheet says different;

Note the comment "The reading operation is always enabled regardless of the Write
Protect pin input level."

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