I2C V6
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C V6
Hello Brian,
We do not currently have an I2C Slave component in v6 but there is an example of chip to chip comms using I2C available from here.
http://www.matrixmultimedia.com/mmforum ... f=7&t=7081
The I2C slave component is on the ever growing to do list but hopefully we should get round to it soon.
We do not currently have an I2C Slave component in v6 but there is an example of chip to chip comms using I2C available from here.
http://www.matrixmultimedia.com/mmforum ... f=7&t=7081
The I2C slave component is on the ever growing to do list but hopefully we should get round to it soon.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Hi guys
I'm very lost Iv'e tried to write a small program to understand how to write a 13 digit number into 4 mem locations, what I have done is split the 13 digit (999 999 999 9999) numbers into 4 variables then write then into mem location 1 to 4 via I2C but cant seem to get it working can someone please tell me what I'm doing wrong. I have tested this program on the hardware where I have a EB006-00-8 board with PIC16F1939 chip Iv'e connected a AT24C06N mem chip, the SCL & SDA of the chip is pulled up with 5k6 resistors. The program seams to write the data (not sure if it is writing the correct data) but it dose not read the data back correctly.
I have also tried the EEPROM read and write V3 example I found on on the forum but that also give me the wrong data back it sends 6 7 8 9 and receive back 9 9 9 9
Brian
I'm very lost Iv'e tried to write a small program to understand how to write a 13 digit number into 4 mem locations, what I have done is split the 13 digit (999 999 999 9999) numbers into 4 variables then write then into mem location 1 to 4 via I2C but cant seem to get it working can someone please tell me what I'm doing wrong. I have tested this program on the hardware where I have a EB006-00-8 board with PIC16F1939 chip Iv'e connected a AT24C06N mem chip, the SCL & SDA of the chip is pulled up with 5k6 resistors. The program seams to write the data (not sure if it is writing the correct data) but it dose not read the data back correctly.
I have also tried the EEPROM read and write V3 example I found on on the forum but that also give me the wrong data back it sends 6 7 8 9 and receive back 9 9 9 9
Brian
- Attachments
-
- 3. EEPROM read and write V3.fcf
- (19.88 KiB) Downloaded 380 times
-
- Test read write mem.fcf
- (56.58 KiB) Downloaded 355 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C V6
Hello Brian,
It looks like in your program you are storing the numbers into 32-bit long variables however a unsigned long variable can only hold 0 - 4294967295.
Do you ever need to 13-digit number to be calculated etc? If so then you will likely need to use 2 long variables and process them individually.
Either way a I2C read or write transaction can only ever transfer 8-bits of data at a time, and if your using a external memory device I would usually expect this to be 8-bit blocks also.
Lets simplify things for a minute. say we have a 16-bit number stored in a unsigned int type variable representing a value from 0 - 65535. to send this via I2C we first need to chop the 16-bits up into 2 sets of 8-bits.
LSB = UINT & 0xFF
MSB = (UINT >> 8 ) & 0xFF
to recombine the two bytes when reading back we would need to do something like this.
UINT = LSB | (MSB << 8 )
Now a 32-bit long can be done in a similar way but some devices may have problems shifting more than 16-bits so the following may not always work.
B0 = ULONG & 0xFF
B1 = (ULONG >> 8 ) & 0xFF
B2 = (ULONG >> 16) & 0xFF
B3 = (ULONG >> 24) & 0xFF
and to recombine
UINT = B0 | (B1 << 8 )
UINT = UINT | (B2 << 16)
UINT = UINT | (B2 << 24)
As for a 13 digit number I think you might struggle, a 13-character string would be simple enough to store and manipulate if you don't need the numeric representation of the number for calculations etc. To do this you would simply send each of the bytes in the string until you hit the 0 null terminator.
It looks like in your program you are storing the numbers into 32-bit long variables however a unsigned long variable can only hold 0 - 4294967295.
Do you ever need to 13-digit number to be calculated etc? If so then you will likely need to use 2 long variables and process them individually.
Either way a I2C read or write transaction can only ever transfer 8-bits of data at a time, and if your using a external memory device I would usually expect this to be 8-bit blocks also.
Lets simplify things for a minute. say we have a 16-bit number stored in a unsigned int type variable representing a value from 0 - 65535. to send this via I2C we first need to chop the 16-bits up into 2 sets of 8-bits.
LSB = UINT & 0xFF
MSB = (UINT >> 8 ) & 0xFF
to recombine the two bytes when reading back we would need to do something like this.
UINT = LSB | (MSB << 8 )
Now a 32-bit long can be done in a similar way but some devices may have problems shifting more than 16-bits so the following may not always work.
B0 = ULONG & 0xFF
B1 = (ULONG >> 8 ) & 0xFF
B2 = (ULONG >> 16) & 0xFF
B3 = (ULONG >> 24) & 0xFF
and to recombine
UINT = B0 | (B1 << 8 )
UINT = UINT | (B2 << 16)
UINT = UINT | (B2 << 24)
As for a 13 digit number I think you might struggle, a 13-character string would be simple enough to store and manipulate if you don't need the numeric representation of the number for calculations etc. To do this you would simply send each of the bytes in the string until you hit the 0 null terminator.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Hi Benj
Thanks what I'm trying to do is send an address from 0 to 999 and then a 10 digit phone number then which once stored correctly I then will send the address and scan through the mem and compare the address until they mach then read the phone number that corresponds back and send it to a GSM module to call. I will give this a try and see or is there an easier way to do this that you could recommend?
Brian
Thanks what I'm trying to do is send an address from 0 to 999 and then a 10 digit phone number then which once stored correctly I then will send the address and scan through the mem and compare the address until they mach then read the phone number that corresponds back and send it to a GSM module to call. I will give this a try and see or is there an easier way to do this that you could recommend?
Brian
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Hi Benj
What Iv"e done is the following
Data_In = Tel_add & 0xFF
Data_In1 = Tel_add >> 8
How will I insert (Data_in and Data_In1) variables into the MI2C_Send_Byte_Transaction(DeviceID, AddH,AddL,Data[Index])
I also have anther problem I have picked up is when i change a string to an INT "07410" i loose the 0 -7410 at the beginning which is no good, how can i send a string of ASCII characters to mem via I2C
Brian
What Iv"e done is the following
Data_In = Tel_add & 0xFF
Data_In1 = Tel_add >> 8
How will I insert (Data_in and Data_In1) variables into the MI2C_Send_Byte_Transaction(DeviceID, AddH,AddL,Data[Index])
I also have anther problem I have picked up is when i change a string to an INT "07410" i loose the 0 -7410 at the beginning which is no good, how can i send a string of ASCII characters to mem via I2C
Brian
-
- Posts: 243
- Joined: Tue Nov 27, 2012 12:53 pm
- Location: Cambridge, UK
- Has thanked: 140 times
- Been thanked: 118 times
- Contact:
Re: I2C V6
Hi Brian.
I think what I might do in such situations is define/use separate byte-wide arrays (e.g... ID Hi-Byte, ID Lo-Byte, Data Hi-Byte, Data Lo-Byte, etc), commonly indexed from a variable or loop counter. You always know where you are and has saved me a few headaches in the past
It's then a simple matter of sequentially referencing the respective bytes from each array in-turn (at a given index value) when reading/writing byte-wide transactions over I2C.
Also, if you're converting a string of non-numerical characters, they must be processed as ASCII values, picked off by indexing each character as you work along the string in question. This would then include (and preserve) the way in which the string is originally represented - including spaces, dashes, etc.
All the best,
Brendan
I think what I might do in such situations is define/use separate byte-wide arrays (e.g... ID Hi-Byte, ID Lo-Byte, Data Hi-Byte, Data Lo-Byte, etc), commonly indexed from a variable or loop counter. You always know where you are and has saved me a few headaches in the past
It's then a simple matter of sequentially referencing the respective bytes from each array in-turn (at a given index value) when reading/writing byte-wide transactions over I2C.
Also, if you're converting a string of non-numerical characters, they must be processed as ASCII values, picked off by indexing each character as you work along the string in question. This would then include (and preserve) the way in which the string is originally represented - including spaces, dashes, etc.
All the best,
Brendan
LinkedIn Profile...
http://www.linkedin.com/in/brendantownsend
http://www.linkedin.com/in/brendantownsend
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Hi Brendan
Thanks for the reply am i correct in doing this to to process the ASCII characters Char_Data[Index] = Char$ (S_tring,Index) and go through a loop till i reach the 13th Character? or must i split the S_tring into 4 bit variables then process each one for a different mem location in loops? I understand one mem location only goes to 255 (11111111) so if i want to send this number of ASCII characters how will i do it? Also can i send 4 ASCII characters to 1 mem location?
I'm not sure of how to change the different mem locations via I2C 0 - 4080 for the 24C04 do you have an examples. I can do it without a problem to the PIC16 on board EEPROM but the I2C has stopped me dead in my tracks for about 2 weeks now.
Brian
Thanks for the reply am i correct in doing this to to process the ASCII characters Char_Data[Index] = Char$ (S_tring,Index) and go through a loop till i reach the 13th Character? or must i split the S_tring into 4 bit variables then process each one for a different mem location in loops? I understand one mem location only goes to 255 (11111111) so if i want to send this number of ASCII characters how will i do it? Also can i send 4 ASCII characters to 1 mem location?
I'm not sure of how to change the different mem locations via I2C 0 - 4080 for the 24C04 do you have an examples. I can do it without a problem to the PIC16 on board EEPROM but the I2C has stopped me dead in my tracks for about 2 weeks now.
Brian
- petesmart
- Valued Contributor
- Posts: 395
- Joined: Thu May 06, 2010 11:42 am
- Location: Sydney, Australia
- Has thanked: 187 times
- Been thanked: 140 times
- Contact:
Re: I2C V6
Just a thought... May not be helpful... Could you use an array d1, d2 etc. to store the telephone numbers....that way you can easily pump out variable by variable using i2c 8 bits per variable ..
Pete
Pete
sorry about that Chief!
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C V6
Hello,
http://www.asciitable.com/
Each ASCII character consumes 1 byte of memory so it's 1 character per byte.
A string is essentially the same as an array of bytes with each character in the string representing an ASCII graphic e.g. 48 = the graphic for the number zero = '0'
The string is terminated with a byte = 0 or null in ASCII and this is used to let the software know where the string ends so we don't start trying to interpret other potentially numeric variables as ASCII.
Each character in the string can be accessed by using array notation.
Each data byte you send will automatically increment the internal address pointer.
Same applies for reading back the bytes.
So to copy the contents of a string to the start of the EEPROM would look something like this.
Hope some of this info will help.
Here is the standard ASCII table, you can see that the values go from 0-127 for standard ASCII and 128 - 255 for extended ASCII.I understand one mem location only goes to 255 (11111111) so if i want to send this number of ASCII characters how will i do it?
http://www.asciitable.com/
Each ASCII character consumes 1 byte of memory so it's 1 character per byte.
A string is essentially the same as an array of bytes with each character in the string representing an ASCII graphic e.g. 48 = the graphic for the number zero = '0'
The string is terminated with a byte = 0 or null in ASCII and this is used to let the software know where the string ends so we don't start trying to interpret other potentially numeric variables as ASCII.
Each character in the string can be accessed by using array notation.
Code: Select all
StrVar = "07877777777777"
length = Length$(StrVar)
Index = 0
while (Index < Length)
{
I2C Send Byte - StrVar[Index]
Index = Index + 1
}
Hopefully this is answered above, 1 ASCII character = 1 byte.Also can i send 4 ASCII characters to 1 mem location?
The I2C write transaction should look something like this.I'm not sure of how to change the different mem locations via I2C 0 - 4080 for the 24C04 do you have an examples.
Code: Select all
I2C Start
I2C Send Byte - External Device Address (Write Mode)
I2C Send Byte - Internal Address MSB
I2C Send Byte - Internal Address LSB
I2C Send Byte - Data Byte 0
....
I2C Send Byte - Data Byte n
I2C Stop
Same applies for reading back the bytes.
Code: Select all
I2C Start
I2C Send Byte - External Device Address (Write Mode)
I2C Send Byte - Internal Address MSB
I2C Send Byte - Internal Address LSB
I2C Restart
I2C Send Byte - External Device Address (Read Mode)
Data Byte 0 = I2C Receive Byte - Last = 0
....
Data Byte n = I2C Receive Byte - Last = 1
I2C Stop
Code: Select all
StrVar = "07877777777777"
length = Length$(StrVar)
Index = 0
I2C Start
I2C Send Byte - External Device Address (Write Mode)
I2C Send Byte - Internal Address MSB - 0
I2C Send Byte - Internal Address LSB - 0
while (Index < Length)
{
I2C Send Byte - StrVar[Index]
Index = Index + 1
}
I2C Stop
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Hi Benj
Thanks for this think I'm sort of getting it Iv'e attached a test program could you please tell me if I'm on the right track. Also am I correct in saying that if i have a string of "9999999999999" and i send this to the mem starting at address 0 it will automatically after the first 8 bytes go to mem location 1 and put the next 8 bytes and so on
Brian
Thanks for this think I'm sort of getting it Iv'e attached a test program could you please tell me if I'm on the right track. Also am I correct in saying that if i have a string of "9999999999999" and i send this to the mem starting at address 0 it will automatically after the first 8 bytes go to mem location 1 and put the next 8 bytes and so on
Brian
- Attachments
-
- Test read write mem1.fcf
- (34.69 KiB) Downloaded 254 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C V6
Hello Brian,
I've made a few minor changes to your file but I think your on this right track.
The internal I2C address is incremented with every byte read or written so you only have to provide the starting address of the data.
I've made a few minor changes to your file but I think your on this right track.
The internal I2C address is incremented with every byte read or written so you only have to provide the starting address of the data.
- Attachments
-
- Test read write mem1.fcf
- (36.29 KiB) Downloaded 284 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Hi Benj
Thanks i can see exsactly how its done now one question when i download this to hardware it runs through the sequance but only displays a bunch of squares when i print the string variable do you hav any idear why? I understand that In simulation it only displays 255 as there is know real chip connected
Brian
Thanks i can see exsactly how its done now one question when i download this to hardware it runs through the sequance but only displays a bunch of squares when i print the string variable do you hav any idear why? I understand that In simulation it only displays 255 as there is know real chip connected
Brian
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: I2C V6
Hi Brian,
I'm looking for the datasheet for the AT24C06N EEPROM device your using to try and check that your program completely meshes up with the protocol used by the memory IC.
I can find some but they have slightly different part numbers e.g. "CAT24C018J", do you have a direct link to the specific datasheet for your device so I know i'm looking at the right info.
I'm looking for the datasheet for the AT24C06N EEPROM device your using to try and check that your program completely meshes up with the protocol used by the memory IC.
I can find some but they have slightly different part numbers e.g. "CAT24C018J", do you have a direct link to the specific datasheet for your device so I know i'm looking at the right info.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Hi Benj
The chip i have is an ATMLU 110 04B i have searched for the data sheet using this number and all serches come to Atmel 24C04B so i asume it is this chip but tomorrow i will go get another chip with better markings. I also have 20 of the Atmel 612 24C04N SOIC pins 1 to 4 are grounded 5 & 6 is pulled up with 4k7, 7 N/C 8 +5V so not sure whats up with this one.
Brian
The chip i have is an ATMLU 110 04B i have searched for the data sheet using this number and all serches come to Atmel 24C04B so i asume it is this chip but tomorrow i will go get another chip with better markings. I also have 20 of the Atmel 612 24C04N SOIC pins 1 to 4 are grounded 5 & 6 is pulled up with 4k7, 7 N/C 8 +5V so not sure whats up with this one.
Brian
- Attachments
-
- AT24C04N Mem Chip.pdf
- (620.38 KiB) Downloaded 428 times
Last edited by jollybv on Fri Jun 06, 2014 6:14 am, edited 1 time in total.
-
- Posts: 243
- Joined: Tue Nov 27, 2012 12:53 pm
- Location: Cambridge, UK
- Has thanked: 140 times
- Been thanked: 118 times
- Contact:
Re: I2C V6
Hi Brian.
Just checking my posts and saw your last comment. I've one observation...
Pin 7 (WP) must not be left NC/floating. It must be connected/driven to either ground for read/write operation or driven high for read-only.
All the best,
Brendan
Just checking my posts and saw your last comment. I've one observation...
Pin 7 (WP) must not be left NC/floating. It must be connected/driven to either ground for read/write operation or driven high for read-only.
All the best,
Brendan
LinkedIn Profile...
http://www.linkedin.com/in/brendantownsend
http://www.linkedin.com/in/brendantownsend
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Thanks Brendan
Have pulled down pin 7 with no luck but will keep that in mind when i go to make the board.
Brian
Have pulled down pin 7 with no luck but will keep that in mind when i go to make the board.
Brian
-
- Posts: 243
- Joined: Tue Nov 27, 2012 12:53 pm
- Location: Cambridge, UK
- Has thanked: 140 times
- Been thanked: 118 times
- Contact:
Re: I2C V6
Thanks Brian - and good luck with the project.
Not so very long ago I created a little programming jig to pull the WP low (when detected by hand-applied probe) and program/verify predefined bytes to an I2C EEPROM. Whilst I'm not at liberty to share most projects developed for professional applications you'll understand, I could extract the relevant part that programs the device to give you a few pointers if needed
All the best,
Brendan
EDIT: I've just discovered I have an earlier incarnation of the program on my laptop, so I've edited the data table and able to provide you with this example
Not so very long ago I created a little programming jig to pull the WP low (when detected by hand-applied probe) and program/verify predefined bytes to an I2C EEPROM. Whilst I'm not at liberty to share most projects developed for professional applications you'll understand, I could extract the relevant part that programs the device to give you a few pointers if needed
All the best,
Brendan
EDIT: I've just discovered I have an earlier incarnation of the program on my laptop, so I've edited the data table and able to provide you with this example
- Attachments
-
- Flat_Babel_I2C_EEPROM_Programming_Example_For_Forums.fcfx
- (22.54 KiB) Downloaded 255 times
LinkedIn Profile...
http://www.linkedin.com/in/brendantownsend
http://www.linkedin.com/in/brendantownsend
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Thanks Brendan
This is much appreciated I modified this program so I can input the data via the keypad its working great Am I correct in saying that this writes to 2 mem locations each of 8 bytes?? If so it will write to mem location 1 & 2 now if I want to store a second 13 digit number where would I put the put an instruction to change the mem address. e.g 001 123 456 7890 in mem location 1 & 2 I now want to store 002 666 666 6666 in mem location 3 & 4 I have made a variable called EEPROM_Add that changes the address but have no clue where to insert it into this the program.
Brian
This is much appreciated I modified this program so I can input the data via the keypad its working great Am I correct in saying that this writes to 2 mem locations each of 8 bytes?? If so it will write to mem location 1 & 2 now if I want to store a second 13 digit number where would I put the put an instruction to change the mem address. e.g 001 123 456 7890 in mem location 1 & 2 I now want to store 002 666 666 6666 in mem location 3 & 4 I have made a variable called EEPROM_Add that changes the address but have no clue where to insert it into this the program.
Brian
- Attachments
-
- I2C_EEPROM_Programming_Example.fcfx
- (28.94 KiB) Downloaded 248 times
-
- Posts: 243
- Joined: Tue Nov 27, 2012 12:53 pm
- Location: Cambridge, UK
- Has thanked: 140 times
- Been thanked: 118 times
- Contact:
Re: I2C V6
Hello Brian.
Glad to hear that it helped you out
If you look at macro 'Write_EEPROM', the header is first created and sent to address the EEPROM physically wired for 'EEPROM_Address', and the immediately-following loop function repeats for each data byte to be sent, exiting when the loop has sent all bytes in the array. The number of bytes that I'd set it to program (controlled by the constant 'Total_Data_Bytes_To_Process') is 16, and to burst-write the data it therefore sends...
Wired EEPROM Address + Write Notifier bit (='0' compare this to the read macro) + Data Start Address + 16 bytes at 16 EEPROM auto-incremented address locations.
In other words, 16 individual bytes to 16 incremented memory locations (you can only write one byte at a time). You will see what's happening if you follow the code when read in conjunction with the EEPROM manual.
I'm so sorry that I've too limited time to reliably jump in and support private projects, but hopefully the working code you now have and info above will give you a good starting point, to first and foremost focus on your storage strategy before you start serious coding. Also plenty of supporters more expert than I in the Matrix forums
All the best,
Brendan
Glad to hear that it helped you out
If you look at macro 'Write_EEPROM', the header is first created and sent to address the EEPROM physically wired for 'EEPROM_Address', and the immediately-following loop function repeats for each data byte to be sent, exiting when the loop has sent all bytes in the array. The number of bytes that I'd set it to program (controlled by the constant 'Total_Data_Bytes_To_Process') is 16, and to burst-write the data it therefore sends...
Wired EEPROM Address + Write Notifier bit (='0' compare this to the read macro) + Data Start Address + 16 bytes at 16 EEPROM auto-incremented address locations.
In other words, 16 individual bytes to 16 incremented memory locations (you can only write one byte at a time). You will see what's happening if you follow the code when read in conjunction with the EEPROM manual.
I'm so sorry that I've too limited time to reliably jump in and support private projects, but hopefully the working code you now have and info above will give you a good starting point, to first and foremost focus on your storage strategy before you start serious coding. Also plenty of supporters more expert than I in the Matrix forums
All the best,
Brendan
LinkedIn Profile...
http://www.linkedin.com/in/brendantownsend
http://www.linkedin.com/in/brendantownsend
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Hi guys
This is driving me mad spent the whole day and have got no further. What I understand 1 Char = 1 Byte witch is 8 bits which is 1 mem location so to store 13 Char i will need 13 mem locations for each Char first 13 Char = 0 - 12 second 13 Char = 13-25 and so on which is using lots of memory is there a way to use less memory?? as I want to be able to store 1000 numbers in a 4k mem chip or is this impossible. Also i really cant see how i can change from mem location. For example if I'm at mem location 0 and want to read / write to mem location 13 where do i do this in the I2C?? I'n the data sheet you send the Device address and the read or write bit, then you send an 8 bit data word i assume this is for the mem location so for mem location 0 this Data word will be 0 and for mem location 13 it should be 13 or is this wrong.
Brian
This is driving me mad spent the whole day and have got no further. What I understand 1 Char = 1 Byte witch is 8 bits which is 1 mem location so to store 13 Char i will need 13 mem locations for each Char first 13 Char = 0 - 12 second 13 Char = 13-25 and so on which is using lots of memory is there a way to use less memory?? as I want to be able to store 1000 numbers in a 4k mem chip or is this impossible. Also i really cant see how i can change from mem location. For example if I'm at mem location 0 and want to read / write to mem location 13 where do i do this in the I2C?? I'n the data sheet you send the Device address and the read or write bit, then you send an 8 bit data word i assume this is for the mem location so for mem location 0 this Data word will be 0 and for mem location 13 it should be 13 or is this wrong.
Brian
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
- Contact:
Re: I2C V6
Yes, for a simple write of one data byte, with I2C, you need a 3 byte sequence.
First the Device Address (0xA0),
then the EEPROM address (0 to 13 as you say),
then the data byte to be stored.
(See page 12 of the Atmel datasheet)
btw. AT24CS04 is 4K bits, not bytes
First the Device Address (0xA0),
then the EEPROM address (0 to 13 as you say),
then the data byte to be stored.
(See page 12 of the Atmel datasheet)
btw. AT24CS04 is 4K bits, not bytes
- jollybv
- Flowcode v5 User
- Posts: 374
- Joined: Thu Feb 12, 2009 5:20 am
- Location: Cape Town
- Has thanked: 81 times
- Been thanked: 25 times
- Contact:
Re: I2C V6
Hi leigh
Thanks when I transmitt the data it seems to send the correct data to the chip I think but dose not seem to move its locations i say for instants send the data to location 3 witch = mem location 26 it writes and reads it back correct but say Iv'e program a few mem locations 001 = 0 (111 111 1111) and location 002 = 13 (222 222 2222) location 003 = 26 (333 333 3333)when i read back the mem locations it always shows me the last number I programmed into memory e.g 001 = 0 (333 333 3333) 002 = 13 (333 333 3333) 003 = 26 (333 333 3333) (0, 13, 26 are the mem locations I'm transmitting after Device Address) so now I'm now very confused.
Brian
Thanks when I transmitt the data it seems to send the correct data to the chip I think but dose not seem to move its locations i say for instants send the data to location 3 witch = mem location 26 it writes and reads it back correct but say Iv'e program a few mem locations 001 = 0 (111 111 1111) and location 002 = 13 (222 222 2222) location 003 = 26 (333 333 3333)when i read back the mem locations it always shows me the last number I programmed into memory e.g 001 = 0 (333 333 3333) 002 = 13 (333 333 3333) 003 = 26 (333 333 3333) (0, 13, 26 are the mem locations I'm transmitting after Device Address) so now I'm now very confused.
Brian
- Attachments
-
- I2C_EEPROM_Programming_Example.fcfx
- (36.07 KiB) Downloaded 254 times
Last edited by jollybv on Tue Jun 10, 2014 5:25 am, edited 1 time in total.