Positron Compiler Documentation

Ewrite

Source: Positron8 Compiler User Manual, PDF page 397

Syntax

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

Overview

Write information to the on-board EEPROM 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 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

Notes

If a Dword type variable is used, then a 32-bit value (4-bytes) will be written to the EEPROM. Similarly, if a Long type variable is used, then a 24-bit value (3-bytes) will be written to EEPROM, 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, [ Wrd.LowByte, Var1 ]

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, [Wrd]
Next

A lot of the Flash 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, have 256 bytes, while others have 1024 bytes.

EEPROM 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 on some of the older microcontroller types, but reading data from the EEPROM is almost instantaneous,.

See also : Edata, Eread