Timor Lansky

How to protect specific page from being erased while programming flash on MC9S08QE

Discussion created by Timor Lansky on Aug 16, 2011
Latest reply on Aug 24, 2011 by Mark Hotchkiss

Hi,

I have an application which stores data on the flash and i need this data to be kept when updating the firmware (programming the microcontroller with new firmware). I am allocating the first page of flash for this purpose in the prm file (page 0xC000-0xC1FF):

    SEGMENTS
        ROM2     =  READ_ONLY    0xC000 TO 0xC1FF;         // keep first page free for Saving data
        ROM       =  READ_ONLY    0xC200 TO 0xFFAD;  

    END

All the firmware code is placed in the ROM section (defined in the PLACMENT section of the prm file) so that actual code lies only from the second page and above (0xC200-0xFFAD). No coed is placed in the ROM2 page but despite that, when i am downloading firmware to the microcontroller it erases also the first page. I believe it keeps performing "mass erase" instead of  multiple "page erase" commands.

I am using MC9S08QE and i am programming it using the USBDMLT pod (www.TechnologicalArt.com) which runs the open source USBDM files. I am programming the microcontroller using Freescale's "True-Time Simulator & Real-Time Debugger" (hiwave) but i also tried the BDM Flash Programmer.

 

I am doing the same thing (keeping one page from being erased during firmware update) on a different device, the MC9S08QG, with freescale's USBSPYDER and it works perfectly just by allocating the pages in the prm file as described above. The USBSPYDER does not support the MC9S08QE devices so i can't use it here.

 

How can i erase only the needed flash pages when updating firmware and the entire flash?

 

Thanks in advance.

Timor

Outcomes