Positron Compiler Documentation

Ewrite

Positron16 · Revision 1.1.3.5 · PDF page 396

Ewrite Address, [ Variable {, Variable…etc } ]

Write information to the on-board EEPROM available on some devices.

Address is a constant, variable, or expression, that contains the address of interest within EEPROM memory. 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 Address as Byte
MyByte = 200
MyWord = 2456
Address = 0                       ' Point to address 0 within the EEPROM
Ewrite Address, [MyWord, MyByte]  ' Write a 16-bit then an 8-bit value

If a Dword type variable is used, then a 32-bit value (4-bytes) will be written to the EEPROM. Similarly, if a Word type variable is used, then a 16-bit value (2-bytes) will be written to EEPROM, and if a Byte type variable is used, then 8-bits will be written. To write an 8-bit value while using a Word sized variable, use the LowByte modifier: -

Ewrite Address, [MyWord.LowByte, MyByte]

If a 16-bit (Word) size value is written to the EEPROM, the address must be incremented by two before the next write: -

For Address = 0 to 64 Step 2
  Ewrite Address, [MyWord]
Next

EEPROM memory is non-volatile, and is an excellent place for storage of long-term information, or tables of values.

Writing data with the Ewrite command can take up to 5ms per byte, but reading data from the EEPROM is almost instantaneous,.

See also : Edata, Eread

View original PDF page 396Open page in PDFOriginal PDF page 396