This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/LAUNCHXL2-570LC43: How can i store a great deal of same type structures in the emif?

Part Number: LAUNCHXL2-570LC43
Other Parts Discussed in Thread: HALCOGEN,

Tool/software: Code Composer Studio

Good day, i have a problem and dont know how to solve it.

I have a structure.

struct TelemPackStruct
{
                 uint32_t tmMarker;
                 float32_t    wx ;
                 float32_t    wy ;
                 float32_t    wz ;
                 float32_t    m1 ;
                 float32_t    m2 ;
                 float32_t    m3 ;
                 float32_t    q0 ;
                 float32_t    q1 ;
                 float32_t    q2 ;
                 float32_t    q3 ;
     struct BinData{
                 uint32_t seconds            :32;
                 uint32_t indication         :8;
                 uint32_t mode               :8;
                 uint32_t modeArea            :8;
     }binDataTM;

};

I need to save this type of structure every second with different values in the emif.

I  enabled the emif in the Halcogen.

I modified the linker file :

MEMORY
{
    VECTORS (X)  : origin=0x00000000 length=0x00000020
    KERNEL  (RX) : origin=0x00000020 length=0x00008000 
    FLASH0  (RX) : origin=0x00008020 length=0x001F7FE0
    FLASH1  (RX) : origin=0x00200000 length=0x00200000
    STACKS  (RW) : origin=0x08000000 length=0x00000800
    KRAM    (RW) : origin=0x08000800 length=0x00000800
    RAM     (RW) : origin=(0x08000800+0x00000800) length=(0x0007F800 - 0x00000800)
/* USER CODE BEGIN (2) */ SDRAM (RXW) : origin=0x80000000 length=0x007FFFE0 /* USER CODE END */ }

and

SECTIONS
{
    .intvecs : {} > VECTORS
    /* FreeRTOS Kernel in protected region of Flash */
    .kernelTEXT  align(32) : {} > KERNEL
    .cinit       align(32) : {} > KERNEL
    .pinit       align(32) : {} > KERNEL
    /* Rest of code to user mode flash region */
    .text        align(32) : {} > FLASH0 | FLASH1
    .const       align(32) : {} > FLASH0 | FLASH1
    /* FreeRTOS Kernel data in protected region of RAM */
    .kernelBSS    : {} > KRAM
    .kernelHEAP   : {} > RAM
    .bss          : {} > RAM
    .data         : {} > RAM

/* USER CODE BEGIN (4) */
    .sysmem  : {} > SDRAM
/* USER CODE END */
}

i though i can handle this problem with this way:

    struct  TelemPackStruct  telemetryStruct __attribute__((section(".sysmem")));

    telemetryStruct.tmMarker= 0xf99ff99f;
    telemetryStruct.q0=1;
    telemetryStruct.q1=1;
    telemetryStruct.q2=1;
    telemetryStruct.q3=1;
    telemetryStruct.wx=1;
    telemetryStruct.wy=1;
    telemetryStruct.wz=1;
    telemetryStruct.m1=1;
    telemetryStruct.m2=1;
    telemetryStruct.m3=1;
    telemetryStruct.binDataTM.seconds=0;
    telemetryStruct.binDataTM.modeArea=0;
    telemetryStruct.binDataTM.mode=0;
    telemetryStruct.binDataTM.indication=0;

And then i wanted to create a pointer to a struct and make pointer++ to store next data.

but compiler says " attribute "section" does not apply to automatic variables" when i create i struct localy. its works only when i make telemetryStruct a global variable. but i suppose i wont be able to write a numerous data in the emif using this way.

Please help me to solve this problem.
EDIT 1:

When i tried to save changes to a global variable, changes didnt work, and in the memory map value at the adress is 0, but the value name is "emifed"

uint32_t emifed __attribute__((section(".sysmem")));
void (){
emifed = 2;
}

  • I don't think I can address all of your problems.  But I can address some of them.

    Roman Kosiy said:
    I  enabled the emif in the Halcogen.

    Please understand I have no expertise on Halcogen.  It could be that some of the recommendations I make don't work in combination with Halcogen.  

    Roman Kosiy said:
    SDRAM (RXW) : origin=0x80000000 length=0x007FFFE0

    I presume this memory range corresponds to what you call the EMIF.

    Roman Kosiy said:

    i though i can handle this problem with this way:

        struct  TelemPackStruct  telemetryStruct __attribute__((section(".sysmem")));
    

    You are on the right track.  However, do not use the section name ".sysmem".  That section name is used by the compiler for the memory heap managed by the RTS functions malloc, free, and so on.  Please choose a different section name.

    Roman Kosiy said:
    then i wanted to create a pointer to a struct and make pointer++ to store next data.

    This presumes you have arranged to have several structures all together in memory.  This is typically done by defining an array of structures.  I don't see where you do that.

    Roman Kosiy said:
    but compiler says " attribute "section" does not apply to automatic variables"

    Here is one good definition of automatic variables.  What's important here is that you cannot control the memory location of an automatic variable.

    Thanks and regards,

    -George

  • Thanks, i decided to do as you said. So what i dont undertand here is the folowing.

    Now i have

    #define NUM_OF_PACKS        1024
    
    struct TelemPackStruct
    {
                     uint32_t tmMarker;
                     float32_t    wx ;
                     float32_t    wy ;
                     float32_t    wz ;
                     float32_t    m1 ;
                     float32_t    m2 ;
                     float32_t    m3 ;
                     float32_t    q0 ;
                     float32_t    q1 ;
                     float32_t    q2 ;
                     float32_t    q3 ;
         struct BinData{
                     uint32_t seconds            :32;
                     uint32_t indication         :8;
                     uint32_t mode               :8;
                     uint32_t modeArea            :8;
         }binDataTM;
    };
    
    
    struct  TelemPackStruct  telemetry [NUM_OF_PACKS] __attribute__((section(".telem")));
    
    void foo()
    {
            telemetry[0].tmMarker=0xf99ff99f;
            telemetry[0].q0=1;
            telemetry[0].q1=1;
            telemetry[0].q2=1;
            telemetry[0].q3=1;
            telemetry[0].wx=1;
            telemetry[0].wy=0;
            telemetry[0].wz=0;
            telemetry[0].m1=0;
            telemetry[0].m2=0;
            telemetry[0].m3=0;
            telemetry[0].binDataTM.seconds=0;
            telemetry[0].binDataTM.modeArea=0;
            telemetry[0].binDataTM.mode=0;
            telemetry[0].binDataTM.indication=0;
    }

    Memory browser still shows that all telemetry[0] members equals 0 and all of the array members are placed in the emif adress. Everything works except of that. I even tried to make an array volatile, tried to assign volatile object to telemetry[0], tried assign through the pointers. its always empty.

    What am i doing wrong?

  • When during execution of the program do you call function foo?
  • Just a guess as I have never used the LAUNCHXL2-570LC43 or Halcogen. That board does not have any SDRAM built-in. Have you added a SDRAM board via the EMIF expansion connector?
  • Yes, now i enabled everything in Halcogen that turns on emif, and i suppose i solved a half of my problem. It writes to EMIF now... but it writes it strange.

    __attribute__((section(".telem"))) volatile  struct  TelemPackStruct  telemetry [NUM_OF_PACKS];
    
    void foo(){
        volatile struct TelemPackStruct tmToRead;
        //filling tmToRead
        telemetry[0]=tmToRead;
     
        //telemetry[0].q1=tmToRead.q1; does the same problem
    
    }

    It suppose to fill elemets telemetry[0] with tmToRead elements. But instead this fills ALL of the telemetry[NUM_OF_PACKS] and only with one variable.  What can this cause?

  • Roman Kosiy said:
    It suppose to fill elemets telemetry[0] with tmToRead elements. But instead this fills ALL of the telemetry[NUM_OF_PACKS] and only with one variable. 

    That is probably due to some error in configuring the hardware.  We in this compiler forum lack the expertise to help with that.  I recommend you start a new thread in the Hercules device forum.  Or, if you prefer, I can move this thread into that forum.

    Thanks and regards,

    -George