Syntax:
SAFWriteWord ( location, data_word_value )
Command Availability:
Available on all PIC micro-controllers with SAFM memory
Explanation:
SAFWriteWord is used to write information, word values, to the SAFM data storage, so that it can be accessed later by a programmer
on a Personal, or by the SAFRead commands.
location
presents the location or relative address to write. 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 data that is to be written to the SAFM location. This can be a word value or a word variable.
This method writes information to SAFM given the specific location in SAFM.
This method is similar to the methods for EEPROM, but supports Word values.
Example 1:
'... code preamble to select part '... code to setup serial 'The following example stores in the word value of 0x1234 as SAFM location 34 SAFWriteWord( 34, 0x1234 )
Example 2:
#chip 18F24K42, 16 '... code to setup PPS '... code to setup serial 'This example will write two word values to two specific locations. dim Word_Variable1 as Word dim Word_Variable2 as Word ;Write the data SAFWriteWord (16, 0x1234) 'location 16, in this device, equates to 0x7F10 SAFWriteWord (18, 0x4321) 'location 18, in this device, equates to 0x7F12 ;Read the data and send to terminal SAFReadWord(16, Word_Variable1 ) SAFReadWord(18, Word_Variable2 ) HserPrint "Word_Variable1 = " Hserprint Word_Variable1 HSerPrintCRLF HserPrint "Word_Variable2 = " Hserprint Word_Variable2 HSerPrintCRLF
If example 2 were displayed on a serial terminal. The result would show, where ----
is the existing value.
Word_Variable1 = 4660 Word_Variable2 = 17185
See also
SAFM Overview,
SAFRead,
SAFReadWord,
SAFWrite,
SAFWriteWord,
SAFReadBlock,
SAFWriteBlock,
SAFEraseBlock