12cwrite not working with 24LC08 SEEPROM ??


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81

    Arrow 12cwrite not working with 24LC08 SEEPROM ??

    I'm trying to fill a SEEPROM with a data lookup table so I can read it later. I'm using a 24LC08 and writing a series of word constants to it. As a test I'm just using a loop to write a sequence of numbers equivalent to the addresses, but that is not working. The loop tries to write values 0-20 to locations 0-20 (actually 0-40 for word vars) but it's only writing the 1st 3 bytes in the EEPROM.

    I can take the LC08 out of the circuit and read it with a prom burner to verify the results and it verifies that all I'm writing is the 1st 3 bytes - and those values do not reflect what I'm trying to write.

    Here's my code loop:

    for temp = 0 to 20
    i2cwrite eedat,eeclk,$A0,Temp,[temp] ' write
    pause 400 ' hold for display
    i2cread eedat,eeclk,$A0,temp,[Mode] ' read it back
    lcdout lcdcmd,lcdline2,#temp," ",#Mode ' display it
    pulsout piezo,10 ' diagnostic "tic" sound
    next temp

    My LCD shows reads of 0 (zero), but the chip reads as:
    10 00 10 FF FF FF FF...
    I'm really frustrated, nothing is adding up here. Am I doing something dumb?
    "Do or do not, there is no try" Yoda

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    tekart,

    With the 24LC08, the address needs to be a BYTE.
    There are also 4 "blocks" of 256 bytes that can be selected in the "control" byte.
    And the address should increment (STEP) by 2 for word sized data.

    I ran this in Proteus ... seems to work.
    Code:
    Temp     VAR BYTE
    Mode     VAR WORD
    
    for temp = 0 to 38 STEP 2
        Mode = temp
        i2cwrite ee_dat,ee_clk,$A0,Temp,[Mode]   ' write
        pause 400                                ' hold for display
        i2cread ee_dat,ee_clk,$A0,temp,[Mode]    ' read it back
        lcdout lcdcmd,lcdline2 ,#temp," ",#Mode  ' display it
        pulsout piezo,10                         ' diagnostic "tic" sound
    next temp
    DT

  3. #3
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default 2 byte increments for word values - duh! But...

    Thanks Darrel,
    I had mis-read the manual and assumed that the compiler took care of the stepping by 2 bytes. I was aware of the 4 blocks, and planned to break my data into 128 word chunks for fit into each block.

    I tried your revised code and the LCD shows a correct read-back, but when I read the EEPROM in my PROM reader all I get is the 1st 3 bytes changed and the rest remains FF.
    It's as if the address increment is not working and I'm just overwriting the same data. I just can't see why that would happen.

    I have checked the hardware over carefully - not much to screw up there. Data and clock are pulled up with 10K and the WP line (pin 7) is wired to GND. Power is good, filtered, clean 5V. Signals all look "textbook".



    [QUOTE=Darrel Taylor;91895]tekart,

    With the 24LC08, the address needs to be a BYTE.
    There are also 4 "blocks" of 256 bytes that can be selected in the "control" byte.
    And the address should increment (STEP) by 2 for word sized data.
    "Do or do not, there is no try" Yoda

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Are you sure you changed the temp variable to a BYTE?

    By changing the temp var back to a WORD, and no other changes to my previous code.
    I get the same results you do ... only writes to the first 3 bytes.

    DT

  5. #5
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default Thank you!!!

    Oh Duh! Now I see the problem. That never occurred to me to use a byte variable for the address counter. It's all so obvious now. I really appreciate your help Darrel!


    Quote Originally Posted by Darrel Taylor View Post
    Are you sure you changed the temp variable to a BYTE?

    By changing the temp var back to a WORD, and no other changes to my previous code.
    I get the same results you do ... only writes to the first 3 bytes.

    "Do or do not, there is no try" Yoda

  6. #6
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default More assistance with this?

    So Darrell,

    My ultimate goal is to get 256 word variables into the EEPROM chip from a comma delimited text file in decimal. My plan was to put them into on-chip EPROM first in 128 word chunks then read them out in a loop and write them to the external EEPROM chip. This is pretty tedious though. So I'm wondering if you have any thoughts on a way to simplify the process?

    Once I have the chip programmed, I can then read it out to create a file for burning them in production. Wish I could just get the data directly into my PROM burner...

    BTW This is a temperature look-up table for a thermostat type device. The values are ADC readings for the degrees F from 0 to 255.

    Guy
    "Do or do not, there is no try" Yoda

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Temperature lookup table?
    Can't that be done in Math?

    Which PIC are you using?
    You may be able to use something like this to store the values in the PIC before writing to EEPROM.
    http://www.picbasic.co.uk/forum/show...php?t=3891#LAB
    DT

  8. #8
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default lookup tables

    It's a 10K thermistor curve that can't be defined in integer math. Been there tried that.
    I'm fine with the lookup table in EEPROM, it's getting it in there is the hassle.

    I'm using a 16F88 for low cost and the ADCs.

    That EXT thing is weird. Not sure how to apply it. My plan at present is to load the 256 bytes in the PIC with 128 words, then write that to the external EEPROM and repeat. Just have to pay attention to the addresses and data file index. I can manage that but was looking for a simpler way out.

    Guy

    Quote Originally Posted by Darrel Taylor View Post
    Temperature lookup table?
    Can't that be done in Math?

    Which PIC are you using?
    You may be able to use something like this to store the values in the PIC before writing to EEPROM.
    http://www.picbasic.co.uk/forum/show...php?t=3891#LAB
    "Do or do not, there is no try" Yoda

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tekart View Post
    It's a 10K thermistor curve that can't be defined in integer math.
    One day, you will learn not to say things like that.
    Can I see your data table?

    That EXT thing is weird. Not sure how to apply it.
    If I can't "Curve Fit" it, I'll show you how to put the table in Code Memory.
    Then you can either use the table from there, or take the data and write it to EEPROM.

    If I can fit the curve, you won't need a table.
    DT

  10. #10
    Join Date
    Sep 2008
    Location
    Maine, USA
    Posts
    81


    Did you find this post helpful? Yes | No

    Default sounds too good to be true

    Darrel,
    Your offer sounds too good to be true. Therefore it must be!

    We're getting into my proprietary info at this point. How can we continue the dialog outside the Forum? This is for a product that I'm developing for my own company so I can pay for your time - if you're willing.
    Guy

    Quote Originally Posted by Darrel Taylor View Post
    One day, you will learn not to say things like that.
    Can I see your data table?


    If I can't "Curve Fit" it, I'll show you how to put the table in Code Memory.
    Then you can either use the table from there, or take the data and write it to EEPROM.

    If I can fit the curve, you won't need a table.
    "Do or do not, there is no try" Yoda

  11. #11
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by tekart View Post


    BTW This is a temperature look-up table for a thermostat type device.

    Guy
    LOL - Darrel has a lot of experience of thermostat type devices

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