how to save value in pic16f84a


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2007
    Posts
    16

    Default how to save value in pic16f84a

    hi..

    i want to save a value in pic16f84a, and if i cut off the power, the value must be still saved.

    how can i do this??

  2. #2
    Join Date
    May 2004
    Location
    New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ibra View Post
    hi..

    i want to save a value in pic16f84a, and if i cut off the power, the value must be still saved.

    how can i do this??
    Use the on-board EEPROM. If I remember right, the '84 has 64 bytes available.

    Arch
    "Data sheets? I ain't got no data sheets. I don't need no data sheets. I don't have to read any stinking data sheets!"

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    When you are first programming the chip, use the EEPROM command. Do this to set an initial value, don't depend upon it being zero from the factory. To change it while your program is running use the Write command, and to read your value use Read.

    Jerry.
    If your oscilloscope costs more than your car...

  5. #5
    JanH's Avatar
    JanH Guest


    Did you find this post helpful? Yes | No

    Default

    I might misunderstand you, but you just want to save a value in a PIC16F84 to use again after powerdown ?

    Why not use the WRITE and READ command. ?

    Below is some code snippets I use on a motor control.
    When I switch power off I want to keep a value for the next time I switch power on again.

    ==== Start of program ====
    ...
    ...
    read 1, Min_Start 'Read stored value of Minimal start speed
    if Min_Start=255 then Min_Start=0 'Min_start was not stored
    ...
    ...
    ...
    Write 1, Min_Start 'Somewhere in program the value is written.
    'to Location 1

    ================================================== ========

  6. #6
    Join Date
    Apr 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    JanH..

    i used this method as you wrote, and like you for control stepper motor.
    but it did not work.

    i posted a thread " problem with stepper " and attached my code for this.

    here is my code, you can see and say.
    Attached Files Attached Files
    Last edited by ibra; - 10th August 2007 at 11:14.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    janH,
    The link I gave in post #3 http://www.picbasic.co.uk/forum/showthread.php?t=5649 is a discussion on how to force the PIC to save on a power down.

    ibra,
    I gave you some sample code for your stepper motors.("problem with stepper ") Did it work? If not, what happened?
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Apr 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    mackrackit..

    the sample code you wrote did not work, the stepper just moves to left for ever.


    i changed my last code ..

    i put a delay after read and write instructions, and i changed the place of write instruction.
    after these changes the stepper just do its job in the first stage ( when p = 13 and return back) ...then it start to go left and right randomly.

    after all this i read the eeprom postion of P, it gives me a big value than 13 !!.

    i think that there some mistakes in logical operators i used..but i dont know where ?

    this is my new code..

    any idea plz??
    Attached Files Attached Files

  9. #9
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    ibra,

    The code I gave was trying to show where, when, and how to write to eeprom. It should not have changed the operation? At some point 13 should have shown up.

    I do not have a stepper on the bench at the moment so this is untested on my part.

    The idea is to have positive data written after every CW step (P=P+1)and negative data after every CCW step(P=P-P).

    Code:
    IF PORTB.6 = 0 AND P<=13 THEN ;go RIGHT
    
     GOSUB RIGHT
    
     ELSE
    
     IF PORTB.7 = 0 AND P>=1 THEN ;go LEFT
    
     GOSUB LEFT
    This looks like the random problem. P<=13 -- P>=1 Stuck between these values. It would have to be greater than 13 or less than 1 to stop.

    Or, make PORTB 6 or 7 high in hardware and tell the PIC what to do when they are high. (STOP)

    I will try to test with a stepper in a day or so.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Using serial eeprom to save data ?
    By iugmoh in forum General
    Replies: 4
    Last Post: - 8th February 2008, 09:36
  2. Serial Communication Using PIC16F84A
    By fazan83 in forum GSM
    Replies: 9
    Last Post: - 22nd January 2007, 03:56
  3. save data in pic
    By PoTeToJB in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 17th May 2006, 22:17
  4. How to connect PIC16F84A to mobile phone
    By PoTeToJB in forum Schematics
    Replies: 2
    Last Post: - 8th March 2006, 16:32
  5. Replies: 3
    Last Post: - 16th April 2005, 13:42

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