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.

C Language FeaturesSupported Data Types and Variables3.4.9 Special Type QualifiersHI-TECH <strong>dsPIC</strong>Csupports the special type qualifiers to allow the user to control placement ofstatic and extern class variables into particular address spaces.3.4.9.1 Persistent Type QualifierBy default, any C variables that are not explicitly initialised are cleared to zero on startup. This isconsistent with the definition of the C language. However, there are occasions where it is desired forsome data to be preserved across resets or even power cycles (on-off-on).The persistent type qualifier is used to qualify variables that should not be cleared on startup.In addition, any persistent variables will be stored in a different area of memory to other variables.persistent objects are placed within the psect nvram.This type qualifier may not be used on variables of class auto; if used on variables local to afunction they must be combined with the static keyword. For example, you may not write:void test(void){persistent int intvar; /* WRONG! */.. other code ..}because intvar is of class auto. To declare intvar as a persistent variable local to functiontest(), write:static persistent int intvar;If the DSPICC option, --STRICT is used, this type qualifier is changed to __persistent.There are some library routines provided to check and initialise persistent data - see A formore information, and for an example of using persistent data.3.4.9.2 YData Type QualifierThe <strong>dsPIC</strong> memory map for RAM is divided into two parts: x-data and y-data. Some <strong>dsPIC</strong> instructioncan only operate will addresses to object in the y-data range. Qualifying an object as ydatacause the object to be placed into the ranges of memory designated for ydata.3.4.10 Pointer TypesThere are two basic pointer types supported by HI-TECH C: data pointers and function pointers.Data pointers hold the address of data objects which can be indirectly read and possibly written by37

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

Saved successfully!

Ooh no, something went wrong!