Cread
Syntax
Variable = Cread Address
Overview
Read data from anywhere in flash memory.
Parameters
Variable is a user defined variable. Address is a constant, variable, label, or expression that represents any valid address within flash memory
Example
' Read flash memory locations within the device
Device = 18F26K40
' Tell the compiler what device to compile for
Declare Xtal = 16
' Tell the compiler the device is operating at 16MHz
Declare Hserial_Baud = 9600
Dim bVar1 as Byte
Dim wWrd as Word
Dim wAddress as Word
wAddress = 1000
' Address now holds the base address
bVar1 = Cread 1000
' Read 8-bit data at address 1000 into Var1
wWrd = Cread Address + 10
' Read data at address 1000+10
Notes
The Cread command takes advantage of the self-modifying feature that is available in the latest devices.
If a Float or Dword size variable is used as the assignment, then 32-bits will be read. If a Word size variable is used as the assignment, then 16-bits will be read. If a Byte sized variable is used as the assignment, then 8-bits will be read.
If the device has it, the configuration fuse setting WRTE must be enabled before Cdata, Dim as Flash, Cread, and Cwrite may be used, this is the default setting. This enables the selfmodifying feature. If the Config directive is used, then the WRTE_ON fuse setting must be included in the list: -
Config WDT_ON, XT_OSC, WRTE_ON