Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

Simple CircuitPython Driver for Microchip 24x256/512 EEPROMs
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Simple CircuitPython Driver for Microchip 24x256/512 EEPROMs

by MarksBench on Tue Jun 01, 2021 9:03 pm

Hello!

I hope it's okay to post this here in case it got buried in the conversation that KJRC and I were having, but after staring at documentation and I2C traffic on my oscilloscope, I think I've finally put together a serviceable CircuitPython driver for Microchip's 24x256 and 24x512 EEPROMs. If you're interested, you can find it here: https://github.com/MarksBench/mb_24x256_512_CP

It is (hopefully) very easy to use. All you need to do it is what I2C address it's on (or use i2c.scan() to try to do it automatically) and uncomment the line that matches the EEPROM you're using.

It will write a single 8-bit value to an address that you specify with write_byte(address, value), and it will read a single 8-bit value from an address that you specify with read_byte(address).

It is important to know that this driver does byte writes - not page writes. Each byte written requires the entire page to be written in EEPROM, so using this driver will wear the EEPROM much faster than doing page writes. The Microchip datasheet states that the 24x512 is good for more than a million page writes, so do with that what you will. I went with byte writes for several reasons:
- It was easier to write,
- These EEPROMs are very inexpensive,
- It uses less memory (don't need a buffer to hold a page worth of data), and
- 107% of the time, I want data to be written to an EEPROM as soon as I get it, not after x more samples have been collected.

I've tested it on a Raspberry Pi Pico (RP2040) running CircuitPython 6.2 and it seems to be working reliably. I expect it will run on other CircuitPython-capable hardware that can do hardware or software I2C.

I expect this driver will work with other Microchip EEPROMs with little in the way of modification but if you have any EEPROMs you'd like me to try, I'd be happy to see if I can figure them out for you and add them to this driver. I am not a programmer - I miss the days when screens were only green, programs had line numbers, and nobody cared if you used a GOTO - but I've been enjoying learning how things work and what I've learned together in case it can be useful for someone.

And last but certainly not least, thank you to KJRC for being patient with my fumbling while I try to learn Circuit/MicroPython and understand I2C and for providing ideas, testing, and feedback. Much appreciated!

MarksBench
 
Posts: 42
Joined: Tue Apr 20, 2021 5:40 pm

Re: Simple CircuitPython Driver for Microchip 24x256/512 EEP

by tannewt on Wed Jun 02, 2021 11:18 am

Awesome! Thank you!

I'd suggest following this guide to contribute your driver into the community bundle: https://learn.adafruit.com/creating-and ... on-library

tannewt
 
Posts: 2428
Joined: Thu Oct 06, 2016 8:48 pm

Re: Simple CircuitPython Driver for Microchip 24x256/512 EEP

by MarksBench on Wed Jun 02, 2021 11:25 am

Hello!

Sounds good - I didn't even know that was possible. I'll give the guide a look and see what I can do!

MarksBench
 
Posts: 42
Joined: Tue Apr 20, 2021 5:40 pm

Please be positive and constructive with your questions and comments.