FSTAT_PVIOL=1; /*clear the PVIOL flag bit*/
FSTAT_ACCERR=1; /*clear the ACCERR flag bit*/
FPROT_FPOPEN=1; /*sectors not protected and are enabled for program or erase*/
FPROT_FPHDIS=1; /*higher protection disable*/
FPROT_FPLDIS=1; /*lower protection disable*/
}
}
void FLASHWrite(unsigned int addr,unsigned int data)
{
unsigned int *paddr;
{
FCNFG_BKSEL=0;
paddr=(unsigned int *)addr;
while(!FSTAT_CBEIF){} //if there are still some commands in the buffer, wait
*paddr=data; //write the data into the address
FCMD=0x20;
FSTAT_CBEIF=1; //clear the interrupt flag.
}
}
void main(void) {
EnableInterrupts;
FLASHInit();
/*write a word into unbanked flash*/
FCNFG_BKSEL=0; /*select flash block*/