Simple READ/WRITE EEPROM is driving me nuts! pls help


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Simple READ/WRITE EEPROM is driving me nuts! pls help

    Ken,
    Make sure you change BOTH of the "Y=Y+1" statements to "Y=Y+2"

    I have verified your code works if you change both. Here is my version of your code. I've trimmed it down, modified the output methods, and generated the temps without the ADC. But your will notice all the WRITE and READ statements are the same. I output the values in hex, which allowed be to then read the EEPROM as an additional way to verify the data.

    Code:
    TEMPF   VAR WORD
    TEMPC   VAR WORD
    Y       VAR BYTE
    X       VAR BYTE
    Z       VAR BYTE
    TEMPF1  VAR WORD
    TEMPF2  VAR WORD
    
    
    START:
        PAUSE  2000     
        Y = 0  
        for x = 1 to 5
     
    WRITE_temp:      'READ THE THERMOCOUPLE AND SAVE IT
           TempC = 1 << Y
           TempF = (TempC*18)/10+32
           LCDOUT $FE, $80, HEX4 TempF
           pause   30    
        '      READ THIS TEMPERATURE
           HSEROUT ["TEMP= ",HEX4 TEMPF, 13]
    '
    '       NOW WRITE IT TO EEPROM LOCATION IN VARIABLE Y
           WRITE Y,WORD TEMPF
    '
    '   IMMEDIATELY READ IT BACK  - - THIS VALUE IS READ CORRECTLY ALL 5 TIMES
    '
           READ Y, WORD TEMPF1 
           HSEROUT ["READ TEMP= ",HEX4 TEMPF, 13]       
    '******************************    
    '    NOW READ IT BACK AND WRITE TO A DIFFERENT VARIABLE ( TEMPF1)
    '   THIS READ ALSO WORKS CORRECTLY ALL 5 TIMES
    '*****************************  
           READ Y, WORD TEMPF1
           HSEROUT ["READ1 TEMPF1= ",HEX4 TEMPF1, 13]
           
           LCDOUT $FE, $C0,"X = ",dec x
           LCDOUT " Y = ",dec Y
          
           Y = Y + 2
           next x       
           
           PAUSE   3000
           HSEROUT ["-----------------------------", 13]
    
    '**********************************
    ' NOW TRY TO READ IT AGAIN, USING ANY VARIABLE DOES NOT MATTER , TEMPF1, ETC
    '    THE ONLY CORRECT READ HERE IS THE LAST ONE, (Y = 4) 
    'ALL OTHERS ARE INCORRECT - - VERY HIGH VALUES - - 23375, 22860, ETC
    '*****************************************************************
           Y = 0         'RESET THE EEPROM ADDRESS POINTER TO 0
           FOR X = 1 TO 5 
           READ Y, WORD TEMPF2  ' USING VARIABLE TEMPF2 HERE, ANY OTHER VARIABLES 
                                ' DO NOT WORK EITHER
           HSEROUT ["READ2 TEMPF2= ",HEX4 TEMPF2,13]
           Y = Y + 2
           next x      
                 
           HSEROUT ["Done", 13]
    DONE:
         
          pause   1000    
          GOTO   DONE
    
        
    END

  2. #2
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Simple READ/WRITE EEPROM is driving me nuts! pls help

    Forgot to post the output:

    Code:
    TEMP= 0021
    READ TEMP= 0021
    READ1 TEMPF1= 0021
    TEMP= 0027
    READ TEMP= 0027
    READ1 TEMPF1= 0027
    TEMP= 003C
    READ TEMP= 003C
    READ1 TEMPF1= 003C
    TEMP= 0093
    READ TEMP= 0093
    READ1 TEMPF1= 0093
    TEMP= 01EC
    READ TEMP= 01EC
    READ1 TEMPF1= 01EC
    -----------------------------
    READ2 TEMPF2= 0021
    READ2 TEMPF2= 0027
    READ2 TEMPF2= 003C
    READ2 TEMPF2= 0093
    READ2 TEMPF2= 01EC
    Done

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Simple READ/WRITE EEPROM is driving me nuts! pls help

    SreveB

    Thanks so much. That was my problem. Actually, I thought that I should add 2 each time, but for some reason stuck with only one. You are correct, when I tried adding 2 originally , it was only to one of the sections. Sometimes I guess I should stay in bed longer.

    Thanks again

    Ken

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