07.04.2013 Views

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

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.

Additional C Pointer Types<br />

} else {<br />

fprintf(stderr,"I don't know how to access memory space: %d\n",<br />

memory_space);<br />

}<br />

}<br />

These functions work in a similar fashion:<br />

• if accessing bit_memory, then<br />

- determine the correct byte offset <strong>and</strong> bit offset<br />

- read or write the appropriate place in the real_bit_memory<br />

• otherwise access another memory (whose access is unknown)<br />

With the two major pieces of the puzzle in place, generate some variables <strong>and</strong><br />

accesses:<br />

__external__ unsigned char bits[NUMBER_OF_BITS]<br />

__attribute__((space(external(bit_memory))));<br />

// inside main<br />

__external__ unsigned char *bit;<br />

bit = bits;<br />

<strong>for</strong> (i = 0; i < 512; i++) {<br />

printf("%d ",*bit++);<br />

}<br />

Apart from the __external__ CV-qualifiers, ordinary C statements can be used to<br />

define <strong>and</strong> access variables in the external memory space.<br />

© 2008 <strong>Microchip</strong> Technology Inc. DS51284H-page 89

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

Saved successfully!

Ooh no, something went wrong!