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
Hi,

  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[] {
0x87,0xC6,0x18,0x25,0xA5,0x10,0x27,0x08,0xC6,0x18,0x25,0xAA,0x10,0xC7,0x18,0x25,
0x9E,0xE6,0x01,0xF7,0xA6,0x20,0xC7,0x18,0x26,0x45,0x18,0x25,0xF6,0xAA,0x80,0xF7,
0x9D,0x9D,0x9D,0x9D,0x45,0x18,0x25,0xF6,0xF7,0xF6,0xA5,0x30,0x27,0x04,0xA6,0xFF,
0x20,0x07,0xC6,0x18,0x25,0xA5,0x40,0x27,0xF9,0x8A,0x81};
/* 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
;
}*/



Outcomes