Well, we are here in C and the address of an array is best expressed with the array-name
now the address is
both may be type-casted as for instance
(char *) buffer
That doesn't work because I will be just changing where the pointer points. I want to change where it's allocated in memory.
I want to specify where the memory set aside for my array starts. So the RealView and Keil seem to solve the problem, but I'm using PSoC 5, which uses the GNU GCC compiler, right? The GCC example assumes that the data already exists at a specific position in memory.
One approach, not being GNU knowlegeable, is the equivalent of an AREA command,
where you set aside an area of memory, then are free to allocate whatever ande wherever
in that area. Or alternatively malloc ?
Bob may have more insight into this.
I already read that info before, but the problem is that the way they're explaining it is to allocate memory in flash and I need to allocate it in SRAM. The linker command doesn't allow me to specify the 32 bit address in order to locate in SRAM. Actually I need my array to start at the address 0x1FFFC000.
My problem could be solved if someone can help me to make my own linker section! That way I could use the section attribute.
You may use simple pointers. To make life (typing and reading) easier use the "typedef" declaration.
typedef uint8 MyMemory;
MyMemory *Array1 = (void*)0x1FFFC000;
Later on in the program you may change the base-address
Array1 = (void*) 0xDeadBeef;
To access an element in Array1 you simply write
*Array1 = 27;
you wrote "That doesn't work because I will be just changing where the pointer points."
That's exactly how pointers work, If you just change the address on a letter, the envelope and its contents will go to a completely different location.
Setting up DMA requires the addresses of the source and destination which are pointers as well, so when you change one of them, you'll have to set up DMA anew.
The methodssuggested are to read and write to the address.
I think your question is how to allocate/reserved the array in the RAM address you want. it to be? Is this corret?
LLeung that is exactly what I'm asking... I need to allocate a variable (array) in a specific desired address (the reason is due to DMA and CPU priorities in certain memory areas). I'm not asking how to read or write to a certain address; I want to declare an array, and I want the compiler to reserve a specific space for it in memory, starting at my desired address. I want to decide where that array is going to be allocated. This needs to be done at compilation time, not when the program is already running.
The link you posted is only useful to allocate my array from 0x00000000 to 0x0000FFFF (mainly flash I think), for some reason the Linker fails after that range, or more specifically the cyhextool when I try to compile it (alternative methods like writing the number in decimal or binary just result in the linking process to be endless), I need to allocate my array (several kb) in 0x1FFFC000 (starting at that address).
As I already mentioned: ARM says exactly:
"With the GNU GCC Compiler you may use only pointer definitions to access absolute memory locations. "
Look here for more Infos: http://www.keil.com/support/docs/2829.htm
To my understanding.
missa wants to "ALLOCATE AN ARRAY AT RAM ADDRESS 0X1FFFC000". missa has no problem reading or writing to/from this array.
Why you need to have it at a fix address? why not declare the array inside your program and let the compiler assign it for you.
It's not necessary to have array in fix memory location to use the DMA. The address of the array for the DMA can be handle by the compiler and resolve during compile time.
The fix address of the PSOC HW are handling by the macro defines of the creator.
The other reason I think people needs that is the memory (most likely external memory) is shared with another processor. So the address must be fixed in order to pass the data around. Is this your issue?
have you tried using -defsym?