EEPROM Variables (EE_Vars.pbp)


Closed Thread
Results 1 to 40 of 80

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: EEPROM Variables (EE_Vars.pbp)

    Thanks Darrel! I should have guess that based on the underscore for the variable. The reason I wanted to use a constant is that I was having trouble with EE_write_default; it didn't seem to save the original value defined in EE_var to EEPROM when I turned off the circuit and restarted it, but now it seems to work (although the first time I powered up the chip after programming and when to show the value on an LCD screen using your example it had something like '366565' rather than '1000').

    BTW, I spent about an hour removing all the HTML tags to make it readable. I've saved a copy in Word as I anticipate going back to it over and over.

    Last question (unrelated to your include): does reprogramming a chip clear it's EEPROM memory?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: EEPROM Variables (EE_Vars.pbp)

    does reprogramming a chip clear it's EEPROM memory?
    That depends on the programmer and options.

    A bulk erase will erase everything.
    But if you are using options for low voltage erase, or not programming config words, it's possible that EEPROM will not get erased.

    With melabs programmer software, go to Options > More Options > Set Options to Defaults to be sure that "Bulk Erase" is being used.
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: EEPROM Variables (EE_Vars.pbp)

    Thanks Darrel!

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: EEPROM Variables (EE_Vars.pbp)

    I'm seeing some strange behaviour with my EEPROM variable - the first time the chip is powered up it seems like the linked variable isn't being set to the default as in this code:

    Code:
    MotorRPM VAR BYTE        :  @  EE_var        _MotorRPM, BYTE, 150
    I know this because this loop is meant to spin up two motors connected to CCP1 & CCP2 on a PIC16F1825; rather than increase the duty to the mid-range RPM as in the default (150), it spins up to the max (255):

    [CODE
    IF MotorRPM > 66 THEN
    FOR I = 65 to MotorRPM
    pause 30
    HPWM 1, I, 20000 ' Stbd engine (CCP1)
    HPWM 2, I, 20000 ' Port engine (CCP2)
    NEXT I
    EndIf
    [/CODE]

    This only happens the first time the chip is powered up after re-programming. If I unplug the breadboard power and turn it back on again, the motors spin up to the expected default.

    Full code attached. Any ideas? Should I put an EE_READ in even though it shouldn't be needed?

    Nacelle_Motors_16F1825_32Mhz_Int_SN754410.txt

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: EEPROM Variables (EE_Vars.pbp)

    Looking over my post #49, this recent problem appears to be similar to what I was seeing there (but went away). I don't have enough available pins on my 16F1825 to display the start up value of _MotorRPM but I suspect the same thing is happening - after first programming the chip, the initial value is way over 150 (and why the PWM command to the motor ends up spinning it to its max value [255]).

    I've switched to PBP3 and MicroCode Studio Plus (v5.0.0.3) and PBP compiler vPBPX 3.0.5.4. I tried what you posted in #50 but no lucy. Could this be a case of bulk erase not working? Why would that happen with one project but not another similar one (as I posted in this thread)

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: EEPROM Variables (EE_Vars.pbp)

    If I add this:

    Code:
    MotorRPM = 150
    before the the PWM command, all works well (completely negating the use of EEPROM of course) so this does indicate to me that somehow the initial value of _MotorRPM is getting messed up after first programming the chip (if I use my mechanical rotary encoder to reduce the RPM, this does get saved properly and the motor starts up with this saved value next time power is turned on).

    Darrel?

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: EEPROM Variables (EE_Vars.pbp)

    Ross,

    Try putting a pause 100 or so at the very beginning of your program.

    The programmer goes through several cycles of power-on and resets to program each section of memory.
    And the EEPROM write is one of the first things that happens in the program.

    The EEPROM write takes ~5ms, so it's probably getting powered down in the middle of the write cycle.

    With a pause at the beginning, it will insure that the programming cycles are completed before it starts running the rest of the program.

    I've single stepped through the program several times in the simulator, and everything works fine.
    I'm not in the office today, so I can't try it with a real programmer.
    DT

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, 15:46
  2. Problem with I2C EEPROM addressing
    By Atom058 in forum General
    Replies: 14
    Last Post: - 3rd November 2009, 04:17
  3. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 15:19
  4. How to write/read strings EEPROM/LCD
    By g-hoot in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 11th February 2007, 07:26
  5. word variable to 25lc640
    By TONIGALEA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 6th July 2004, 20: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