Problem with saving to EEPROM...


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Tear,

    the DATA statement doesn't work that way, see PBP Manual section 5.11

    I guess you can't expect someone to help you any further with the "spaghetti"-code you have posted, because it is "unreadable"

    It is no surprise that one gets lost with this kind of code.

    In addition:

    some CRLF in your posting would have increased readabiltiy dramatically.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  2. #2
    Tear's Avatar
    Tear Guest


    Did you find this post helpful? Yes | No

    Default

    Hi,

    After more testing I have found out that using the DATA and EEPROM command are not writing the value to the EEPROM. Below is test code to see if the value I want to place in EEPROM is written to it. Unfourtantly it doesnt work and doesnt work with any value. Looking at the manual it said that you need to do the READ and WRITE command in seperate bytes since I am using words to hold values larger than 255.

    Here is the example code:


    Delay var word

    EEPROM 0, [1500]
    read 0, Delay.BYTE0
    Read 1, Delay.BYTE1

    if Delay = 1500 then
    goto loop
    else
    goto Flash
    endif

    Flash:
    high PORTB.3
    pause 500
    low PORTB.3
    pause 500
    goto flash

    ''Start of program!
    Loop:
    'Run program



    No matter what number I try to use for the EEPROM command the light will always go to the flash loop saying that it isnt reading the same value.

    ~Michael

  3. #3
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    again:

    the DATA statement doesn't work the way you are using it, see PBP Manual section 5.11

    the EEPROM statement doesn't work that way either, see PBP Manual section 5.18

    DATA WORD 1500
    would do the trick.

    OR: split your word into two bytes and use:

    DATA @0,$DC,$05
    (Attention, LowByte is first in this example!)

    If you want the HighByte first you have got to swap the Byte order in your READ and WRITE statemenst as well.

    B.T.W.
    you could make your life a lot easier by moving to a more up to date PIC like the 16F628 or 16F88 (which is Loader compatible!) or one of the many others...

    ...you could get rid of the external Resonator (or Crystal with it's Caps)

    Another thing I have seen in your code example is:
    your Buttons appear to be active HIGH, means you have got to have PullDown resistors at the corresponding PIC Pins.

    If you would reverse this logic you could even get rid of these resistors and use the PICs internal weak pullups.
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  4. #4
    Tear's Avatar
    Tear Guest


    Did you find this post helpful? Yes | No

    Default

    Sorry for reposting the same thing. I read the manual and even though PICBasic makes it a lot easier for coding I am not strong at it at all. 99% of my experience as a student is in building circuits (just finished my sophmore year of EE).

    I have one question though, if you dont mind. Using DATA WORD 1500 works, but I am guessing that it places it at memory slot 0 of the EEPROM. How can I place another variable like this after the first one? I am sure that I need to includethe address in the command somehow.

    Thanks,
    Michael

  5. #5
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Tear
    I have one question though, if you dont mind. Using DATA WORD 1500 works, but I am guessing that it places it at memory slot 0 of the EEPROM. How can I place another variable like this after the first one? I am sure that I need to includethe address in the command somehow.
    OK,
    we are talking about the DATA statement.
    It preloads the EEPROM at program time.

    If you want to specify a location (other than the current pointer position) there is only one choice:
    use DATA @Location,Byte1,Byte0.......

    There is NO way of specifying a location (other than the current pointer position) a WORD is to be written to.

    But this is not much of a problem, since the WORD is written to the location starting from the current pointer position.
    (Bear in mind, a WORD is written LowByte first!)


    So:

    DATA @0,$11,$22
    DATA WORD $AABB
    DATA $33
    DATA $44
    DATA WORD $CCDD

    would result in the following EEPROM content:
    11 22 BB AA 33 44 DD CC

    Just try it !

    However,
    I would always use DATA with Bytes (since READ and WRITE only deal with Bytes), because later on in your program is a lot easier, you don't, have to remember wether or not you have to swap the order of the two bytes you have just "READ".
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



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. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 03:17
  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. EEPROM Read problem
    By Christos_K in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 5th June 2005, 17:10
  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 : 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