RobTillaart / FRAM_I2C

Arduino library for I2C FRAM
MIT License
34 stars 7 forks source link
arduino fram i2c

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

FRAM_I2C

Arduino library for I2C FRAM.

Description

FRAM is a library to read from and write to (over I2C) an FRAM module. Since 0.5.0 the library provides four classes:

Currently only the MB85RC1MT is known to use 32 bit. FRAM32 can also address 16 bit devices although there is some overhead in footprint.

FRAM stands for Ferroelectric RAM - https://en.wikipedia.org/wiki/Ferroelectric_RAM

FRAM memory is much faster than EEPROM and almost as fast as (Arduino UNO) RAM. Another important feature FRAM has in common with EEPROM is that FRAM keeps its content after a reboot as it is non-volatile, even for years. That makes it ideal to store configuration or logging data in a project.

Last but not least FRAM allows much more write cycles than any EEPROM. Typical FRAM allows 10^12 write cycles (see datasheet) where an ATMEGA328 (UNO) supports 10^5 write cycles (https://docs.arduino.cc/learn/built-in-libraries/eeprom). That is a factor of 10 million more write cycles.

Fujitsu

Types of FRAM tested with this library:

TYPE SIZE TESTED NOTES uses ref
MB85RC04 512 Y no deviceID register FRAM9 #35
MB85RC16 2 KB Y no deviceID register FRAM11 #28
MB85RC64T 8 KB Y FRAM
MB85RC64V 8 KB Y no deviceID register FRAM #38
MB85RC128A 16 KB N no deviceID register FRAM
MB85RC256V 32 KB Y FRAM
MB85RC512T 64 KB Y FRAM
MB85RC1MT 128 KB Y FRAM32 #19

MB85RC128A and MB85RC64V have no size / deviceID, clear() will not work correctly, unless one calls setSizeBytes(16 * 1024) or setSizeBytes(8 * 1024) to set the size manually.

For the FRAM9 and FRAM11 the size problem is solved (hard coded) in their class.

Ramtron / Cypress / Infineon

Types of FRAM tested with this library:

TYPE SIZE TESTED NOTES uses ref Notes
24CL16B 2 KB N no deviceID register FRAM11 #28
FM24C256-G 32 KB Y no deviceID register FRAM #45 test with ESP32
FM24V10 128 KB Y FRAM32 #49

Codes on the chip - Fujitsu

The datasheet - MB85RC04_DS501_00057_1v0_E-2329111.pdf - page 20 - provides meaning to the markings on the FRAM devices. The meaning of Environment code is unclear.

RC04:   Product name
E11900: E1 (Environment code) + 1900 (Year and Week code)
300:    3 (Factory code) + 00(Trace code)

Notes

Related

Interface

#include "FRAM.h"

Constructors

Begin

The user has to call Wire.begin() before FRAM.begin()!

Write & read

Support for basic types and two calls for generic objects, use casting if needed.
In the FRAM32 class these functions have an uin32_t memAddr.

Template functions

See issue #13, #42

ReadUntil, readLine

Experimental 0.5.1, see issue #30

ReadUntil

readUntil() can be used to read lines and/or fields from an FRAM filled with text. For example logging written with the FRAM_logging.ino example. Note: if memAddr + bufferLength >= size of FRAM, memory address wrapping may occur. The library does not check, so the user should.

Note: internally readUntil() reads bufferLength bytes to fill the buffer. Then it searches for the separator. This is chosen to optimize performance for relative small buffers that are used most. For large buffers this fetching of the whole buffer will take much time. This can results in less responsiveness. Increasing the I2C bus speed might compensate this a bit.

Finally the FRAM_readUntil.ino sketch has a readUntil() implementation that uses a per byte fetching.

Write-protect

Will work only if a writeProtectPin was defined in begin()

Metadata

These may not work for devices that have no deviceID register.
So use with care.

Manufacturers ID

Name ID Notes
Fujitsu 0x00A
Ramtron 0x004 shared
Cypress 0x004 shared
Infineon 0x004 shared
getMetaData read error 0xFFF See #38

Additions for manufacturers ID's are welcome.

Sleep

(0.3.6 added - experimental)

According to the data sheets there are only three FRAM devices support the sleep command. So use with care.

TYPE SIZE SLEEP (datasheet) CURRENT CONFIRMED NOTES
MB85RC04 512 not supported - N
MB85RC16 2 KB not supported - N
MB85RC64T 8 KB Y Page 11 4.0 uA* N
MB85RC128A 16 KB not supported - N
MB85RC256V 32 KB not supported - Y
MB85RC512T 64 KB Y Page 12 4.0 uA* N
MB85RC1MT 128 KB Y Page 12 3.6 uA Y See #17
FM24C256-G 32 KB not supported Y See #45

current with * are from datasheet

Current

Indicative power usage in uA in three modi (if supported).

TYPE SIZE STANDBY WRITE SLEEP NOTES
MB85RC04 512 -
MB85RC16 2 KB -
MB85RC64T 8 KB 4.0 uA
MB85RC128A 16 KB -
MB85RC256V 32 KB 10.22 uA 93.48 uA -
MB85RC512T 64 KB 4.0 uA
MB85RC1MT 128 KB 11.7 uA 46-721 uA 3.6 uA See #17
FM24C256-G 32 KB 100 uA See #45

FRAM_RINGBUFFER

Since version 0.4.2 a separate class FRAM_RINGBUFFER is added to this repo. Its interface is straightforward and described in FRAM_RINGBUFFER.md. The FRAM_ringbuffer.ino examples shows how the class can be used.

FRAM_MULTILANGUAGE

Since version 0.5.2 the FRAM_ML class is added. Its purpose is to store tables of strings in FRAM. Its interface is described in FRAM_MULTILANGUAGE.md.

See examples.

FRAM32

Since version 0.8.0 the FRAM32 internal readBlock() and writeBlock() guard for memory addresses that are out of range. This prevents interference with valid address ranges. These will just be ignored for now and no error flag whatever is set.

FRAM11 + FRAM9

Experimental support for smaller FRAM's with 11 and 9 bits addresses.

Future

Must

Should

Could

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,