Cread8, Cread16, Cread24, Cread32, Cread64
Syntax
Assignment Variable = Cread8 Label [ Offset Variable ] or Assignment Variable = Cread16 Label [ Offset Variable ] or Assignment Variable = Cread24 Label [ Offset Variable ] or Assignment Variable = Cread32 Label [ Offset Variable ] or Assignment Variable = Cread64 Label [ Offset Variable ]
Overview
Read an 8, 16, 24, 32 or 64-bit value from a flash memory table using an offset of Offset Variable and place into Variable.
Cread8 will access 8-bit constant values from a flash memory table. Cread16 will access 16-bit constant values from a flash memory table. Cread24 will access 24-bit constant values from a flash memory table. Cread32 will access 32-bit constant values from a flash memory table, this also includes 32-bit floating point values. Cread64 will access 64-bit constant values from a flash memory table.
Parameters
Assignment Variable is a user defined variable. Label is a label name given to the code memory table of which values will be read from. Offset Variable can be a constant value, variable, or expression that points to the location of interest within the code memory table.
Cread8 Example
' Extract the second value from within an 8-bit flash memory table
'
Device = 24FJ64GA002 ' Select the device to compile for
Declare Xtal = 16
Declare Hserial_Baud = 9600 ' USART1 Baud rate
Declare Hrsout1_Pin = PORTB.14 ' Select the pin for TX with USART1
Dim Offset as Byte ' Create a Byte size variable for the offset
Dim MyResult as Byte ' Create a Byte size variable to hold the result
'
' Create a flash memory table containing only 8-bit values
'
Dim Byte_Table as Code = as Byte 100, 200
RPOR7 = 3 ' Make PPS Pin RP14 U1TX
Offset = 1 ' Point to second value in the flash memory table
'
' Read the 8-bit value pointed to by Offset
'
MyResult = Cread8 Byte_Table[Offset]
HrsoutLn Dec MyResult ' Display the decimal result
Cread16 Example
' Extract the second value from within a 16-bit flash memory table
'
Device = 24FJ64GA002 ' Select the device to compile for
Declare Xtal = 16
Declare Hserial_Baud = 9600 ' USART1 Baud rate
Declare Hrsout1_Pin = PORTB.14 ' Select the pin for TX with USART1
Dim Offset as Byte ' Create a Byte size variable for the offset
Dim MyResult as Word ' Create a Word size variable to hold the result
'
' Create a flash memory table containing only 16-bit values
'
Dim Word_Table as Code = as Word 1234, 5678
RPOR7 = 3 ' Make PPS Pin RP14 U1TX
Offset = 1 ' Point to the second value in the flash table
'
' Read the 16-bit value pointed to by Offset
'
MyResult = Cread16 Word_Table[Offset]
HrsoutLn Dec MyResult ' Display the decimal result
Cread24 Example
' Extract the second value from within a 24-bit flash memory table
'
Device = 24FJ64GA002 ' Select the device to compile for
Declare Xtal = 16
Declare Hserial_Baud = 9600 ' USART1 Baud rate
Declare Hrsout1_Pin = PORTB.14 ' Select the pin for TX with USART1
Dim Offset as Byte ' Create a Byte size variable for the offset
Dim MyResult as Dword ' Create a Dword size variable to hold the result
'
' Create a flash memory table containing only 24-bit values
'
Dim Long_Table as Code = as Long 12340, 56780
RPOR7 = 3 ' Make PPS Pin RP14 U1TX
Offset = 1 ' Point to the second value in the flash table
'
' Read the 24-bit value pointed to by Offset
'
MyResult = Cread24 Long_Table[Offset]
HrsoutLn Dec MyResult ' Display the decimal result
Cread32 Example
' Extract the second value from within a 32-bit flash memory table
'
Device = 24FJ64GA002 ' Select the device to compile for
Declare Xtal = 16
Declare Hserial_Baud = 9600 ' USART1 Baud rate
Declare Hrsout1_Pin = PORTB.14 ' Select the pin for TX with USART1
Dim Offset as Byte ' Create a Byte size variable for the offset
Dim MyResult as Dword ' Create a Dword size variable to hold the result
'
' Create a flash memory table containing only 32-bit values
'
Dim Dword_Table as Code = as Dword 12340, 56780
RPOR7 = 3 ' Make PPS Pin RP14 U1TX
Offset = 1 ' Point to the second value in the flash table
'
' Read the 32-bit value pointed to by Offset
'
MyResult = Cread32 Dword_Table[Offset]
HrsoutLn Dec MyResult ' Display the decimal result
See also : Dim As Code, cPtr8, cPtr16, cPtr24, cPtr32, cPtr64.


