Adafruit I2C FRAM Breakout support Arduino Due

So what were the results of running an I2C scanner, if that shows nothing your wasting your time with other stuff, libraries etc ?

Yes, I have

grafik

Are your connections:

FRAM <--> Due
VCC <--> 3.3V
GND <--> GND
SDA <--> SDA (20)
SCL <--> SCL (21)
All other FRAM pins remain unconnected.

This lib is including Wire.h as well: https://github.com/adafruit/Adafruit_BusIO/blob/34f7392493718d311dc4ffccc745cc630ca7840f/Adafruit_I2CDevice.h#L1

It was pretty much a certainty that Adafruit would be using the Arduino Wire library, since this provides I2C compatibility across the Arduino range of boards.

So far I've not found anyone (posts) whose is using the official libs successfully with the FRAM board. Probably someone on GitHub can confirm that the lib works with the FRAM breakout board: https://github.com/arduino/ArduinoCore-sam/issues/126 Probably there is missing just a bit of undocumented modification of the example sketch to get it running...

If you have another (perhaps unrelated) I2C breakout board, it might be worth testing this with the Due, just to confirm that its I2C port is working correctly.

You mention that you've tried it with the Arduino Mega.

You could try connecting it like this:

FRAM <--> Mega
VCC <--> 5V
GND <--> GND
SDA <--> SDA (20)
SCL <--> SCL (21)
All other FRAM pins remain unconnected.

If this doesn't function then the issue most likely rests with the FRAM board itself.

First, I tried it with Arduino Due. Then I tried with Arduino Mega for cross-checking.

I've tried already...

Luckily I ordered 2 breakout boards. I'll try with the second one now.

Always good to have a second board, just to compare :grinning:.

Nope, Arduino Due + I2C FRAM Breakout Board + official hw connection instructions + VCC->3V3: I2C FRAM not identified ... check your connections?

And the Mega?

The second I2C FRAM board works on Arduino Mega (SDA/20 + SCL/21) :rocket:

With the same I2C FRAM board + Arduino Due (SDA/20 + SCL/21) I'm getting something different but still not functioning:

Unexpected Manufacturer ID: 0xA00
I2C FRAM not identified ... check your connections?

Will continue in case this processor doesn't support repeated start

That's progress.

This means that it probably has something to do with the Due. My guess is that FRAM doesn't either like the low pull-up resistors on the Due, or maybe the microcontroller's faster edges.

You could try switching to Wire1 on the Due, since this doesn't have the built-in pull-up resistors. The FRAM board itself has 10k pull-ups anyway.

It means switching to the Due's Wire1's SDA1 and SCL1 pins near the AREF pin, then adding arguments to the Adafruit FRAM library's begin() function on line 15 of their example code, by changing this:

if (fram.begin()) {  // you can stick the new i2c addr in here, e.g. begin(0x51);

to this:

if (fram.begin(MB85RC_DEFAULT_ADDRESS, &Wire1)) {  // you can stick the new i2c addr in here, e.g. begin(0x51);

if (fram.begin(MB85RC_DEFAULT_ADDRESS, &Wire)) { does compile.

#include "Wire.h"
...
if (fram.begin(MB85RC_DEFAULT_ADDRESS, &Wire1)) {

does not compile: 'Wire1' was not declared in this scope

Strange, it compiles fine on my machine, using the Adafruit MBR58RC256V example with the board as Arduino Due on the programming port.

I'm on Arduino 1.8.15, you? Arduino Due BSP (SAM) is version 1.6.12

This is coming from Adafruit_FRAM_I2C::begin (Adafruit_FRAM_I2C) and is caused by getDeviceID (Adafruit_FRAM_I2C) BTW. It calls write_then_read (Adafruit_BusIO) whic calls write as well as read (Adafruit_BusIO). So far I could not spot any board specifics...

@MartinL There are quite a few things I'd like to check in the code. Usually I'd look into tests in a SW project. However there are no tests defined which I could use as starting point. The code does not abstract away the dependency from the HW (I2C). Do you have some hints how to get started with debugging/developing library code which depends on actual HW?

I'm using the same.

This is the code I'm compiling. It might be worth cutting and pasting it into a new sketch in the Arduino IDE and trying to compile it on your machine with Arduino Due (Programming Port) selected:

#include "Adafruit_FRAM_I2C.h"

/* Example code for the Adafruit I2C FRAM breakout */

/* Connect SCL    to analog 5
   Connect SDA    to analog 4
   Connect VDD    to 5.0V DC
   Connect GROUND to common ground */
   
Adafruit_FRAM_I2C fram     = Adafruit_FRAM_I2C();

void setup(void) {
  Serial.begin(115200);
  
  if (fram.begin(MB85RC_DEFAULT_ADDRESS, &Wire1)) {  // you can stick the new i2c addr in here, e.g. begin(0x51);
    Serial.println("Found I2C FRAM");
  } else {
    Serial.println("I2C FRAM not identified ... check your connections?\r\n");
    Serial.println("Will continue in case this processor doesn't support repeated start\r\n");
    while (1);
  }
  
  // Read the first byte
  uint8_t test = fram.read(0x0);
  Serial.print("Restarted "); Serial.print(test); Serial.println(" times");
  // Test write ++
  fram.write(0x0, test+1);
  
  // dump the entire 32K of memory!
  uint8_t value;
  for (uint16_t a = 0; a < 32768; a++) {
    value = fram.read(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) {

}

The fact that the code compiles makes sense, since the Wire library for the Due creates both the Wire and Wire1 objects.

The Adafruit FRAM_I2C library's begin() function can take a pointer to a secondary I2C port, in this case we pass the address of Wire1.