This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CORTEX M4 - Output an array declared with __DATA(RAM) attribute?

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));


Any help in solving this would be highly appreciated... Of course I'm missing something about the attribute __DATA().

Thanks in advance,
Andrea

Parents
  • HI , 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!

Reply
  • HI , 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!

Children