Specifications

Chapter 2 - Microcontroller PIC16F84
0=writing disallowed
bit 3 WRERR (Write EEPROM Error Flag ) Error during writing to EEPROM
This bit was set only in cases when writing to EEPROM had been interrupted by a reset signal or
by running out of time in watchdog timer (if it's activated).
1=error occured
0=error did not occur
bit 4 EEIF (EEPROM Write Operation Interrupt Flag bit) Bit used to inform that writing data to
EEPROM has ended.
When writing has terminated, this bit would be set automatically. Programmer must clear EEIF bit
in his program in order to detect new termination of writing.
1=writing terminated
0=writing not terminated yet, or has not started
Reading from EEPROM Memory
Setting the RD bit initializes transfer of data from address found in EEADR register to EEDATA
register. As in reading data we don't need so much time as in writing, data taken over from
EEDATA register can already be used further in the next instruction.
Sample of the part of a program which reads data in EEPROM, could look something like the
following:
After the last program instruction, contents from an EEPROM address zero can be found in working
register w.
Writing to EEPROM Memory
In order to write data to EEPROM location, programmer must first write address to EEADR register
and data to EEDATA register. Only then is it useful to set WR bit which sets the whole action in
motion. WR bit will be reset, and EEIF bit set following a writing what may be used in processing
interrupts. Values 55h and AAh are the first and the second key whose disallow for accidental
writing to EEPROM to occur. These two values are written to EECON2 which serves only that
purpose, to receive these two values and thus prevent any accidental writing to EEPROM memory.
Program lines marked as 1, 2, 3, and 4 must be executed in that order in even time intervals.
Therefore, it is very important to turn off interrupts which could change the timing needed for
executing instructions. After writing, interrupts can be enabled again .
Example of the part of a program which writes data 0xEE to first location in EEPROM memory
could look something like the following:
http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_09Poglavlje.htm (2 of 3) [4/2/2003 16:18:00]