Cart New Account Login

HomeAbout usProductsSupportForumsBlogCustomer Service

Please accept the use of cookies on our site

At PEmicro we use web browser cookies in order to provide you with an enhanced experience and in order to be able to do things like shopping cart processing and identify you when you login to our website.

Click here to accept

search inside this forum
search inside all forums
Erase EEPROM with 0 not 0xFF
mzamfir n. Aug 9, 2016 at 01:39 PM (13:39 hours)
Staff: Johnny N.

  • Hi,
    Please excuse the apparent ignorance on the subject, but bear with me.
    We've been using prog12.z for a number of years to program Freescale MC9S12 chips. Recently, a customer requested that we erase the EEPROM before programming.
    Before this request, we simply loaded the linear_pflash algorithm, hit erase and then program with the correct binary.
    After this request, we started with:
    - load the EEPROM_linear algorithm, then hit erase;
    - load the previous pflash algorithm, then hit erase;
    - program with the binary.
    Now, the PCB is in a fault state. We narrowed it down to the flash memory being filled with 0xFFs, instead of 0s. This creates 2 issues with our firmware, one of which cannot be addressed without severe impact for the customer.
    So, my our only choices are:
    - either remove this EEPROM erase 'step'
    - either erase the EEPROM by putting all values to 0 in memory instead of FF.
    I would like to use the 2nd option, if possible, but I can't seem to figure it out. Would it be something in the algorithm I can change, or an option I missed in prog12z?


  • Greetings,

    The erased state is 0xFF. So if 0x00 is the preferred method then you must program zeroes. You will have to create your own binary file that fills the entire region with zeroes. There is no unique command or setting to enable this.

    I did some research as to how you may be able to do this...

    4.2 Filling Unused Flash Areas
    When using codewarrior version 6.3, unused flash area can be filled using the FILL command in the linker parameter file, project.prm. The following code tells the linker to fill 0x82 into all unused flash areas of 0xC000 to 0xFF9D.

    ROM = READ_ONLY 0xC000 TO 0xFF9D FILL 0x82;

    Maybe you can implement something like this where you FILL 0x00.

    The brute force way is to have an assembly file that you program zeroes. I just whipped up a utility to do this. So if you could tell me the starting and ending address then I can generate an S19/PHY file for you.

    Takao Yamada

  • Hello,

    Each memory cell or bit of the EEPROM can be a "0" or a "1". The default state is always a "1" and programmed state is "0". When you program a memory cell, you are actually clearing it to "0". Erasing a memory cell is just setting the "0" back to "1" and reverting it to default state.

    This is how our software performs flash erase and program operations and follows the industry convention. We are not going to change this.

    You cannot erase your EEPROM to all 0's. What you can do is erase it, then re-program the EEPROM to all 0's with a separate S19 file or you can use the Program Bytes and Program Words command to do it. If you are doing the latter, you can automate the process with a batch file using PROG12Z

    P&E Engineeering Support

Add comment

   Want to comment? Please login or create a new PEMicro account.

© 2018 P&E Microcomputer Systems Inc.
Website Terms of Use and Sales Agreement