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!
I2C test
-
- Posts: 47
- http://meble-kuchenne.info.pl
- Joined: Sat Jul 10, 2021 2:43 pm
- Has thanked: 12 times
- Been thanked: 6 times
Re: I2C test
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!
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
Hi Martin,
Of course I have attached the fc file.
Of course I have attached the fc file.
- Attachments
-
- test eeprom.fcfx
- (18.95 KiB) Downloaded 108 times
-
- Valued Contributor
- Posts: 1462
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 136 times
- Been thanked: 713 times
Re: I2C test
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
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
- Attachments
-
- test eeprom.fcfx
- (18.4 KiB) Downloaded 107 times
-
- Valued Contributor
- Posts: 1462
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 136 times
- Been thanked: 713 times
Re: I2C test
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
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