-
Notifications
You must be signed in to change notification settings - Fork 8
safreadword
Syntax:
'as a subroutine
SAFReadWord ( location, data_word_variable )
'as a function
data_word_variable = SAFReadWord ( location )
Command Availability:
Available on all PIC micro-controllers with SAFM memory
Explanation:
SAFReadWord is used to read information, word values, from SAFM so that it can be accessed for use in a user program.
location
represents the location or relative address to read. The
location will range from 0 to SAF_BYTES -1. Each data Word requires
2 SAF Locations, therefore the location will range from either 0 to 254
or 0 to 126 (in steps of 2), depending upon the device.
data
is the word data that is to be read from the SAFM location.
This must be a word variable.
This method reads word information from SAFM given the relative location in SAFM.
Example 1:
'... code preamble to select part
'... code to setup serial
'The following example uses a subroutine to read an SAFM location into a word variable.
dim data_word_variable as word
;Write a word to SAF location 64
SAFWriteWord( 64, 0x1234 )
; Read the Word from SAF location 64
SAFReadWord ( 64, data_word_variable )
HSerPrint "Value = "
HSerPrint data_word_variable
HSerPrintCRLF
If example 1 were displayed on a serial terminal. The result would show:
Value = 4660
Example 2:
'... code preamble to select part
'... code to setup serial
'The following example uses a function to read an SAFM location into a word variable.
dim data_word_variable as word
;Write a word to SAF location 64
SAFWriteWord( 64, 0x4321 )
; Read the Word from SAF location 64
data_word_variable = SAFReadWord ( 64 )
HSerPrint "Value = "
HSerPrint data_word_variable
HSerPrintCRLF
If example 2 were displayed on a serial terminal. The result would show:
Value = 17185
See also SAFM Overview, SAFRead, SAFReadWord, SAFWrite, SAFWriteWord, SAFReadBlock, SAFWriteBlock, SAFEraseBlock