puneeth NS

Not able to use Flash for buring data (as ROM)

Discussion created by puneeth NS on Mar 27, 2008
Latest reply on Mar 29, 2008 by puneeth NS

  I am using MC9S08AW16, trying to burn the flash region with some data to use it as ROM, i used the program given in the HCS08_Peripherals_Module_Quick_Reference_Users_Guide, that program does not work and not able to understand the algorithm given in the data sheet. especially about using FCBEF ( Write 1 to FCBEF to launch command and clear FCBEF). In the full chip simulation it says using unintialliatized location, when programmed is on the chip, only first location is burnt with data other locations are not burnt. Also when I enable channel interrupts in the program and use full chip simulation, interrupt does not occur. But works properly when program is in the chip.

code in the reference material:

//Array of opcode instructions of the Erase/Program function
//Element 0x14 of the array is: (command 0x20 to program a byte, 0x40 to erase a page)
unsigned char FLASH_CMD[] {
/* The opcode above represents this set of instructions
if (FSTAT&0x10){ //Check to see if FACCERR is set
FSTAT = FSTAT | 0x10; //write a 1 to FACCERR to clear
(*((volatile unsigned char *)(Address))) = data; //write to somewhere in flash
FCMD = 0x20; //set command type.
FSTAT = FSTAT | 0x80; //Put FCBEF at 1.
_asm NOP; //Wait 4 cycles
_asm NOP;
_asm NOP;
_asm NOP;
if (FSTAT&0x30){ //check to see if FACCERR or FVIOL are set
return 0xFF; //if so, error.
while ((FSTAT&0x40)==0){ //else wait for command to complete