Simple External EEPROM Table Example?


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2005
    Posts
    96

    Default Simple External EEPROM Table Example?

    Can someone give me a quick external eeprom lookup table example. I know I am missing something stupid. I'm not worried about the exact code, more the thought process.

    Basically what I need to do is put the following data into eeprom

    (1) 00000001,00000000,00000000,00000000
    (2) 00001010,00000000,00000000,00000000
    (3) 00001010,00000000,00000000,00000000
    (4) 00101010,00000000,00000000,00000000
    (5) 10101010,00000000,00000000,00000000
    (6) 10101010,00000000,00000000,00000000
    (7) 10101010,00000010,00000000,00000000
    (8) 10101010,00000010,00000000,00000000
    (9) 10101010,00001010,00000000,00000000
    (10) 10101010,00101010,00000000,00000000

    After the data is in EEPROM my program will have a variable that will store a value between (1) and (10). Based on that variable I need to go to the EEPROM and return with 4 byte sized variables.

    I am having trouble understanding how to format this data in eeprom effiecently so that I can get the 4 byte size variables out in a small amount of time.

    Thanks for any thoughts, hopefully I have not confused everyone.

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi modifyit,


    You will have 20 WORD size variables instead of 10.
    The code will look like below. I did not use decimal numbers to make it more understandable and stored Binary numbers in EEPROM.


    Code:
              'LowByte,  HighByte, LowByte,  HighByte
    EEPROM 1, [%00000001,%00000000,%00000000,%00000000]
    EEPROM 5, [%00001010,%00000000,%00000000,%00000000]
    EEPROM 9, [%00001010,%00000000,%00000000,%00000000]
    EEPROM 13,[%00101010,%00000000,%00000000,%00000000]
    EEPROM 17,[%10101010,%00000000,%00000000,%00000000]
    EEPROM 21,[%10101010,%00000000,%00000000,%00000000]
    EEPROM 25,[%10101010,%00000010,%00000000,%00000000]
    EEPROM 29,[%10101010,%00000010,%00000000,%00000000]
    EEPROM 33,[%10101010,%00001010,%00000000,%00000000]
    EEPROM 37,[%10101010,%00101010,%00000000,%00000000]
    
    LOCATOR VAR BYTE
    Holder  VAR WORD[21]
    
    
    START:
    
    FOR LOCATOR = 1 to 37 STEP 4
    
       READ LOCATOR,   Holder.lowbyte[LOCATOR]        'EEPROM Location 1  \  
       READ LOCATOR+1, Holder.highbyte[LOCATOR]       'EEPROM Location 2  /  
    '    We read First two bytes here.
    
       READ LOCATOR+2, Holder.lowbyte[LOCATOR+1]      'EEPROM Location 3  \  
       READ LOCATOR+3, Holder.highbyte[LOCATOR+1]     'EEPROM Location 4  /  
    '   Read Second two bytes.
    
    NEXT LOCATOR
        
    ' Print the numbers on LCD and see what is going on.
    
    GOTO START
    
    END
    ---------------------------------------
    Pls check these posts.
    first this http://www.picbasic.co.uk/forum/showthread.php?t=544
    then
    this http://www.picbasic.co.uk/forum/showthread.php?t=42.


    Edit: This code is not a direct answer to your question but if you understand the way it works, then you can have a variable in your program as you said and based on its value you can do the following.

    Say your variable is also named as Locator. Then you just use the same concept inside the FOR loop above and get your data from EEPROM, but remember you will have "4-bytes" from EEPROM into two WORD size variable in your program.
    Last edited by sayzer; - 26th October 2006 at 08:16.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Can't read sequential addresses in external EEPROM
    By tjkelly in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th February 2010, 14:46
  2. Replies: 1
    Last Post: - 28th January 2010, 22:15
  3. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 06:26
  4. External EEPROM Not getting data (24LC515)
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2005, 13:16
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 19:59

Members who have read this thread : 1

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