Data EEPROM gets clobbered during programming


Closed Thread
Results 1 to 6 of 6
  1. #1

    Default Data EEPROM gets clobbered during programming

    18LF4620, MCSP, MPASM, Melabs USB serial programmer.

    Program 1 writes data to the EEPROM and successfully plays it back.
    During programming, the coonfiguration bit "Data EEPROM" Protected or Not Protected makes no difference. The EEPROM always gets programmed by the DATA statements. Likewise changing Table Write Data EEPROM makes no difference - the EEPROM always gets what is in the DATA statements.

    Program 2 always overwrites the data EEPROM. Playback shows the EEPROM as all $FF regardless of whether I have the Data EEPROM protected or not or whether I have the Table Write Data EEPROM protected or not.

    In my real application, program 2 must not corrupt the data stored in EEPROM as it contains unique data like serial numbers and calibration coefficients that were derived when program 1 ran for the first time.

    What am I doing wrong?

    Program 1

    Code:
    '************* Config Register setup for USB programmer ****************
    ' OSC = HS,  FSCM = En, IESO = En, PwrupTmr = En, BrownOut = Dis
    ' BOR Volts = 2, WDT = Off, WDTPS = 1:512, CCP2 mux = RB3, 
    ' PortB rst = Digital, LPT1Osc = Low, MCLR = Reset, LVP = Dis
    ' Enhanced CPU = Dis, All memory = Not Protected
    ' Note re power consumption.    PBP assumes the WDTPS is set to 512.
    ' SLEEP draws 2.5 uA in this system.  Each time sleep times out there
    ' is a current pulse for 2.5 mSecs at 600 uA.  Setting WDTPS = 1024 extends
    ' the SLEEP internal period by 2 and so the average power drops BUT
    ' PBP will get the sleep times wrong by the factor of chosen WDTPS:512
    '************************************************************************
    '
     
    data @900, "This is a string from byte 900 ",13,10
    data @850, "This is a string from byte 850 ",13,10
    data @800, "This is a string from byte 800 ",13,10
    data @750, "This is a string from byte 750 ",13,10
    data @650, "This is a string from byte 650 ",13,10
    data @600, "This is a string from byte 600 ",13,10
    data @500, "This is a string from byte 500 ",13,10
    data @400, "This is a string from byte 400 ",13,10
    data @350, "This is a string from byte 350 ",13,10
    data @300, "This is a string from byte 300 ",13,10
    data @250, "This is a string from byte 250 ",13,10
    data @200, "This is a string from byte 200 ",13,10
    data @150, "This is a string from byte 150 ",13,10
    data @100, "This is a string from byte 100 ",13,10
    data @50, "This is a string from byte 50 ",13,10
    data @0, "Data Read Write test from byte 0 ",13,10
    
    '************************* Defines *****************************
    DEFINE OSC 4    
    DEFINE DEBUG_REG PORTB     'Debug pin port 
    DEFINE DEBUG_BIT 6         'Debug pin bit 
    DEFINE DEBUG_BAUD 19200    'Debug baud rate 
    DEFINE DEBUG_MODE 0        'Debug mode: 0 = True, 1 = Inverted
    DEFINE DEBUG_PACING 2000  
    
    A           var   byte
    B           var   byte  
    C           var   byte
    
    
    pause 2000
    
    debug 13, 10, 13, 10, 13, 10, "Data loaded to EEPROM", 13, 10
    
    debug 13, 10, "Numeric EEROM dump 0 ~ 1023", 13, 10
    for a = 0 to 63
       for b = 0 to 15
          read (16*a + b), c
          debug #c, ", "
       next b
       debug 13, 10
    next a
    
    debug 13, 10, "Literal EEROM dump 0 ~ 1023", 13, 10
    for a = 0 to 63
       for b = 0 to 15
          read (16*a + b), c
          debug c, ", "
       next b
       debug 13, 10
    next a
    
    end

    Program 2
    Code:
    '************* Config Register setup for USB programmer ****************
    ' OSC = HS,  FSCM = En, IESO = En, PwrupTmr = En, BrownOut = Dis
    ' BOR Volts = 2, WDT = Off, WDTPS = 1:512, CCP2 mux = RB3, 
    ' PortB rst = Digital, LPT1Osc = Low, MCLR = Reset, LVP = Dis
    ' Enhanced CPU = Dis, Data EEPROM = Protected, All the rest of memory = Not Protected
    
    '************************* Defines *****************************
    DEFINE OSC 4   
    DEFINE DEBUG_REG PORTB     'Debug pin port 
    DEFINE DEBUG_BIT 6         'Debug pin bit 
    DEFINE DEBUG_BAUD 19200    'Debug baud rate 
    DEFINE DEBUG_MODE 0        'Debug mode: 0 = True, 1 = Inverted 
    DEFINE DEBUG_PACING 2000  
    
    A           var   byte
    B           var   byte  
    C           var   byte
    
    pause 1000
    
    debug 13, 10, 13, 10, 13, 10, "Data being retrieved from EEPROM", 13, 10
    
    
    debug 13, 10, "Numeric EEROM dump 0 ~ 1023", 13, 10
    for a = 0 to 63
       for b = 0 to 15
          read (16*a + b), c
          debug #c, ", "
       next b
       debug 13, 10
    next a
    
    debug 13, 10, "Literal EEROM dump 0 ~ 1023", 13, 10
    for a = 0 to 63
       for b = 0 to 15
          read (16*a + b), c
          debug c, ", "
       next b
       debug 13, 10
    next a
    
    end

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    How are you flashing code 2? If there is a setting in your programmer software to preserve EEPROM values while flashing the chip, you should enable that.

    Melabs serial programmer has these under 'options-erase-data' and 'options-program-data' which can be unchecked to preserve your EEPROM contents.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    According to the way you've got your DATA statements, shouldn't your loops look like this instead?
    Code:
    for a = 0 to 49
       for b = 0 to 15
          read ( ( 50 * b ) + a ) , c
          debug c, ", "
       next b
       debug 13, 10
    next a

  4. #4


    Did you find this post helpful? Yes | No

    Default EEPROM still gets clobbered

    Hi Skimask,
    The loop structure is fine. It shows me the full 1024 bytes of the EEPROM.

    Program 2 clobbers the EEPROM. I think Jerson is thinking in the right direction that it is a programmer setup issue. The USB serial programmr I have uses different terminology to his post but I think I know what he means. The trouble I now have is that the '4620 will not program unless it is erased first. That erasure takes the EEPROM contents with it and empties the memory.

    Cheers
    BrianT

  5. #5


    Did you find this post helpful? Yes | No

    Default How to preserve data EEPROM during programming

    I had faulty thinking about what the CONFIGURATION setup screen in the Melabs Serial USB programmer does. It appears to show the configuration that will be in force AFTER the programming step. Setting Data EEPROM to 'protected' does not protect it during the programming but it seems it will be protected when the program runs.

    What I found solves the problem is to dig deep in the options\more options\ erase and options\more options\blank check to get the programmer to accept the fact that the chip was not blank and to program anyway and to not touch the data EEPROM during programming.

    Pretty obvious after the event. Thanks to Jerson for pointing me in the right direction.

    Thanks
    BrianT

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by BrianT View Post
    Hi Skimask,
    The loop structure is fine. It shows me the full 1024 bytes of the EEPROM.
    Yep, sure is. I read it wrong....Duh....

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 05:47
  2. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 03:21
  3. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 15:50
  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, 20:42
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 29th November 2004, 00:56

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