hi can anybody provide me c code examples for flash erase and programming. and tell me whether it is necessary to save the pages or that is optional. will the below will do? /* Page size array (512 instruction words) */ C_UBYTE Luilow_Page_Array[512]; C_UBYTE Luihigh_Page_Array[512]; C_UINT16 Luipage_Count; /* Save Current page */ C_UINT16 SAV_TBLPAG = TBLPAG; C_UINT16 *LppPM_Destination_Address = (C_UINT16 *)(Lul_Sector_Addr); /* A dummy table write to any location in the page selects the address of the row to be erased. * The program memory must be erased at an even 512 instruction word address boundary. Therefore, * the 10 Least Significant bits of the table write program memory address have no effect when * a page is erased */ Luipage_flash_addr = (Lul_Sector_Addr & 0xFFFC00);
/* Save flash page data */ for(Luipage_Count=0; Luipage_Count>16)&(0xFF)); /* Dummy write */ __builtin_tblwtl(Luipage_flash_addr, 0xFFFF); /* Write the KEY Sequence */ NVMKEY=KEY_SEQ_1; NVMKEY=KEY_SEQ_2; /* Start the erase operation */ /* __builtin_write_NVM();*/ NVMCON|=ERASE_INIT; Nop() Nop() /* Wait till the Erase operation completes */ while(NVMCON_WR); /* Restore Table page */ TBLPAG = SAV_TBLPAG;
--------------------------------------- This message was sent using the comp.arch.embedded web interface on