[fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?
Bo Berglund
bo.berglund at gmail.com
Wed Apr 5 07:54:52 CEST 2023
On Wed, 05 Apr 2023 00:33:50 +0200, Bo Berglund via fpc-pascal
<fpc-pascal at lists.freepascal.org> wrote:
>On Tue, 4 Apr 2023 23:43:21 +0200, Christo Crause via fpc-pascal
><fpc-pascal at lists.freepascal.org> wrote:
>
>
>>Is your startaddress variable an unsigned 16 bit integer
>>(word/uint16)? If not, type cast this to a uint16 to ensure the compiler
>>calls the correct overloaded method.
Did not answer the type question:
Yes, that has always been a uint16 for the reason you outline: to select the
correct overloaded method.
>>
>>Passing the address of the first element of a TBytes array as you did above
>>is correct.
>
OK, I thought so. It has been there with some variations all the time.
>
>
>Note: I have not changed anything inside the i2c.pas file...
This was just to point out that I am not modifying this base file, just using
it.
Another observation:
I *can* write a sequence of bytes into the EEPROM succsessfully using an
i2c-tools command like this:
i2ctransfer -y 1 w18 at 0x50 0x00 0x38 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08
0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f
This writes data starting towards the end of the page and wraps around such that
part of the data gets to the start of the page.
It shows:
- It is possible to write the data in one go
- If the data length is past the end of the page it wraps around to the
beginning
So if the problem cannot be solved then I could either use the loop with delay
or call the i2c-tools command i2ctransfer as a TProcess execution to write
multiple bytes in one command.
But I would rather not use the TProcess method at all since it relies on an
external tool being present and the argument list can be pretty long and tedious
to build...
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list