READ location,variable,variable, WORD wordvariable
Location - is a variable/constant specifying a byte-wise address (0-255).
Variable - receives the data byte read.To use a word variable the keyword WORD must be used before the wordvariable).
Read EEPROM data memory byte content into variable.
The read command allows byte data to be read from the microcontroller's internal data memory. The contents of this memory is not lost when the power is removed. However the data is updated (with the EEPROM command specified data) upon a new download. To save the data during a program use the write command.
The read command is byte wide, so to read a word variable two separate byte read commands will be required, one for each of the two bytes that makes the word (e.g. for w0, read both b0 and b1). With the PICAXE-08, 08M, 08M2, 14M, 18, 18M and 18M2 the data memory is shared with program memory. See the EEPROM command for more details.
When word variables are used (with the keyword WORD) the two bytes of the word are saved/retrieved in a little endian manner (ie low byte at address, high byte at address + 1).
Read EEPROM data
Transfer the values stored in EEPROM location 0 to 63 to a serial LCD
Read word data from Data EEPROM
This program will load the contents of two word variables from Data EEPROM. The w0 variable is loaded from locations 0 and 1 while the w1 variable is loaded from locations 2 and 3. As w0 is formed from b0 and b1, w1 is formed from b2 and b3, the next unused byte variable is b4. The b4 variable is used to specify the location within EEPROM to load from. Note that the b4 variable has to be increased by 2 to read word variables from sequential locations in EEPROM as each data word stored uses two consecutive bytes of storage.
- Code Example:
; data eeprom holds loc data will be read into ; 0 $34 w0 lsb (b0) ; 1 $12 w0 msb (b1) ; 2 $CD w1 lsb (b2) ; 3 $AB w2 msb (b3) let b4 = 0 ; read w0 from location 0 and 1 read b4, word w0 let b4 = b4 + 2 ; read w1 from location 2 and 3 read b4, word w1 debug ; w0 now holds $1234, w1 holds $ABCD endCopy Code Submit an Example
Submit Your Own Code!
You must be logged in to submit code examples. Login now.