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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Supported Data Types and VariablesC Language Featuresthe program using the pointer. Function pointers hold the address of an executable routine whichcan be called indirectly via the pointer.3.4.10.1 Data PointersA data pointer that is not a pointer to const references objects in the data space, or RAM. Suchpointers are 16 bits wide and can access any object resident in the data space. A data pointer to aconst-qualified object is used when the object is read-only and will not be modified. If any attemptis made to indirectly modify an object declared as const, the compiler will issue a warning.3.4.10.2 Function PointersPointers to functions can be defined to indirectly call functions or routines in the program space.The size of function pointers is always 16 bits. Although only being 16 bits, this will still workcorrectly if the selected processor has more memory than can be addressed by a 16-bit pointer. Thisis achieved though the use of a jump table which will automatically be generated by the compilerwhen large model is selected.3.4.10.3 Qualifiers and PointersPointers can be qualified like any other C objects, but care must be taken when doing so as thereare two quantities associated with pointers. The first is the actual pointer itself, which is treated likeany ordinary C variable and has memory reserved for it. The second is the object that the pointerreferences, or to which the pointer points. The general form of an initialized pointer definition lookslike the following.object’s_type_&_qualifiers * pointer’s_qualifiers pointer’s_name = value;The rule is as follows: if the modifier is to the left of the * in the pointer declaration, it applies tothe object which the pointer references. If the modifier is to the right of the *( next to the pointer’sname), it applies to the pointer variable itself. Any data variable qualifier may be applied to pointersin the above manner.38TUT•RIALHere are three examples of pointers, initialized with the address of the variables:const int ci = 0x55aa;int i;in which the definition fields are highlighted with spacing:

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

Saved successfully!

Ooh no, something went wrong!