Data Definitions
can also be made to an addressmod data type. The #type directive can
be used to make this memory region as default for variable allocations.
The syntax is :
#type default=addressmodname
// all the variable declarations
that
// follow will use this memory
region
#type default=
For example:
Type default=emi
// goes back to the default mode
//emi is the addressmod name
defined
char buffer[8192];
#include <memoryhog.h>
#type default=
Using Program Memory for Data
CCS C Compiler provides a few different ways to use program memory for data. The different
ways are discussed below:
Constant Data:
The const qualifier will place the variables into program memory. If the keyword const is used
before the identifier, the identifier is treated as a constant. Constants should be initialized and
may not be changed at run-time. This is an easy way to create lookup tables.
The rom Qualifier puts data in program memory with 3 bytes per instruction space. The address
used for ROM data is not a physical address but rather a true byte address. The & operator can
be used on ROM variables however the address is logical not physical.
The syntax is:
const type id[cexpr] = {value}
For example:
Placing data into ROM
const int table[16]={0,1,2...15}
Placing a string into ROM
const char cstring[6]={"hello"}
Creating pointers to constants
const char *cptr;
cptr = string;
The #org preprocessor can be used to place the constant to specified address blocks.
For example:
The constant ID will be at 1C00.
#ORG 0x1C00, 0x1C0F
CONST CHAR ID[10]= {"123456789"};
Note : Some extra code will precede the 123456789.
The function label_address can be used to get the address of the constant. The constant
variable can be accessed in the code. This is a great way of storing constant data in large
programs. Variable length constant strings can be stored into program memory.
A special method allows the use of pointers to ROM. This method does not contain extra code
at the start of the structure as does constant.
27
相关PDF资料
PCI-EXP-T42G5-N1 IP CORE PCI EXPRESS ORCA 4
PCM18XH2 PROCESSOR MODULE MPLAB-ICE 2000
PCM18XN0 PROCESSOR MODULE FOR ICE2000
PDA-B-24-615-E-2B1-1-C CIRCUIT BREAKER MAG 1P 15A
PFMF.260.2 PFMF PTC FUSE SMT 2.6A 1812
PFNF.200.2 PFNF PTC FUSE SMT 2A 1206
PFRY.375 PTC-FUSE RADIAL 72 VDC
PFSM.150.33.2 FUSE PTC 8A 15V FST-TRIP SMD
相关代理商/技术参数
PCD_09 制造商:MACOM 制造商全称:Tyco Electronics 功能描述:Low Profile PCB Relay PCD
PCD-00173-0C 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY
PCD-00173-0E 制造商:Molex 功能描述:Ethernet Cable Assembly
PCD-00173-0H 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY
PCD-00173-0K 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY
PCD-00174-0C 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY; Cable Length - Imperial:3ft; Cable Length - Metric:914.4mm; Connector Type A:RJ45 Plug; Connector Type B:RJ45 Plug; Jacket Color:Red; Approval Bodies:CSA / UL; Body Material:PVC; Cable Assembly Type:Ethernet ;RoHS Compliant: NA
PCD-00174-0E 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY; Cable Length - Imperial:3ft; Cable Length - Metric:914.4mm; Connector Type A:RJ45 Plug; Connector Type B:RJ45 Plug; Jacket Color:Grey; Approval Bodies:CSA / UL; Body Material:PVC; Cable Assembly Type:Ethernet;RoHS Compliant: NA
PCD-00174-0H 制造商:Molex 功能描述:ETHERNET CABLE ASSEMBLY