Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-05 Thread Bo Berglund via fpc-pascal
On Wed, 5 Apr 2023 17:57:00 +0200, Christo Crause via fpc-pascal wrote: >The use of WriteBytesToReg in the TI2c_eeprom.WriteData method seems fine, >perhaps retest with the updated WriteBytesToReg method. I pulled the i2c.pas file from GitHub (actually downloaded the zip since I don't really

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-05 Thread Christo Crause via fpc-pascal
On Wed, Apr 5, 2023 at 12:43 PM Bo Berglund via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > On Wed, 5 Apr 2023 11:40:09 +0200, Christo Crause via fpc-pascal > wrote: > >Looking at the datasheet for CAT24C128, Fig. 6 Byte Write Sequence, shows > >no repeated start condition between

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-05 Thread Bo Berglund via fpc-pascal
On Wed, 5 Apr 2023 11:40:09 +0200, Christo Crause via fpc-pascal wrote: >Looking at the datasheet for CAT24C128, Fig. 6 Byte Write Sequence, shows >no repeated start condition between register address and data bytes. I >suspect that the second i2c message should contain the I2C_M_NOSTART flag,

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-05 Thread Christo Crause via fpc-pascal
On Wed, Apr 5, 2023 at 11:22 AM Jean SUZINEAU via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > May be you could get the source code of i2ctransfer from i2c-tools and > compare it with the code in i2c.pas ? > Good idea, that led to the suggestion to try the WriteBytes method which is

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-05 Thread Christo Crause via fpc-pascal
On Wed, Apr 5, 2023 at 7:55 AM Bo Berglund via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > On Wed, 05 Apr 2023 00:33:50 +0200, Bo Berglund via fpc-pascal > > I *can* write a sequence of bytes into the EEPROM succsessfully using an > i2c-tools command like this: > > i2ctransfer -y 1

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-05 Thread Jean SUZINEAU via fpc-pascal
May be you could get the source code of i2ctransfer from i2c-tools and compare it with the code in i2c.pas ? ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Bo Berglund via fpc-pascal
On Wed, 05 Apr 2023 00:33:50 +0200, Bo Berglund via fpc-pascal wrote: >On Tue, 4 Apr 2023 23:43:21 +0200, Christo Crause via fpc-pascal > 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

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Bo Berglund via fpc-pascal
On Tue, 4 Apr 2023 23:43:21 +0200, Christo Crause via fpc-pascal wrote: >> if not i2cMaster.WriteBytesToReg(FEEPROMAddr, startaddress, @source[0], >> NumBytes) then >> >> Here the source argument is a TBytes array of bytes so I supply the >> address of >> element 0 as the data argument

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Christo Crause via fpc-pascal
See comments below. On Tue, Apr 4, 2023 at 6:52 PM Bo Berglund via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > I use the method: > > i2cMaster.WriteBytesToReg(i2caddress: byte; regAddress: uint16; data: > PByte; > size: byte): boolean;) > > With data specified as follows in the call:

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Jeffrey A. Wormsley via fpc-pascal
> > Page Write ... > What this means is that if you start in the middle of a 64 byte block, let's say at byte 60 (0 based) which is on page 0, and you write 4 bytes, then you will write into 60, 61, 62 and 63 as expected. But if you write 6 bytes, you will write into bytes 60, 61, 62, 63 and

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-04 Thread Bo Berglund via fpc-pascal
On Sun, 02 Apr 2023 23:21:38 +0200, Bo Berglund via fpc-pascal wrote: >On Sun, 2 Apr 2023 23:14:25 +0200, Christo Crause via fpc-pascal > wrote: > >>On Sun, Apr 2, 2023 at 9:30?PM Bo Berglund via fpc-pascal < >>fpc-pascal@lists.freepascal.org> wrote: >> >>> Is there a reason that there is no

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-03 Thread Bo Berglund via fpc-pascal
On Mon, 03 Apr 2023 15:09:38 -0400, Dennis Lee Bieber via fpc-pascal wrote: >On Mon, 03 Apr 2023 20:55:43 +0200, Bo Berglund via fpc-pascal > declaimed >the following: > >>I just tested by writing four 0x00 bytes in a row, then verifying that the >>memory read shows these, then writing other

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-03 Thread Bo Berglund via fpc-pascal
On Mon, 3 Apr 2023 14:37:48 -0400, "Jeffrey A. Wormsley via fpc-pascal" wrote: >I noticed you put the part number in the original email. > >Interestingly, the data sheet mentions 64 byte pages, and 1,000,000 erase >cycles, but does not mention the need to erase a page before writing. So

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-03 Thread Dennis Lee Bieber via fpc-pascal
On Mon, 03 Apr 2023 20:55:43 +0200, Bo Berglund via fpc-pascal declaimed the following: >I just tested by writing four 0x00 bytes in a row, then verifying that the >memory read shows these, then writing other data and again verifying that the >data is there. > Which may only mean the

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-03 Thread Bo Berglund via fpc-pascal
On Mon, 03 Apr 2023 20:55:43 +0200, Bo Berglund via fpc-pascal >On Mon, 3 Apr 2023 14:26:17 -0400, "Jeffrey A. Wormsley via fpc-pascal" > wrote: > >>I've been using i2c and SPI eeproms for almost two decades. All of them >>can read/write a single byte if that's what you want to do, but the

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-03 Thread Bo Berglund via fpc-pascal
>On Mon, Apr 3, 2023 at 10:53?AM Bo Berglund via fpc-pascal < >fpc-pascal@lists.freepascal.org> wrote: > >> On Mon, 3 Apr 2023 08:42:12 -0400, "Jeffrey A. Wormsley via fpc-pascal" >> wrote: >> >> >> >> >> i2c_read_reg works too inasmuch as it does not error out, but it >> returns FF >> >>

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-03 Thread Jeffrey A. Wormsley via fpc-pascal
I noticed you put the part number in the original email. Interestingly, the data sheet mentions 64 byte pages, and 1,000,000 erase cycles, but does not mention the need to erase a page before writing. So perhaps this part does not have that restriction. If you're making a library specifically

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-03 Thread Jeffrey A. Wormsley via fpc-pascal
I've been using i2c and SPI eeproms for almost two decades. All of them can read/write a single byte if that's what you want to do, but the write/erase restrictions I noted are there for any parts I've ever used. If you write a byte to $00, you cannot write it to $01 without first erasing the

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-03 Thread Bo Berglund via fpc-pascal
On Mon, 3 Apr 2023 08:42:12 -0400, "Jeffrey A. Wormsley via fpc-pascal" wrote: >> >> i2c_read_reg works too inasmuch as it does not error out, but it returns FF >> whatever addres I read like the i2c-tools command does. >> I am not sure that it is correct though... >> > >Yes this is expected, as

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-03 Thread Jeffrey A. Wormsley via fpc-pascal
> > i2c_read_reg works too inasmuch as it does not error out, but it returns FF > whatever addres I read like the i2c-tools command does. > I am not sure that it is correct though... > Yes this is expected, as eeproms erase to $FF. You can write to the same byte as many times as you want, as

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-02 Thread Bo Berglund via fpc-pascal
On Sun, 2 Apr 2023 23:14:25 +0200, Christo Crause via fpc-pascal wrote: >On Sun, Apr 2, 2023 at 9:30?PM Bo Berglund via fpc-pascal < >fpc-pascal@lists.freepascal.org> wrote: > >> Is there a reason that there is no i2c_write_reg demo in the github >> package? >> > >I haven't gotten round to that,

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-02 Thread Christo Crause via fpc-pascal
On Sun, Apr 2, 2023 at 9:30 PM Bo Berglund via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > Is there a reason that there is no i2c_write_reg demo in the github > package? > I haven't gotten round to that, waiting for hardware to test the code with. I will try to write one so I can

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-02 Thread Bo Berglund via fpc-pascal
On Sun, 02 Apr 2023 15:07:48 -0400, Dennis Lee Bieber via fpc-pascal wrote: >On Sun, 02 Apr 2023 16:16:46 +0200, Bo Berglund via fpc-pascal > declaimed >the following: > > >> >> >>Byte Write > >>a location within a 64 byte

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-02 Thread Bo Berglund via fpc-pascal
On Sun, 2 Apr 2023 07:31:43 +0200, Christo Crause via fpc-pascal wrote: >On Sat, Apr 1, 2023 at 9:57?PM Bo Berglund via fpc-pascal < >fpc-pascal@lists.freepascal.org> wrote: > >> Question: >> Can I use Linux file system commands to read/write the data on the i2c >> EEPROM >> memory device and if

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-02 Thread Dennis Lee Bieber via fpc-pascal
On Sun, 02 Apr 2023 16:16:46 +0200, Bo Berglund via fpc-pascal declaimed the following: > > >Byte Write >a location within a 64 byte page. A byte following the >address bytes will be interpreted as data. The data will be

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-02 Thread Bo Berglund via fpc-pascal
On Sun, 02 Apr 2023 10:23:24 +0200, Bo Berglund via fpc-pascal wrote: >On Sun, 2 Apr 2023 07:31:43 +0200, Christo Crause via fpc-pascal > wrote: > >>On Sat, Apr 1, 2023 at 9:57?PM Bo Berglund via fpc-pascal < >>fpc-pascal@lists.freepascal.org> wrote: >> >>> Question: >>> Can I use Linux file

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-02 Thread Bo Berglund via fpc-pascal
On Sun, 2 Apr 2023 07:31:43 +0200, Christo Crause via fpc-pascal wrote: >On Sat, Apr 1, 2023 at 9:57?PM Bo Berglund via fpc-pascal < >fpc-pascal@lists.freepascal.org> wrote: > >> Question: >> Can I use Linux file system commands to read/write the data on the i2c >> EEPROM >> memory device and if

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-02 Thread Bo Berglund via fpc-pascal
On Sat, 1 Apr 2023 20:30:02 -0400, Travis Siegel via fpc-pascal wrote: >Generally, raspberry pi devices connected to other devices will (by >default) use python for their programming.  The python libs have all the >setup and tear down code built in.  You can use C as well, so I see no >reason

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-01 Thread Christo Crause via fpc-pascal
On Sat, Apr 1, 2023 at 9:57 PM Bo Berglund via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > Question: > Can I use Linux file system commands to read/write the data on the i2c > EEPROM > memory device and if so how from fpc? > To some extent it is possible to handle i2c transactions as

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-01 Thread Travis Siegel via fpc-pascal
Generally, raspberry pi devices connected to other devices will (by default) use python for their programming.  The python libs have all the setup and tear down code built in.  You can use C as well, so I see no reason why FPC couldn't be used.  It's probably going to take some work though. 

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-01 Thread Giuliano Colla via fpc-pascal
Il 01/04/2023 21:56, Bo Berglund via fpc-pascal ha scritto: I need to read and write data to an EEPROM connected by I2C on a RaspberryPi4. The I2C channel is found in /dev as i2c-1: $ ll /dev/i2* crw-rw 1 root i2c 89, 1 2019-02-14 11:12 /dev/i2c-1 In this channel the EEPROM CAT24C128 is

Re: [fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-01 Thread Travis Siegel via fpc-pascal
On unix (and all of it's derivatives, everything is a file, including connections to other systems.  You can treat it like a file, and in (most) circumstances, it will operate just as if it were a local file. Some devices require special handling, but for the most part, if it's listed as a

[fpc-pascal] FPC/Lazarus on RPi4 - How to read/write I2C connected EEPROM?

2023-04-01 Thread Bo Berglund via fpc-pascal
I need to read and write data to an EEPROM connected by I2C on a RaspberryPi4. The I2C channel is found in /dev as i2c-1: $ ll /dev/i2* crw-rw 1 root i2c 89, 1 2019-02-14 11:12 /dev/i2c-1 In this channel the EEPROM CAT24C128 is at address 0x50 The data on the device is organized as 256 pages