Hello everybody, I know this has been discussed in previous posts but I still can't achieve to write on flash or even erase the page.
I'm using a simple code from AN3404 which apparently follows the flow chart on GT60 manual, the thing is that the code works just fine if I run it step by step, but if I let it to fully run (not step by step or breakpoints) the debugger keep saying me that the frequency has changed and sometimes the program stops or just hang. The Cpu ints are disabled when any flash related operation is made. If it is of any help the app is for write data received from SCI to flash.
Here is the code use for page erase and the flash init routine:
void InitFlash(void){
FSTAT_FACCERR=1;
FSTAT_FPVIOL=1;
FCDIV = 25;
}
void NVM_Erase_Page (unsigned char *dest)
{
unsigned char dummy=0;
if (FSTAT_FACCERR == 1 || FSTAT_FPVIOL == 1) //Verifying error flags
{
FSTAT_FACCERR = 0; //Clear error flags
FSTAT_FPVIOL = 0;
}
*dest = dummy;
FCMD = mPageErase; //Byte program command
FSTAT_FCBEF = 1; //Run the command
_asm NOP;
_asm NOP;
_asm NOP;
_asm NOP;
if (FSTAT_FACCERR == 1 || FSTAT_FPVIOL == 1) //Verifying error flags
{
FSTAT_FACCERR = 0; //Clear error flags
FSTAT_FPVIOL = 0;
}
while (FSTAT_FCCF == 0);
}
The BUS frequency is set around 4.45 MHz
Thanks in advance
Victor