__eds__ WORD __ramspace[0x100] __attribute__((eds,address(0x8000ul),noload));
I want to understand the syntax above ( The program is for pic24 and in C ) especially __ramspace[0x100]
. Can anybody help me?
__eds__ WORD __ramspace[0x100] __attribute__((eds,address(0x8000ul),noload));
I want to understand the syntax above ( The program is for pic24 and in C ) especially __ramspace[0x100]
. Can anybody help me?
It's a bit late, but maybe this can help someone else:
__eds__ means you want to put whatever follows into the extended data space. You do this when you want to use the data space beyond a certain address. You can find from which address the extended space begins for your MCU in the datasheet.
WORD means you will reserve whole words (and not for instance bytes). For a pic24 this means 16 bit chunks.
__ramspace[0x100] is a 1D array 256 in size. When you take a look at what is written in front of this, you can see you are declaring an array named __ramspace , size 256 words (so 256x 16 bit values) in extended data space (eds).
Now you must declare the offset e.g. the start address of the array (the physical address where __ramspace[0] - first array element - will be). This is what 0x8000 does.
Finally you instruct the compiler if the array should be initialised at boot-up (for instance filled with zeros). In your case there is a noload, meaning random data will be inside the array at boot-up, until you write your own values in it.
Hope this helps.
__ramspace[0x100]
is the only part of that line which is just pure C. :) It declares an array of 0x100
(256, in decimal) elements of type WORD
. The name of the array is __ramspace
.
eds
.address(0x8000ul)
argument to __attribute__()
presumably makes the linker put the variable in question at location 0x8000
.The __eds__
qualifier is described in the "MPLAB® C Compiler for PIC24 MCUs and dsPIC® DSCs User’s Guide" as:
In the attribute context the eds, for extended data space, attribute indicates to the com- piler that the variable will may be allocated anywhere within data memory. Variables with this attribute will likely also need the eds type qualifier (see Chapter 6. “Additional C Pointer Types”) in order for the compiler to properly generate the correct access sequence. Note that the eds qualifier and the eds attribute are closely related, but not identical. On some devices, eds may need to be specified when allocating variables into certain memory spaces such as space(ymemory) or space(dma) as this memory may only exist in the extended data space.
__ramspace
is not a special designator, it's just the identifier that was chosen.