Only SCL and SDA pins 18 and 19 work

Status
Not open for further replies.

Hitachii

Active member
Trying to install an FRAM breakout board onto a 4.1. Running the test code in the Adafruit FRAM library linked below, the program returns a successful read when attached to pins 18 and 19. However, when attached to SDL/SCA 1 or 2 (understanding that SCL/SDA flip order on the board), the serial monitor is blank, even though the code is supposed to return a message if there's an unsuccessful read. When I unplug the pins, the unsuccessful read does show up (instead of blank, like when it's plugged into SCL/SDA 1 and 2). Also tried running a general i2c test code, which returns a successful read when at on the first pins, but says that no i2c ports found when plugged into the others. Wondering if the blank serial monitor is significant in context.

My connections seem fine, The only other things currently attached to the board are a few momentary switches, which aren't programmed into the code. They're just soldered in place so I wanted to ask this question before dismantling the whole project, in the highly likely event that there's something that I don't know about attaching i2c devices. I'm also trying to use two other i2c devices. Should I use them on the same bus?

Here's the board, test code located
https://cdn-learn.adafruit.com/downloads/pdf/adafruit-i2c-fram-breakout.pdf

Code from the FRAM library:
Code:
#include <Wire.h>
#include "Adafruit_EEPROM_I2C.h"

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

/* Connect SCL    to SCL
   Connect SDA    to SDA
   Connect VDD    to 3 - 5V DC
   Connect GROUND to common ground */
   
Adafruit_EEPROM_I2C i2ceeprom;

#define EEPROM_ADDR 0x50  // the default address!

void setup(void) {
  Serial.begin(115200);
  
  if (i2ceeprom.begin(0x50)) {  // you can stick the new i2c addr in here, e.g. begin(0x51);
    Serial.println("Found I2C EEPROM");
  } else {
    Serial.println("I2C EEPROM not identified ... check your connections?\r\n");
    while (1) delay(10);
  }
  
  // Read the first byte
  uint8_t test = i2ceeprom.read8(0x0);
  Serial.print("Restarted "); Serial.print(test); Serial.println(" times");
  // Test write ++
  i2ceeprom.write8(0x0, test+1);
  
  // dump the first 256 bytes of memory
  uint8_t val;
  for (uint16_t addr = 0; addr < 256; addr++) {
    val = i2ceeprom.read8(addr);
    if ((addr % 32) == 0) {
      Serial.print("\n 0x"); Serial.print(addr, HEX); Serial.print(": ");
    }
    Serial.print("0x"); 
    if (val < 0x10) 
      Serial.print('0');
    Serial.print(val, HEX); Serial.print(" ");
  }
}

void loop(void) {

}
 
Try i2ceeprom.begin(0x50, &Wire1);

If you don't tell it which port to use, Adafruit's library will default to Wire which is only on pins 18 & 19.
 
It appears to have worked, thanks Paul. Only now I'm having another issue related to FRAM but not i2c. Can start a new thread if needed.

When testing on the Uno, I get the following reading, which is a successful read:

Restarted 29 times

0x0: 0x1E 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x20: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x40: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x60: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x80: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0xA0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0xC0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0xE0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

When testing on the Teensy, I get the text in the box below sometimes, otherwise the serial monitor mostly just reads "0x00 0x00 0x00 0x00 "

Found I2C EEPROM
Restarted 31 times

0x0: 0x20 0x00

Testing each in the respective Arduino/Teensyduino programs. I went in and removed all the buttons in case that was the problem, but same messages. Currently the only thing connected to the teensy is the EEPROM via SCL and SDA and the 3.3V and ground pins.
 
Interesting development, the FRAM library has two example codes. The one I've been using reads the first 256 addresses, while the second one (posted below) does the same thing but reads all of the addresses. When using the second example code, the problem mentioned above actually flips when plugged into the Uno, then the Teensy, in the respect that the Uno only reads 4 addresses or so while the Teensy successfully shows all addresses in the serial monitor. Incredibly strange. However, I'm just going to assume that everything works and there's something about the way that this code is written has some compatibility issues I'm not aware of.

I'm happy to check if there's anything about this that piques your curiosity though.

Code:
#include <Wire.h>
#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(9600);
  
  if (fram.begin()) {  // 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");
  }
  
  // Read the first byte
  uint8_t test = fram.read8(0x0);
  Serial.print("Restarted "); Serial.print(test); Serial.println(" times");
  // Test write ++
  fram.write8(0x0, test+1);
  
  // dump the entire 32K of memory!
  uint8_t value;
  for (uint16_t a = 0; a < 32768; 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) {

}
 
Status
Not open for further replies.
Back
Top