I2Cwritge - array


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2006
    Location
    Venezuela - Caracas
    Posts
    48

    Default I2Cwritge - array

    i write 4 time 100% no error, after 4 many caracters wrong
    if i use "for" work 100%, but is slow
    for i = 0 to 38
    I2CWRITE MData, MClock, Controle, Posicao_Memoria, [Letra_2(i)]
    Posicao_Memoria = Posicao_Memoria + 1
    PAUSE 5
    next i



    ------------------------------------------------------------------------
    my code

    I var byte
    Controle var Byte
    Posicao_Memoria VAR WORD
    Letra_2 var byte[38]

    Controle = $A0

    WRITE 8, 0
    WRITE 9, 0

    for i = 0 to 38
    Letra_2(i) = i
    next i

    loop:

    ' read adress
    READ 8, Posicao_Memoria.HighByte
    READ 9, Posicao_Memoria.LowByte


    I2CWRITE MData, MClock, Controle, Posicao_Memoria, [STR Letra_2\38]
    Posicao_Memoria = Posicao_Memoria + 38
    PAUSE 5


    ' write adress
    WRITE 8, Posicao_Memoria.HighByte
    WRITE 9, Posicao_Memoria.LowByte

    goto loop

  2. #2
    Join Date
    Aug 2004
    Posts
    64


    Did you find this post helpful? Yes | No

    Default I2C write

    Hi:
    What EEPROM are you using.?. I think it is a 24LC32 or bigger,because the word address.
    You must make the pause for each Write of 10 ms. Some memories do not like only 5.
    Greetings...
    Ruben de la Pena

  3. #3
    Join Date
    Jul 2007
    Posts
    53


    Did you find this post helpful? Yes | No

    Default Pages write problem, I think.

    Most EEPROM use a cache page of 8 bytes. You may encounter all kinds of problems if you try to write the same page in two subsequent write operations.Thus, I think it will be better to go with multiples of 8. Meaning you will use 40 instead of 38 in this statement: "Posicao_Memoria = Posicao_Memoria + 38". And the rest of the code should obviously go according to this. And yes, you probably need 10ms pause anyways.

    Have a look at the datasheet to understand the difference between page write and byte write. You will find some other valuable informations too!

    J-P

  4. #4
    Join Date
    Sep 2006
    Location
    Venezuela - Caracas
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    thanks brothers for help
    i'll try multiples of 8

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Simple Array Demo
    By Archangel in forum Code Examples
    Replies: 5
    Last Post: - 15th February 2010, 04:46
  3. Array values changing
    By MyBuddy in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th October 2009, 23:13
  4. RS232 receive an array (packet)
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th February 2008, 05:02
  5. If Then Array Oddity
    By atillotson in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 1st July 2005, 17:46

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts