sosandroid / FRAM_MB85RC_I2C

Arduino library for I2C FRAM - Fujitsu MB85RC & Cypress FM24, CY15B
Other
56 stars 21 forks source link
arduino arduino-library cy15b cypress ferroelectric-domains fm24c fm24w fram fujitsu i2c-device i2c-fram mb85rc memory ram

Arduino library for I2C FRAM - Fujitsu MB85RC & Cypress FM24, CY15B

I2C Ferroelectric Random Access Memory (FRAM). Read/write endurance for each memory slot : 10^12 cycles and more. 9~16 bit adresses, 8 bits data slots.

Supports 4K, 16K, 64K, 128K, 256K & 512K devices. Works for 1M devices when considering each device as 2 differents 512K devices

For SPI chips, please have a look on Christophe Persoz's repo

Features

Revision History

v1.0 - First release
v1.0.1 - Robustness enhancement
v1.0.2 - fix constructor, introducing byte move in memory
v1.0.3 - fix writeLong() function
v1.0.4 - fix constructor call error
v1.0.4.1 - Add example to help @porcao
v1.0.5 - Enlarge density chip support by making check more flexible, Error codes not anymore hardcoded, add connect example, add Cypress FM24 & CY15B series comment.
v1.1.0b - Adding support for devices without device IDs + 4K & 16 K devices support
v1.1.0b1 - Fixing checkDevice() + end of range memory map check + better manual mode example
v1.2.0 - Uses reinterpret_cast instead of bit shift / masking for performance. Breaks backward compatibility with previous code - See PR#6
v1.2.1 - Fix issue #11, issue #13, issue #10, Updating tested chips table

Devices

Fujitsu FRAM - manufacturer code 0x00A - Fujitsu page

Model Density (kB) Device addressing Device ID feature Density code Memory addressing Tested
MB85RC04V 4 6 bits Yes 0x00 9 bits [1] Yes
MB85RC16V 16 4 bits No - 11 bits [2] Yes
MB85RC16 16 4 bits No - 11 bits [2] No
MB85RC64V 64 7 bits No - 13 bits No
MB85RC64A 64 7 bits No - 13 bits Yes
MB85RC64TA 64 7 bits Yes 0x03 13 bits No
MB85RC128A 128 7 bits No - 14 bits No
MB85RC256V 256 7 bits Yes 0x05 15 bits Yes
MB85RC512T 512 7 bits Yes 0x06 16 bits No
MB85RC1MT 1024 6 bits Yes 0x07 17 bits [3] Yes

Cypress FRAM - manufacturer code 0x004 - Cypress page

Model Density (kB) Device addressing Device ID feature Density code Memory addressing Tested
FM24CL04B 4 6 bits No - 9 bits [1] Yes
FM24C04B 4 6 bits No - 9 bits [1] Yes
FM24C16B 16 4 bits No - 11 bits [2] No
FM24CL16B 16 4 bits No - 11 bits [2] Yes
FM24C64B 64 7 bits No - 13 bits Yes
FM24CL64B 64 7 bits No - 13 bits Yes
CY15B128J 128 7 bits Yes 0x01 14 bits No
FM24W256 256 7 bits No - 15 bits No
CY15B256J 256 7 bits Yes 0x02 15 bits No
FM24V05 512 7 bits Yes 0x03 16 bits No
FM24V10 1024 6 bits Yes 0x04 17 bits [3] Yes

[1]: 4K devices have a 9 bits addressing memory map. The 9th bit is set in the device address byte

[2]: 16K devices a 11 bits addressing memory map. The 3 MSB are set in the device address byte in place of A2~A0

[3]: 1M a 17 bits addressing memory map. To manage this device, you need to consider it as 2 512K devices with 2 distincts adresses : 1010+A2+A1+0 and 1010+A2+A1+1. The library is set that way.

Adresses

Devices address : b1010 + A2 + A1 + A0.

All devices are pulling down internaly A2, A1 & A0. Default address is b1010000 (0x50) - exception 1M chips which seems to be a double 512K devices in a single package. Please use 2 objects instances to deal with them.

4K devices have only A2 & A1 support. A0 is used for memory addressing. i2c_addr = 0b1010xx0

16K devices does not have A2, A1 nor A0 support. This is used for memory addressing i2c_addr = 0b1010000

An interesting document from Fujitsu describes it quite well.

Errors

The error management is eased by returning a byte value for almost each method. Most of the time, this is the status code from Wire.endTransmission() function.

Testing

To do

Q&A

Here some quick answers to some interesting questions:

Credits