Storing data in Pic


Closed Thread
Results 1 to 8 of 8
  1. #1
    Tomexx's Avatar
    Tomexx Guest

    Default Storing data in Pic

    I'd like to store data in my pic F877A (during RUN MODE) so that after power off it would still be there.

    What is the best way (fast,reliable) to accomplish this?
    (I hear about EEPROM, FLASH... what are my options)

    Thanks,
    Tom

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


    Did you find this post helpful? Yes | No

    Default

    16F877 have an internal eeprom alowing you to store your data.
    to write to internal eeprom. Use WRITE and READ instructions from PICBASIC.

    If you have a lot of data let's say more than internal F877 one, you can use external EEPROM like 93c46, 24C04, 24LC64 and others.

    F877 has internal EEPROM 2K (or 256 * 8bit) lets say 256 allocations space for a BYTE size variable... not too bad

    regards¸
    Steve

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

  3. #3
    Tomexx's Avatar
    Tomexx Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks mister_e,
    One more:
    What locations should I be writing too?
    For example if I want to store 5 bytes, how would I write that?

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


    Did you find this post helpful? Yes | No

    Default

    What locations should I be writing too?
    For example if I want to store 5 bytes, how would I write that?
    you can store at whatever adress you want to ....
    let's say you want to store these var

    First=1
    Second=2
    Third=3
    Fouth=4
    Fifth=5

    Usually i start write to address 0
    WRITE 0,First
    WRITE 1,Second
    WRITE 2,Third
    WRITE 3,Fourth
    WRITE 4,Fifth

    when you want to read them back...

    READ 0,First
    READ 1,Second
    READ 2,Third
    READ 3,Fourth
    READ 4,Fifth

    that's it!!
    Steve

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

  5. #5
    Tomexx's Avatar
    Tomexx Guest


    Did you find this post helpful? Yes | No

    Default

    Great, it's simple then.

    So I guess if you read an address at which nothing was previously stored you should get 0 then, right?

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


    Did you find this post helpful? Yes | No

    Default

    Usually you will get FF as blank value.
    Steve

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

  7. #7
    Tomexx's Avatar
    Tomexx Guest


    Did you find this post helpful? Yes | No

    Default

    Is there a way to check if a memory location has been written?

    I want my user to be able to store his program settings in the EEPROM and be able to retrieve them next time the pic powers up.
    Example, he stores his password and the program will remember it after power is down. Then on bootup program will check the password, etc.

    If FF is the default and you want your program to store some variables (which might happen to be FF) in some memory location then later on there's no way of knowing if the FF at the memory location is an actual data that your program stored or the default that has always been there.

    That could get problematic.

    I guess you can just store numbers from 0 to FE and check for FF to tell you that a particular location hasn't been written too.

    Not a nice way to program but might work. Except for, like you said the FF might be programmer dependant and if you use another programmer which defaults to 0s then you're program's logic has to be changed.

    There's gotta be a better way... Please help.

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


    Did you find this post helpful? Yes | No

    Default

    Hi tomexx,
    Usually all programmer must blank with FFs. case not... will not be considered as blank. FF is a safe way to test blank.

    BUT be sure your programmer erase EEPROM memory when programming.

    To test a password... you can have a maximum lenght of character. when you write it to eeprom use always a fix sized. others unused character in password can be filled with 0s or FF or if you want an special character to gives you the end point of your password. This allows to test password lenght while entering.

    regards
    Steve

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

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Send data to PC USB
    By konter in forum Off Topic
    Replies: 2
    Last Post: - 18th December 2009, 21:57
  3. Going Loopy - How do i get my Loops sorted out ???
    By gtvmarty in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th September 2009, 05:02
  4. PIC to PIC Serial data using Cat5 cable
    By Andy Wood in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd May 2007, 02:42
  5. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21

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