MC96FR116C
190
November, 2018 Rev.1.8
// PGM or ERASE Timing, normally the same values are set.
#define PGMTIME
0x4F // 2.5ms @4MHz
#define ERSTIME
0x4F // 2.5ms @4MHz
void page_buffer_reset();
void flash_page_write(unsigned int addr, unsigned char *wdata);
void flash_page_erase(unsigned int addr);
void flash_program_enter();
void flash_program_exit();
xdata unsigned char pagerom[FLASH_PBUFF_SIZE] _at_ 0x8000; // page buffer
data unsigned char page_data[FLASH_PBUFF_SIZE]; // write data buffer
void main()
{
unsigned p_index;
// Step 2
flash_program_entry();
eeprom_page_erase(0xF000);
// Tmp data for page write operation. Try other data!!!
for (p_index=0; p_index < FLASH_PBUFF_SIZE; +) {
page_data[p_index] = p_index;
}
eeprom_page_write(0xF000, page_data);
// Step 10
flash_program_exit();
while(1);
}
void
flash_page_
erase(unsigned int addr)
{
int i;
unsigned char temp;
int addr_index;
// Step 1
FETCR = ERSTIME;
// Step 3
page_buffer_reset();
// Step 4