cPtr8, cPtr16, cPtr24, cPtr32
Syntax
Variable = cPtr8 (Address) Variable = cPtr16 (Address) Variable = cPtr24 (Address) Variable = cPtr32 (Address)
Overview
Indirectly read flash memory using a variable to hold the 16-bit or 32-bit address. For enhanced 14-bit core devices and 18F devices only.
Parameters
Variable is a user defined variable that holds the result of the indirectly addressed flash memory area. Address is a Word, Long, or Dword variable, or an expression that holds the 16-bit, 24-bit, or 32-bit address of the flash memory area of interest.
Address can also post or pre increment or decrement:
(MyAddress++) Post increment MyAddress after retrieving it’s RAM location. (MyAddress --) Post decrement MyAddress after retrieving it’s RAM location. (++MyAddress) Pre increment MyAddress before retrieving it’s RAM location. (--MyAddress) Pre decrement MyAddress before retrieving it’s RAM location.
cPtr8 will retrieve a value with an optional 8-bit post or pre increment or decrement. cPtr16 will retrieve a value with an optional 16-bit post or pre increment or decrement. cPtr24 will retrieve a value with an optional 24-bit post or pre increment or decrement. cPtr32 will retrieve a value with an optional 32-bit post or pre increment or decrement.
8-bit Example.
'
' Read 8-bit values indirectly from flash memory
'
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
'
' Create an 8-bit flash memory table
'
Dim FlashArray As Flash8 = 1, 2, 3, 4, 5, 6, 7, 8, 9, 0
Dim MyByte As Byte
' Create a byte variable
Dim bIndex As Byte
Dim wAddress As Word
' Create variable to hold 16-bit address
Main:
'
' Read from flash memory
'
wAddress = AddressOf(FlashArray) ' Load wAddress with address of flash memory
Do
' Create a loop
MyByte = cPtr8(wAddress++) ' Retrieve from code with post increment
If MyByte = 0 Then Break ' Exit when a null(0) is read from code
HRsoutLn Dec MyByte
' Transmit the byte read from code
Loop
16-bit Example.
'
' Read 16-bit values indirectly from flash memory
'
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
'
' Create a 16-bit flash memory table
'
Dim FlashArray As Flash16 = 100, 200, 300, 400, 500, 600, 700, 0
Dim MyWord As Word
' Create a word variable
Dim bIndex As Byte
Dim wAddress As Word
' Create variable to hold 16-bit address
Main:
'
' Read from flash memory
'
wAddress = AddressOf(FlashArray)
' Load wAddress with address of memory
Do
' Create a loop
MyWord = cPtr16(wAddress++)
' Retrieve from code with post increment
If MyWord = 0 Then Break
' Exit when a null(0) is read from code
HRsoutLn Dec MyWord
' Transmit the word read from code
Loop
24-bit Example.
'
' Read 24-bit values indirectly from flash memory
'
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
'
' Create a 24-bit flash memory table
'
Dim FlashArray As Flash24 = 100, 200, 300, 400, 500, 600, 700, 0
Dim MyLong As Long
' Create a long variable
Dim bIndex As Byte
Dim wAddress As Word
' Create variable to hold 16-bit address
Main:
'
' Read from flash memory
'
wAddress = AddressOf(FlashArray)
' Load wAddress with address of memory
Do
' Create a loop
MyLong = cPtr24(wAddress++)
' Retrieve from code with post increment
If MyLong = 0 Then Break
' Exit when a null(0) is read from code
HRsoutLn Dec MyLong
' Transmit the long read from code
Loop
32-bit Example.
'
' Read 32-bit values indirectly from flash memory
'
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
'
' Create a 32-bit flash memory table
'
Dim FlashArray As Flash32 = 100, 200, 300, 400, 500, 600, 700, 0
Dim MyDword As Dword
' Create a dword variable
Dim bIndex As Byte
Dim wAddress As Word
' Create variable to hold 16-bit address
Main:
'
' Read from flash memory
'
wAddress = AddressOf(FlashArray)
' Load wAddress with address of memory
Do
' Create a loop
MyDword = cPtr32(wAddress++)
' Retrieve from code with post increment
If MyDword = 0 Then Break
' Exit when a null(0) is read from code
HRsoutLn Dec MyDword
' Transmit the dword read from code
Loop