Values in EEPROM get erased on power cycle


Closed Thread
Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2005
    Posts
    14

    Default Values in EEPROM get erased on power cycle

    Hi, I am a newbie to using pic chips and programming the pic chips with picbasic pro. My problem is, I am using a PIC 18f452 and am trying to store user input variables to the onboard eeprom of the chip. I am using the pic basic pro write and read command and it seems to work OK as long as the chip is powered up. When power is cycled to the chip, I loose the values that should be stored in the EEPROM. Shouldn't these values be maintained since the values are stored to the EEPROM or am I trying to use the EEPROM improperly?

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    never get any problem with it with all PIC with on-board EEPROM. What about a snip of your code??? PBP Version???
    Steve

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

  3. #3


    Did you find this post helpful? Yes | No

    Default

    I use the write and read commands all the time without problems. I use the data command when I want to pre-load the eeprom with known values.

  4. #4
    Join Date
    Aug 2005
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Thanks for reply mister e and cocacolakid. Below is a snippet of code from my program. I am reading dip switches that I have connected to portc and portd and storing the values in the onboard eeprom when a switch I have connected to portb.2 is on. This code is at the beginning of program after variable declarations and only executes once on startup before program goes into loop. It works OK until I turn the switch off on portb.2 and cycle the power. The value read from the EEPROM is then 65535. Any help that you can give me will be greatly appreciated.


    if PORTB.2 = 1 Then 'Check Calibration Switch. If on read Dip Switches
    Write 0, PORTC 'Read Dip Switches on Port C and Store Value in
    'EEPROM Address 0
    pause 10
    Write 1, PORTD 'Read Dip Switches on Port D and Store Value in
    'EEPROM Address 1
    pause 10
    EndIf
    Read 0, TMTR1KFLO.byte0 'Read Value in EEPROM Addres 0 and store
    'in low byte of TMTR1KFLO (Declared as Word)
    pause 10
    read 1, TMTR1KFLO.byte1 'Read Value in EEPROM Addres 1 and store
    'in Hi byte of TMTR1KFLO (Declared as Word)
    pause 10
    loop: 'Program Loop

  5. #5
    Join Date
    Aug 2005
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Sorry, my code and remarks kinda of got scrambled together after I posted it.

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


    Did you find this post helpful? Yes | No

    Default

    mm i doubt you can do
    Code:
    Write 0, PORTC 'Read Dip Switches on Port C and Store Value in 
    'EEPROM Address 0
    pause 10
    Write 1, PORTD 'Read Dip Switches on Port D and Store Value in
    'EEPROM Address 1
    what about
    Code:
    TempVar var byte
    '//////////// blah blah blah \\\\\\\\\\\\\\\\
    TempVar=PORTC
    Write 0, TempVar
    
    TempVar = PORTD
    Write 1, TempVar
    Steve

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

  7. #7


    Did you find this post helpful? Yes | No

    Default

    What version of PBP are you using. There were some issues with odd number eeprom locations being misread on the 18Fxxxx series chips. PBP 2.44 and later corrected this issue.

    Also you do have a pull-down on portb.2 do you not? I floating input can cause very unpredictable results.

  8. #8


    Did you find this post helpful? Yes | No

    Default

    Mr E, I was wondering about that too but since I'm not at work I can't confirm nor deny the statement. Yours is definitely the safe option.

  9. #9
    Join Date
    Aug 2005
    Posts
    14


    Did you find this post helpful? Yes | No

    Default

    Thanks Guys, I do have pull down resistors on PORTC and PORTD but overlooked the one for PORTB.2. I did install one and it did fix my problem. However I don't quite understand why this would cause the problem that I had since this switch was used only to tell the program when to write to EEPROM. By the way the Write 0, PORTC does work OK.

    Thanks Again for your help
    Roy

  10. #10


    Did you find this post helpful? Yes | No

    Default

    The input on portb.2 was left floating which means that it's not really ground nor is it vcc. A floating input can change it state be simpling touch it or even something around it. Think of it this way, if the input requires say 0.7V to register as a low and 1.2V to register as a high you now have a 500mV dead zone than can go either way, pull in one way and the problem is resolved because you now know where it will always be without any other for of influence like a switch.

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. Internal EEPROM Read/write Addressing Errors with 18F PIC's
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 18
    Last Post: - 12th July 2005, 19:42
  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