Eread
Syntax
Variable = Eread Address
Overview
Read information from the on-board EEPROM (Electrically Erasable Programmable Read Only Memory) available on some PICmicro™ types.
Parameters
Address is a constant, variable, or expression, that contains the address of interest within EEPROM. Variable is a user defined variable.
Example
Device = 18F452
' A suitable device with on-board EEPROM
Dim MyByte as Byte
Dim MyWord as Word
Dim MyLong as Long
Dim MyDword as Dword
Edata 10, 354, 123456789
' Place some data into the EEPROM
MyByte = Eread 0
' Read the 8-bit value from address 0
MyWord = Eread 1
' Read the 16-bit value from address 1
MyLong = Eread 3
' Read the 24-bit value from address 3
MyDword = Eread 7
' Read the 32-bit value from address 7
Notes
If a Float, or Dword type variable is used as the assignment variable, then 4-bytes will be read from the EEPROM. Similarly, if a Long type variable is used as the assignment variable, then a 24-bit value (3-bytes) will be read from EEPROM. If a Word type variable is used as the assignment variable, then a 16-bit value (2-bytes) will be read from EEPROM, and if a Byte type variable is used, then 8-bits will be read. To read an 8-bit value while using a Word sized variable, use the LowByte modifier: -
Wrd1.LowByte = Eread 0 ' Read an 8-bit value
Wrd1.HighByte = 0
' Clear the high byte of Wrd
If a 16-bit (Word) size value is read from the EEPROM, the address must be incremented by two for the next read. If a Long type variable is read, then the address must be incremented by 3. Also, if a Float or Dword type variable is read, then the address must be incremented by 4.
Most of the PICmicro™ types have a portion of memory set aside for storage of information. The amount of memory is specific to the individual PICmicro™ type, some, such as the 16F84, has 64 bytes, the 16F877 device has 256 bytes, and some of the 18F devices have upwards of 512 bytes.
EEPROM is non-volatile, and is an excellent place for storage of long-term information, or tables of values.
Reading data with the Eread command is almost instantaneous, but writing data to the EEPROM can take up to 10ms per byte.