Positron Compiler Documentation

Eread

Positron16 · Revision 1.1.3.5 · PDF page 395

Assignment Variable = Eread Address

Read information from the on-board EEPROM available on some devices.

Address is a constant, variable, or expression, that contains the address of interest within EEPROM memory. Assignment Variable is a user defined variable.

Device = 24F08KL301             ' Select the device to compile for
Declare Xtal = 16

Dim MyByte As Byte
Dim MyWord As Word
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
MyDword = Eread 3             ' Read the 32-bit value from address 3

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 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: -

MyWord.LowByte = Eread 0     ' Read an 8-bit value
MyWord.HighByte = 0             ' Clear the high byte of MyWord

If a 16-bit (Word) size value is read from the EEPROM, the address must be incremented by two for the next read. Also, if a Float or Dword type variable is read, then the address must be incremented by 4.

EEPROM memory 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 5ms per byte.

See also : Edata, Ewrite

View original PDF page 395Open page in PDFOriginal PDF page 395