I am getting an address for an FRAM even with out one being connected
Here is a code snippet:
local i2c = hardware.i2c0; //hardware.i2cJK or hardware.i2c0
i2c.configure(CLOCK_SPEED_400_KHZ);
local fram1 = MB85RC(i2c, 0xA0, 256, null, true);
//addresses are 0xA0, 0xA2, 0xA4, 0xA6, 0xA6, 0xA8, 0xAA, 0xAC, 0xAE
//this is used allow the use of upto 8 FRAMs as if they were 1
//local fram2 = MB85RC(i2c, 0xA2, 256);
//local fram3 = MB85RC(i2c, 0xA4, 256);
//local fram4 = MB85RC(i2c, 0xA6, 256);
//…
It’s been a while since I wrote this, so let me check, but IIRC, it doesn’t test for the presence of a FRAM device at the address passed into the constructor. Your test (fram1 == null)) will therefore always pass because the object is always instantiated.
Also:
writeByte(address, value)
Allows you to write a value from 0x00—0xFF to the FRAM. An 8bit uint, Great.
readByte(address)
Returns the unsigned 8-bit value located at address. The returned value is a single-character string.
Not good as there appears to be no way of converting the single-character string into an 8 bit int again.
Even using a blob with int type ‘b’ fails.
How do I retrieve the 8bit uint a value (from 0x00—0xFF) from the FRAM?
That’ll do it. I’m in the process of updating the MB85RC library and plan to update the function checkFramInfo() as follows (the key change is the addition of the third line):
writeByte(address, value)
Allows you to write a value from 0x00—0xFF to the FRAM. An 8bit uint, Great.
readByte(address)
Returns the unsigned 8-bit value located at address. The returned value is a single-character string.
Not good as there appears to be no way of converting the single-character string into an 8 bit int again.
Even using a blob with int type ‘b’ fails.
How do I retrieve the 8bit uint a value (from 0x00—0xFF) from the FRAM?
A pre-release update to the library can be found at our GitHub repo here, if you’d like to try it out. Resolves some of the issues raised above (eg. readByte returns an integer not a string) and includes a stack of refactoring and other fixes.
This is not available yet via #require so you’ll need to copy and paste it into your code for now.