emulate from ram

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

emulate from ram

2,673 Views
jah
Contributor I
-how do i setup so my flash routines emualte from ram
-someone must have done this recently, any help thanks
-how do i get the linker to build the ram code and load it into ram at startup
-has all this been done before? i need to flash page erase and byte write




flash.c functions are below:
#pragma DATA_SEG _FLASH_TOOL
static void Flash_Erase (unsigned int FlashAddress){

FixedAddres = FlashAddress;
// DataToWrite = 0xFF;
// Ram_Routine[22] = 0x40;
// __asm jsr Ram_Routine;
if(FSTAT & 0x10) FSTAT |= 0x10; //Check to see if FACCERR is set, write a 1 to FACCERR to clear error

*(unsigned char *)FixedAddres = 0xFF; //write anything anywhere in the page to erase

FCMD = 0x40; //load flash command type.
FSTAT |= 0x80; //Put FSTAT/FCBEF = launch a new burst command & wait 4 cycles
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;

// if (FSTAT&0x30)return; //check to see if FSTAT/FACCERR = an error occuredor FVIOL are set

while (!(FSTAT & 0x40)); //else wait for comand to complete
}//void Flash_Erase (unsign
//************************

//*************>>> stores a byte of data onto the Flash at the given address **************************************
static void Flash_Program(unsigned char data){

//Check to see if FACCERR is set
if (FSTAT & 0x10) FSTAT |= 0x10; //write a 1 to FACCERR to clear

//write to flash
*(unsigned char *)FixedAddres = (unsigned char)data;
FCMD = 0x20; //set command type & launch operation, wait 4 cyc.
FSTAT |= 0x80;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;

// if(FSTAT&0x30) return; //check to see if FACCERR or FVIOL are set

while (!(FSTAT & 0x40)); //else wait for comand to complete
}//void Flash_Program(By...

#pragma DATA_SEG DEFAULT
//************************


flash.h
#pragma DATA_SEG _FLASH_TOOL
static void Flash_Erase (unsigned int);
static void Flash_Program(unsigned char);
#pragma CODE_SEG DEFAULT



mylinker.prn
SEGMENTS
Z_RAM = READ_WRITE 0x0046 TO 0x00FF;
RAM = READ_WRITE 0x0100 TO 0x04FF;
PATCH_RAM = READ_WRITE 0x0500 TO 0x06FF;
FLASH_TOOL= READ_WRITE 0x0700 TO 0x07C7;
PLACEMENT
DEFAULT_ROM INTO ROM;
DEFAULT_RAM INTO RAM, RAM2;
_FLASH_TOOL INTO FLASH_TOOL;
Labels (1)
0 Kudos
4 Replies

285 Views
J2MEJediMaster
Specialist I
Go to the FAQ section of the Freescale web site and search for "Flash programming" (no quotes). FAQ-26240 talks about how to implement Flash programming in detail, along with references to the appropriate app notes.

---Tom
0 Kudos

285 Views
Saga
Contributor II
It says to go to technical note 228, but how do i access to that technical note? it doesn't has a link nor i find it anywhere in the site, thank you!
0 Kudos

285 Views
bigmac
Specialist III
Use the forum search facility, and search for TN228.  Then open up the first reference, and you should find a link to the document you require.
0 Kudos

285 Views
Saga
Contributor II
I found it! Thank you BIGMAC.
0 Kudos