Name:
read
Syntax:

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).

Description:

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).

Applies To:
All
See Also:
Related Create:
    Share:
    Print:

    Read EEPROM data

    Transfer the values stored in EEPROM location 0 to 63 to a serial LCD

    Code Example:
    main:	for b0 = 0 to 63	; start a loop
    	  read b0,b1		; read value at b0 into b1
    	  serout B.7,N2400,(b1)	; transmit value to serial LCD
    	next b0			; next loop
    Copy Code Submit an Example

    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
    
    end
    Copy Code Submit an Example

    Submit Your Own Code!

    You must be logged in to submit code examples. Login now.

    Comments

    • Login to leave a comment.