I've used the example code for the Adafruit I2C FRAM breakout board, but I've made it even simpler by just writing the same thing to each byte location and then reading them all off, doing nothing with the data.
I can tell it works because I can read off any byte and get the expected value, but the problem is that it works way too slowly. writing and reading 512 bytes takes almost a full half a second. This just won't work for my application, but I suspect there's something fundamentally wrong with what I'm doing.
I tried calling Wire.setClock(400000);
, which supposedly is the maximum speed my Nano can drive an I2c slave at, but no matter what argument I input, the operation takes the same amount of time (498616 microseconds, within about +/- 20 microseconds).
I also tried calling Wire.begin(); TWBR = 10;
, because I read that somewhere. But again, I get no difference. Here's my whole code- It's pretty simple
#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();
uint16_t framAddr = 0;
byte p = 55; //any old value- just write the same thing into all locations
void setup(void) {
Serial.begin(153600);
//Wire.begin();
//TWBR = 10;
//Wire.setClock(400000);
if (fram.begin()) {
Serial.println("Found I2C FRAM");
}
else {
Serial.println("I2C FRAM not identified ... check your connections?\r\n");
}
}
void loop(void) {
int i = 0;
long a = micros();
for (i ; i < 512; i++){ //write 512 bytes to the FRAM board
fram.write8(i, p);
}
for (i = 0 ; i < 512; i++) { //read 512 bytes from the FRAM board
fram.read8(i);
}
long b = micros();
Serial.println(b - a);
Serial.println("");
}