I2CWRITE problem


Closed Thread
Results 1 to 36 of 36

Hybrid View

  1. #1
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    Whether you use a word or byte address depends on the EEPROM device.
    It's in the manual for I2CREAD.

  2. #2
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Default

    Address size depends on EEPROM size (see table)
    PicBasic Manual I2C -part
    (2 bytes = 1 word)

    Manual is Your friend

    BR,
    -Gusse-
    Last edited by Gusse; - 26th January 2010 at 10:24. Reason: Repeating same as Art ;)

  3. #3
    Join Date
    Jan 2010
    Location
    morocco
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by art View Post
    whether you use a word or byte address depends on the eeprom device.
    It's in the manual for i2cread.

    yeah but when u use xxx var byte

    for xxx = 0 to 255 it works
    THE PROBLEM IS WHEN IT COUNT FROM 0 TO 1023 IN WORD VAR IT DOES SOMETHING WRONG IM OUT FOR JOB WILL TRY LATER TAKE CARE EVERYONES I KNOW U WILL FINDOUT


    try it out
    Last edited by MR2010; - 26th January 2010 at 10:24.

  4. #4
    Join Date
    Jul 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    I have been reading this discussion with interest as I have had a similiar problem to yours.

    What I tried to do was to write 32 words in a word array to a 24LC256. Initially my micro was the 18F452, but I have moved over to the 18F4680. Both devices gave the same problem. My line of code was:

    DATA var WORD [31]
    AA var WORD
    I2WR var byte
    I2ADDR var WORD

    I2CWRITE PORTC.4, PORTC.3, I2WR, I2ADDR, [ STR DATA\32 ], I2C_ERR

    I would then read the data back as single words:

    I2CREAD PORTC.4, PORTC.3, I2RD, I2ADDR, [ AA ], I2C_ERR


    When I read the data back, I would repeatedly read some correct data, a bunch of $FFFF, more correct data, then the data would appear to 'move' and would not be at the designated eprom address. All very strange, but whats more it was repeatable within locations of the device.

    The device data sheet specifiies that it can read and write a page of 64 bytes, (32 words).

    I over came the problem by writing each word in the word array individually, pausing 5 ms between each word write. Not the best solution but it work. This way wastes 160ms of processing time.

    I am still trying to find a way to solve my problem as I really need to write the data block in one hit. I might try using the hardware I2C technique next as I2CWRITE ... [ STR DATA\32] didn't work for me.


    Paul.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    Paul, I notice that you have only declared 31 WORDS but you are loading the eeprom with 32 BYTES. You can only load individual BYTES into the eeprom even if they are in an array. You would be loading the LOWBYTE of each of the words in the DATA array into the eeprom. Even then, you have only declared 31 words and not 32.

    Dave Purola,
    N8NTA

  6. #6
    Join Date
    Jul 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Dave View Post
    Paul, I notice that you have only declared 31 WORDS but you are loading the eeprom with 32 BYTES. You can only load individual BYTES into the eeprom even if they are in an array. You would be loading the LOWBYTE of each of the words in the DATA array into the eeprom. Even then, you have only declared 31 words and not 32.

    Dave Purola,
    N8NTA

    Hi Dave,

    That is correct, the 1st element in the array, DATA[0], the second element DATA[1], the 32nd DATA[31].

    The STR command counts the elements in an array, [ STR DATA\1] would send element DATA[0]. PBPro knows if I am using WORDS or BYTES and counts them appropriately.

    In this section of the PBPro manual, it clearly states that WORD variable arrays can be sent.

    Paul.

  7. #7
    Join Date
    Dec 2007
    Location
    Finland
    Posts
    191


    Did you find this post helpful? Yes | No

    Post

    Quote Originally Posted by Paul View Post
    Hi Dave,

    That is correct, the 1st element in the array, DATA[0], the second element DATA[1], the 32nd DATA[31].

    The STR command counts the elements in an array, [ STR DATA\1] would send element DATA[0]. PBPro knows if I am using WORDS or BYTES and counts them appropriately.

    In this section of the PBPro manual, it clearly states that WORD variable arrays can be sent.

    Paul.
    Hi Paul,

    Check from manual about Arrays

    It is two different things:
    - Number of elements (array; 1,2,3,... )
    - Location of element (string; 0,1,2,... )

    BR,
    -Gusse-
    Last edited by Gusse; - 26th January 2010 at 13:41.

  8. #8
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default

    Just to elaborate on the problem,
    The middle part of this video shows the function that writes to EEPROM.
    The messages are short because I can only type about 15 letters before
    the first one stuffs up.
    Each letter requires 6 bytes because they are stored as mono bitmaps,
    and there is some lead in space written with zeros.



    Art.

  9. #9
    Join Date
    Jul 2005
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Gusse View Post
    Hi Paul,

    Check from manual about Arrays

    It is two different things:
    - Number of elements (array; 1,2,3,... )
    - Location of element (string; 0,1,2,... )

    BR,
    -Gusse-

    I had read this section of the manual sometime ago, and have obviously forgotten. Thank you Gusse, Art and Dave. It is good to be corrected and shown your error. Even with the change in array declaration, my page write I2C routine still will not work and exhibit the previously described problem. I will look at the physical aspects of the design (hardware), failing that attempt the hardware I2C routine. I have found some examples of code in the forums.

    Paul

Similar Threads

  1. My I2CWRITE - timings and tricks
    By FinchPJ in forum Code Examples
    Replies: 5
    Last Post: - 3rd March 2008, 21:40
  2. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 6th June 2006, 20:03
  3. Problem with I2Cread and I2CWRITE function
    By Tony85 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th June 2006, 18:32
  4. Another I2CWRITE problem
    By ErnieM in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 20th May 2006, 21:57
  5. I2CRead / I2CWrite Problem?
    By koossa in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st October 2005, 18:26

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