Eeprom Word Addressing


Closed Thread
Results 1 to 9 of 9
  1. #1
    Simon Brodeur's Avatar
    Simon Brodeur Guest

    Default Eeprom Word Addressing

    I'm trying to write 16bit values from an accelerometer to a 256K external 12C EEPROM. To values should be turning around 1000. . I have some problem reading and/or writing the values.

    I use the I2CREAD and I2CWRITE commands,with:
    cbit = %1010000

    When I read result, on the serial communicator, it looks of this:

    1024
    64367
    1016
    63290
    1032
    62986
    ...

    I think the problem is the address variable
    When I write word, in the form like:
    I2CWRITE SDA,SCL,cbit,address,[word]

    Will I have to increment address by 2 to write the next consecutive word?
    Will it be the same for the I2CREAD?

    I tried several manner of writing and reading and it didn't help me...

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    that's true. An eeprom store a byte in each address location ( well those i know and use). So if you want to store a word... it will need to adresses. That's not a bug
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Simon Brodeur's Avatar
    Simon Brodeur Guest


    Did you find this post helpful? Yes | No

    Default

    Also, will any previous value at the same address be overwrited?

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    As long as you increment/decrement your address by 2 you shouldn't overwrite any previous/next data.

    Writing to the same adress ( let's say $06) will overwrite the previous value wich was @ $06 and $07
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Hi, Simon

    I had the same problem with EEprom 16 bits storing ...

    a simple way is to trucate values into Value.lowbyte and value.highbyte

    for addressing, i.e use addresses for Highbytes as 2*n and for lowbytes as 2*n + 1 ...

    and when reading you do the same.

    there's no mix that way - just takes 2 I2CWRITE lines instead of 1 !!!

    as address is defined as a Word ... the count for me is 65536 locations at max ...so, it could explain overwriting some values !!! for 256k you will probably have to add some extra block addressing.

    in French .... would be easier !!! let's say this accelometer makes me think to something in the air ....

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Simon Brodeur's Avatar
    Simon Brodeur Guest


    Did you find this post helpful? Yes | No

    Default

    I resolved some problem in my code, but something trouble me about the FOR...Next loop. My code is :

    For address = 0 to last STEP 4
    I2CREAD SDA,SCL,cbit,address,[xsend.Highbyte]
    address = address + 1
    I2CREAD SDA,SCL,cbit,address,[xsend.Lowbyte]
    ...
    Next


    My value in my EEPROM are like this (numbers are EEPROM locations) :

    01 23 45 67 89
    |xx|yy|xx|yy|xx|...

    Normally, the output value of address should be : 0,4,8,12,16,...
    But will the '' address = address + 1 '' line affect this output, giving result like this : 0,5,10,15,20,... ????????

    This should be an easy question for you

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    well yes no toaster hamburger. What about the whole variable definition or code?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Simon Brodeur's Avatar
    Simon Brodeur Guest


    Did you find this post helpful? Yes | No

    Default

    Here's my whole code... but it may be difficult to follow.

    Check the subroutine LOAD, it is the problem I verified the writing with another program.
    Attached Files Attached Files

  9. #9
    Simon Brodeur's Avatar
    Simon Brodeur Guest


    Did you find this post helpful? Yes | No

    Default

    I got it working...
    I just simply read by word instead of read by byte...

    Thanks you guys

Similar Threads

  1. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  3. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 07:25
  4. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th July 2008, 23:19
  5. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 15:23

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