How to write to ROM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to write to ROM

2,449 Views
Adam
Contributor III
Using a mc9s12gc32

I have a portion of code that starts runs out of the 3F page fixed at 0xc0000. I am trying to write to the 3E ROM page directly as the program runs out of the 3F page Or (even writing to portions of the 3F page).

Example:
LDX #$C800 ;
EE_ZERO_ROM_LOOP ;
CLR 0,X ; Clear ROM Area
INX ;
CPX #$FFEF ;
BLE EE_ZERO_ROM_LOOP ;

So here, I am trying to clear the ROM area from 0xC800 to 0xFFEF.... but the ROM doesn't seem to clear.

Am I missing something?
Labels (1)
0 Kudos
3 Replies

888 Views
Ilocano
Contributor I
Below thread might be of some use to help with this topic
http://technologicalarts.net/viewtopic.php?t=36
0 Kudos

888 Views
Adam
Contributor III
Thank, that was a huge help.
0 Kudos

888 Views
glork
Contributor I
Hi Adam.
That area of on-board memory is actually FLASH (eeprom) memory. It has very specific and difficult erase/write requirements, and cannot be treated as ram.
While it is possible to erase and write portions of flash from within a user/application there are some constraints:
1. You must first erase a row/page/block (varies per controller)
2. Your code that is to erase/write the flash cannot be running out of the block being modified.
3. There are some serious timing issues involved.

For this reason freescale provides a chunk of hardware somewhere within the controller that performs the lowest-level of these tasks for you, but still your code thats using this hardware must not be running in the area of flash that you wish to modify.

Freescale provides some application notes on this matter (sorry, I don't have the a/n numbers because I haven't used them). Search the app note area for 'doonstack' (do-on-stack) which is a routine for writing flash that runs on the cpu stack in ram.
Hope this helps.
ron
0 Kudos