Addressing 16-bit I2C register with Raspberry Pi
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
HenrikW
el 27 de Abr. de 2021
Comentada: MathWorks MATLAB Hardware Team
el 17 de Mayo de 2021
Hi,
I try to read from a 24LC512 eeprom via the I2C interface of a raspberry pi. My Problem is now, that the EEPROM has 16-bit register addresses. I tried to use
[value] = readRegister(myi2cdevice,register,dataPrecision)
but 'register' supports only 8-bit (0 to 255) values. Is there a workaround for this problem?
0 comentarios
Respuestas (1)
MathWorks MATLAB Hardware Team
el 13 de Mayo de 2021
Hi Henrik,
You can use write() and read() APIs for the same. Here is the code snippet that can help you,
>> % Read the data
>> write(<obj_here>, <address_here>, 'uint16');
>> dataRead = read(<obj_here>, <length_of_data_here>, 'uint16')
You can find more info about these APIs in following link,
https://www.mathworks.com/help/supportpkg/raspberrypiio/i2c-interface.html
Thanks,
MATLAB Hardware Team
MathWorks
2 comentarios
MathWorks MATLAB Hardware Team
el 17 de Mayo de 2021
Hi Henrik,
The reason that you are seeing address low byte first and then address high byte is probably due to the endiannes of your PC/hardware setup. Currently we support only little-endian devices, it is a limitation in our support package and we plan to address this issue in future releases.
You can execute the following command and see if you PC is if little-endian.
>> [~,~,endian] = computer
If your computer is little-endian ('L') then you may need to swap address bytes and then perform write and read operations. Hope this should solve no. (1).
For no. (2), you may still want to start with the device address. As per the following datasheet you need to do write [Start device_Address Write Addr_High Addr_low] + read [Start device_address data] for reading data from the memory.
http://ww1.microchip.com/downloads/en/devicedoc/21754m.pdf
If you are still facing any challenges then please contact our Technical Support for further assistance.
https://www.mathworks.com/support/contact_us.html
Thanks,
MATLAB Hardware Team
MathWorks
Ver también
Categorías
Más información sobre MATLAB Support Package for Raspberry Pi Hardware en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!