- Published: Saturday, 04 April 2009
- Written by Digital DIY
- Hits: 9048
The EEPROM on a PIC micro is memory that can contain information even while the PIC is turned off. This is useful for storing data/passwords/key information that is changeable, but required by the program.
Reading and writing to/from the PIC's EEPROM is very simple with a higher programming language such as Proton+, and is as simple as the following;
The type of variable being save will determine the amount of EEPROM memory that will be written too. For example:
The above example will write Large_Variable to address 00 of the PIC's EEPROM. But because DWord's contain 4 bytes of information, addresses 00, 01, 02, 03 will be written too. You must take things like this into account. Other examples are Words take 2 Bytes, or Floats take 4 Bytes etc.
Reading from the EEPROM is just as easy, and a quick look at the Proton Help file will guide you in the right direction.
Note: PIC's, like other EEPROMS, can only be written too 1,000,000 times by the datasheet. In reality, this value can be as low as 100,000. Do not write to the EEPROM in a continues loop - use it sparingly. There is no limit on reading EEPROM data however.
Here's a small program displaying an EEPROM read and write: