LoPy4 - I2C - FRAM Memory - MicroPython Library
I am working on a project where I am building an industrial lubrication system controller, my application requires me to have a way to save user-selected parameters for the controller to access and config on boot. I got a custom-made shield for my project that takes a LoPy4 as a controller.
my shield is equipped with a FRAM - MB85RC256VPF-G-JNERE2 chip SDA->P9, SCL->P10, and Write Protect on P2.
It's my first project with MicroPython and Pycom. I managed to have all my other functionalities figured out from the documentation except my FRAM.
I am having problems finding a library or information to help me achieve my results. at this point, I think I may need to write my own firmware which is way above my abilities for now.
So far in my research, I found a discussion and a link to PeterHinch's Github repo that brings me to a dead end. I was looking at is GitHub projects and i did not see anything referring to FRAM I2C but he has is lots of other amazing work I am glad I found. I think it may have been deleted overtime.
I also found a Repo from Adafruit but it is for circuit python. https://github.com/adafruit/Adafruit_CircuitPython_FRAM.
I am wondering if anyone knows about or has seen something that could help me out.
There is no need for a "firmware" when it comes to using an FRAM. You just need to understand how an I²C bus operates.
Reading or writing is a straight forward process:
- Create and i2c-Object (see example in the pycom docs)
- Write data by
i2c.writeto_mem(ADDR_FRAM, Offset, bytearray(Data), addrsize=16) DataByteArray = i2c.readfrom_mem(ADDR_FRAM, Offset, Size, addrsize=16)
Page 8 of the datasheet explains which bytes sequence has to be sent: two bytes for the target address, then the data byte(s).
Then write yourself two functions WriteFRAM(Offset, Byte) and ReadFRAM(Offset) and you are done. The whole thing may finally have just about 20 lines of code.
Don't spend too much time on searching for an already working program. Writing your own FRAM code is a very instructive task and will also lead to a better understanding of the possible pitfalls. Just as an example: how do you plan to react when a bus transmission fails due to a temporary electrical interference?