/*****************************************************************
* erase, write, and verify buffer (64 code or 8 IDLOC bytes) *
*****************************************************************/
void Write_Buffer (void)
{ if (Row_Count) // don't write an empty buffer
{ Set_TBLPTR (); // erase 64 byte 'row'
Write (0b10010100); // EEPGD=1/CFGS=0/FREE=1/WREN=1
for (x=0; x<Row_Count; x++) // write 64 byte 'row'
{ TABLAT = Row_Buffer[x];
TBLWRPOSTINC_Func (); //
}
TBLRDPOSTDEC_Func (); // fix TBLPTR, do "long write"
Write (0b10000100); // EEPGD=1/CFGS=0/FREE=0/WREN=1
Set_TBLPTR (); // verify 64 byte 'row'
for (x=0; x<Row_Count; x++)
{ TBLRDPOSTINC_Func ();
if (TABLAT != Row_Buffer[x])
{ Error_Flag = 0x04; // indicate verify error
}
Row_Buffer[x] = 0xFF; // reset row buffer byte to FF
}
Row_Count = 0; // indicate row buffer empty
}
}