Dear sir,
I am using ms9c12xdp512 16 bit mcu. I want to erase flash by sector(1024 bytes). But the function can not work. Can you help me?
main.c
{
INT8U data[2] = {48, 49};
writeByte(0xFA, (INT8U*)0xBFFE, data, 2); //Write data to PAGE_FA, check the memory, it worked.
eraserSector(0xFA, 0x8000, 16); //After calling this, it does not work, the data in 0XFABFFE is still there.
}
//erase by sector(1024 bytes)
void eraserSector(INT8U page, INT16U address, INT8U count){
INT16U i;
INT8U d;
INT8U oldPage;
oldPage = PPAGE;
while(!(FCLKDIV & 0x80));
if(PPAGE){
PPAGE = page;
d = page&0x0C;
d = d>>2;
FCNFG = 3-d;
}
for(i=0;i<count;i++, address += 1024){
while(!(FSTAT & 0x80));
while(FSTAT & 0x30){
FSTAT |= 0x30;
}
while(!(FPROT & 0x80));
__DINT;
*(INT16U*)address = 0xFFFF;
FCMD = 0x40;
FSTAT |= 0x80;
while( !FSTAT_CBEIF );
while( !FSTAT_CCIF );
__EINT;
}
PPAGE = oldPage;
}
Hi,
I would like to provide you solution for flash (XDP512-FLASH-E_W-CW51). You can also find functions you would like to create. Moreover I have added a memory map to better understand local, globall, ppage... access.
Probably for the future you will be also require EEPROM routines so I have also attached them. (SW-XDP512-EEPROM-E_W-CW47.ZIP)
I hope and believe provided materials will lead you to understand and sucesfully solve your project.
Best regards,
Ladislav