Page 3 of 4
Re: I2C test
Posted: Sat Oct 12, 2024 11:14 am
by samtin
Hi Martin,
Yes, you have really been a great help and I thank you. When you have time and if you want, tell me how I should proceed when I change the source code to "FC_Comp_Source_Serial_EEPROM_(24LC512)" for example, how to get the fcpx file.
All the best!
Re: I2C test
Posted: Sat Oct 12, 2024 4:27 pm
by samtin
Hi Martin,
Now I noticed that I actually used another component in the test, instead of using the 24LC256 component.
The 24LC256 does not work, the eeprom component is not visible on the 2D panel, and in the properties I do not have the option to write at least one byte, in the data field it does not allow me to add parentheses, when editing the data variable in the initial value field I passed 4 bytes, but did not store them in the eeprom locations starting from address 0.
All the best!
Re: I2C test
Posted: Sat Oct 12, 2024 4:30 pm
by mnfisher
The component I did doesn't simulate - it will only run on hardware (in the bad old days you had to pay for components)
Can you post your code so far?
Martin
Re: I2C test
Posted: Sat Oct 12, 2024 4:39 pm
by samtin
Hi Martin,
Of course I have attached the fc file.
Re: I2C test
Posted: Sat Oct 12, 2024 6:23 pm
by mnfisher
Looks like this should work on hardware (you might need to change the capacity if you have 512Kb chip)
Note that it will do nothing in simulation (sorry) - and that Read and Write only work on an array of data - so if you have
ReadData(data, 4) - it will read 4 bytes into data (which needs to have room for this) so this doesn't need to be in a loop.
StartRead(0)
ReadData(data, 4) // Read bytes 0,1,2,3 to data
ReadData(d1, 4) // Read bytes 4,5,6,7 to d1
Similarly - WriteData(data, 4) will write 4 bytes to the eeprom (and increment the address by 4) so:
StartWrite(0)
WriteData(data, 4) // Write to addresses 0,1,2,3
WriteData(d1, 4) // Write to address 4,5,6,7
Note that the size can be more or less than 4 (depending the size of data / d1) - and data needs to be an array (this makes reading a single byte slightly more convoluted - ReadByte(data, 1) then need x = data[0]
I've tweaked and commented a few lines of your code.
Martin
Re: I2C test
Posted: Sun Oct 13, 2024 9:52 am
by samtin
Good morning,
The data to be written are taken from the initial value {0, 1, 2, 3}.
Is there another option where other data can be written apart from those in the initial value?
Re: I2C test
Posted: Sun Oct 13, 2024 10:07 am
by mnfisher
Yes, just set data to the values you exam to write.
StartWrite(address) sets the address to start writing the data to.
So
StartWrite(23)
data[0]=56
data[1] =99
WriteData(data, 2)
Will write 56, 99 to addresses 23 and 24 in the Eeprom
Re: I2C test
Posted: Sun Oct 13, 2024 11:38 am
by samtin
Perfect, I will try to test on the board. Now I make some notifications for some previous studies.
Thanks Martin
Re: I2C test
Posted: Sun Oct 13, 2024 11:58 am
by mnfisher
Please let us know how it goes

Re: I2C test
Posted: Mon Oct 14, 2024 1:55 pm
by samtin
Hi Martin,
It works perfectly, I'll come back later with a more concise flowchart, I have to delete the components that I no longer need.