11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Supported Data Types and VariablesC Language FeaturesThe psects in which bit objects are allocated storage are declared using the bit PSECT directiveflag. Eight bit objects will take up one byte of storage space which is indicated by the psect’s scalevalue of 8 in the map file. The length given in the map file for bit psects is in units of bits, not bytes.All addresses specified for bit objects are also bit addresses.The bit psects are cleared on startup, but are not initialised. To create a bit object which has anon-zero initial value, explicitly initialise it at the beginning of your code.If the DSPICC flag --STRICT is used, the bit keyword becomes unavailable.3.4.3 8-Bit Integer Data Types and VariablesHI-TECH <strong>dsPIC</strong>C supports both signed char and unsigned char 8-bit integral types. If thesigned or unsigned keyword is absent from the variable’s definition, the default type is unsignedchar unless the DSPICC --CHAR=signed option is used, in which case the default type is signedchar. The signed char type is an 8-bit two’s complement signed integer type, representing integralvalues from -128 to +127 inclusive. The unsigned char is an 8-bit unsigned integer type, representingintegral values from 0 to 255 inclusive. It is a common misconception that the C char typesare intended purely for ASCII character manipulation. This is not true, indeed the C language makesno guarantee that the default character representation is even ASCII. The char types are simply thesmallest of up to four possible integer sizes, and behave in all respects like integers.The reason for the name “char” is historical and does not mean that char can only be used torepresent characters. It is possible to freely mix char values with short, int and long values in Cexpressions. With HI-TECH C the char types will commonly be used for a number of purposes, as8-bit integers, as storage for ASCII characters, and for access to I/O locations.Variables may be declared using the signed char and unsigned char keywords, respectively,to hold values of these types. Where only char is used in the declaration, the type will be signedchar unless the option, mentioned above, to specify unsigned char as default is used.Since the processor’s register are 16-bit wide, it can often be more efficient to use 16-bit integrervariables over 8-bit variables.3.4.4 16-Bit Integer Data TypesHI-TECH <strong>dsPIC</strong>C supports four 16-bit integer types. short and int are 16-bit two’s complementsigned integer types, representing integral values from -32,768 to +32,767 inclusive. Unsignedshort and unsigned int are 16-bit unsigned integer types, representing integral values from 0to 65,535 inclusive. All 16-bit integer values are represented in little endian format with the leastsignificant byte at the lower address.Variables may be declared using the signed short int and unsigned short int keywordsequences, respectively, to hold values of these types. When specifying a short int type, the32

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!