The position in the program will not have any bearing on how WRITE operates. Put it wherever you want it.
If an interrupt occurs in the middle of a WRITE sequence, it can cause the WRITE to fail. But, the interrupt has to happen at just the right time to cause a problem. So turning OFF interrupts everytime isn't always necessary.
I like to try writing to EEPROM with interrupts turned on, to reduce the possibily of losing other interrupts(10ms is a long time).
Do the WRITE, then READ it back to see if the WRITE was successful, if not, try again. If interrupts are happening so fast that it fails 3 times in a row. Then turn off the interrupts (INTCON.7 = 0) and write it one last time.
Unless your interrupts are happening at a very high speed, the write will succeed the first time, 99% of the time or better.
<br>
Bookmarks