EEPROM Page write - AT24C512

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
lnsri22
Posts: 75
Joined: Fri Aug 17, 2018 12:16 pm
Location: India

EEPROM Page write - AT24C512

Post by lnsri22 » Thu Dec 13, 2018 7:09 am

Hello everyone!!

I am trying to interface an EEPROM (AT24C512, 512kbits (64KB)) with pyboardV1.1. I have found success using the test script here.

https://github.com/dda/MicroPython/blob ... /EEPROM.py

The time taken for erase, write and read seems to be a bit longer being single byte is written every time to the eeprom. Is there a way to do a page write (128 bytes at a time for AT24C512).

User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: EEPROM Page write - AT24C512

Post by mcauser » Mon Dec 17, 2018 4:45 am

Isn't it as simple as:

Code: Select all

from machine import I2C
i2c = I2C(scl=Pin(5), sda=Pin(4), freq=100000)
buf = bytearray(b'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed metus, hendrerit in elit quis, ultrices Maecenas lobortis sed orci.')
i2c.writeto_mem(0x50, 0, buf, addrsize=16)  # write 128 bytes to slave 0x50, slave memory 0x00
buf2 = i2c.readfrom_mem(0x50, 0, 128, addrsize=16)  # read 128 bytes from slave 0x50, slave memory 0x00
or...

Code: Select all

from pyb import I2C
i2c = I2C(1, I2C.MASTER, baudrate=100000)
buf = bytearray(b'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed metus, hendrerit in elit quis, ultrices Maecenas lobortis sed orci.')
i2c.mem_write(buf, 0x50, 0x00, addr_size=16)  # write 128 bytes to slave 0x50, slave memory 0x00
i2c.mem_read(128, 0x50, 0x00, addr_size=16)  # read 128 bytes from slave 0x50, slave memory 0x00

manimozhi
Posts: 1
Joined: Tue Dec 18, 2018 7:10 am

Re: EEPROM Page write - AT24C512

Post by manimozhi » Fri Dec 21, 2018 1:52 pm

Hi!!

Thanks for the idea.

I tried this with no success. Getting the error

"can't convert byte to int"

For your reference, I'm trying to erase the EEPROM (theoretically). Filling '0xFF' in all 64 K locations

What am I missing...?

Thanks in advance!!

Post Reply