Hi to you all,I'm using an LPC4370 (in a link2 probe) to output the data acquired @ 40 MSPS using the USB CDC VCOM driver included in the LPCOPEN Libraries. I can output an array of uint32_t elements and read it properly in Matlab at the host side.Unfortunately though I'm having troubles with arrays declared as follows: I read some strange numbers, not the ones I stored into the array.
__DATA(RAM3) static uint32_t multiChannel[BINS];
Since the application I'm working on has some real time requirements I need to keep the array allocated into RAM and not in flash.To output the array right now I'm passing it to the write method of the driver using a cast to uint8_t and specifying the array length, like:
write(uint8_t*)multiChannel, sizeof(multiChannel));
Why do you think w/o __DATA(RAM3) the array is in Flash? It is a normal variable, so it will be placed in RAM. Check your linker script (scatter loading file) w/ and w/o the __DATA() attribute.Maybe you do not have a section RAM3 in your linker-script?
HI 42Bastian Schick, thanks for the reply.As pointed out in this question I asked a while ago, the LPC4370 (the micro I'm working on) can execute code from SPIFI, and that's why I need to specify that I want it to be executed from RAM.I checked the memory.ld script, and as you can see RAM3 is correctly defined as alias fro RamAHB32.
MEMORY { /* Define each memory region */ RamLoc128 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x20000 /* 128K bytes (alias RAM) */ RamLoc72 (rwx) : ORIGIN = 0x10080000, LENGTH = 0x12000 /* 72K bytes (alias RAM2) */ RamAHB32 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 /* 32K bytes (alias RAM3) */ RamAHB16 (rwx) : ORIGIN = 0x20008000, LENGTH = 0x4000 /* 16K bytes (alias RAM4) */ RamAHB_ETB16 (rwx) : ORIGIN = 0x2000c000, LENGTH = 0x4000 /* 16K bytes (alias RAM5) */ RamM0Sub16 (rwx) : ORIGIN = 0x18000000, LENGTH = 0x4000 /* 16K bytes (alias RAM6) */ RamM0Sub2 (rwx) : ORIGIN = 0x18004000, LENGTH = 0x800 /* 2K bytes (alias RAM7) */ SPIFI (rx) : ORIGIN = 0x14000000, LENGTH = 0x100000 /* 1M bytes (alias Flash) */ } /* Define a symbol for the top of each memory region */ __base_RamLoc128 = 0x10000000 ; /* RamLoc128 */ __base_RAM = 0x10000000 ; /* RAM */ __top_RamLoc128 = 0x10000000 + 0x20000 ; /* 128K bytes */ __top_RAM = 0x10000000 + 0x20000 ; /* 128K bytes */ __base_RamLoc72 = 0x10080000 ; /* RamLoc72 */ __base_RAM2 = 0x10080000 ; /* RAM2 */ __top_RamLoc72 = 0x10080000 + 0x12000 ; /* 72K bytes */ __top_RAM2 = 0x10080000 + 0x12000 ; /* 72K bytes */ __base_RamAHB32 = 0x20000000 ; /* RamAHB32 */ __base_RAM3 = 0x20000000 ; /* RAM3 */ __top_RamAHB32 = 0x20000000 + 0x8000 ; /* 32K bytes */ __top_RAM3 = 0x20000000 + 0x8000 ; /* 32K bytes */ __base_RamAHB16 = 0x20008000 ; /* RamAHB16 */ __base_RAM4 = 0x20008000 ; /* RAM4 */ __top_RamAHB16 = 0x20008000 + 0x4000 ; /* 16K bytes */ __top_RAM4 = 0x20008000 + 0x4000 ; /* 16K bytes */ __base_RamAHB_ETB16 = 0x2000c000 ; /* RamAHB_ETB16 */ __base_RAM5 = 0x2000c000 ; /* RAM5 */ __top_RamAHB_ETB16 = 0x2000c000 + 0x4000 ; /* 16K bytes */ __top_RAM5 = 0x2000c000 + 0x4000 ; /* 16K bytes */ __base_RamM0Sub16 = 0x18000000 ; /* RamM0Sub16 */ __base_RAM6 = 0x18000000 ; /* RAM6 */ __top_RamM0Sub16 = 0x18000000 + 0x4000 ; /* 16K bytes */ __top_RAM6 = 0x18000000 + 0x4000 ; /* 16K bytes */ __base_RamM0Sub2 = 0x18004000 ; /* RamM0Sub2 */ __base_RAM7 = 0x18004000 ; /* RAM7 */ __top_RamM0Sub2 = 0x18004000 + 0x800 ; /* 2K bytes */ __top_RAM7 = 0x18004000 + 0x800 ; /* 2K bytes */ __base_SPIFI = 0x14000000 ; /* SPIFI */ __base_Flash = 0x14000000 ; /* Flash */ __top_SPIFI = 0x14000000 + 0x100000 ; /* 1M bytes */ __top_Flash = 0x14000000 + 0x100000 ; /* 1M bytes */
And here what the IDE says
What do you think about this? To me it seems that everything about the memory map is fine, but maybe I'm missing something since its the first time I try to dig deep in the memory mapping system!
Wow, this is a strange memory splitting. Anyway, check the map file to see where the array is placed w/o section specifier.
BTW: Where did you get this memory.ld from?
I'm sorry, I know this could be a dumb question, but actually its the first time I dive into linker scripts.. Where is the file you mean supposed to be? I found the .ld one in my Project/Debug directory. Actually 3 files have the .ld extension but no one explicitly mentions the arrays I'm declaring. I'll attach my files to this answer! Thank 42Bastian Schick for the support.2867.myproj_Debug.txt
3225.myproj_Debug_memory.txt
5582.myproj_Debug_library.txt
Wow, those linker-scripts are overly complicated (tool output :( ).Anyway, I see no difference between declaring the array w/ or w/o __DATA(RAM3). In both cases it is placed in RAM.Did you check if it is filled correctly before sending out?
Hi 42Bastian Schick, yesterday I figured it out.I had a problem because my project has a lot of critical data sections which I put in different RAM slots. The RAM3 (which I was trying to use) had already other variables and therefore some interference during read cycles occurred and my data were constantly corrupted... I don't even know why this should happen, not to mention that it actually started after implementing the USB driver for LPCOpen. Re-ordinating everything (now I use 4 RAM sections out of 7 available), solved the issue. It wuould be really interesting to dig more into the thing and fully understand what happened here..