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.

Storage Class and Object PlacementC Language Featuresnecessarily be allocated in the order declared - in contrast to parameters which are always in lexicalorder.Note that most type qualifiers cannot be used with auto variables, since there is no control overthe storage location. The exceptions are const and volatile.3.5.1.2 Static VariablesUninitialized static variables are by default allocated in the bss psect (located in XDATA memory)unless they have also been qualified as ydata which will instead use the ybss psect (located inYDATA memory). static variables are local in scope to the function in which they are declared,but may be accessed by other functions via pointers since they have permanent duration. staticvariables are guaranteed to retain their value between calls to a function, unless explicitly modifiedvia a pointer.static variables which are initialised are only done so once during the program’s execution.Thus, they may be preferable over initialised auto objects which are assigned a value every time theblock in which the definition is placed is executed.3.5.2 X and Y DATA VariablesThe <strong>dsPIC</strong> memory map is divided into X and Y data areas. Some dsp instructions can only operateon objects stored in ydata. For this reason the ydata qualifier is provided to position an object intoydata memory. Only static and global variables may use this qualifier. If no qualifier is given, alocation in xdata memory will be assumed.3.5.3 Absolute VariablesA global or static variable can be located at an absolute address by following its declaration withthe construct @ address, for example:volatile unsigned char Portvar @ 0x06;will declare a variable called Portvar located at 06h. Note that the compiler does not reserveany storage, but merely equates the variable to that address, the compiler-generated assembler willinclude a line of the form:_Portvar EQU 06hThis construct is primarily intended for equating the address of a C identifier with a microprocessorspecial funciton register. To place a user-defined variable at an absolute address, define it in aseparate psect and instruct the linker to place this psect at the required address as specified in Section3.12.3.5.40

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

Saved successfully!

Ooh no, something went wrong!