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.

Using the const qualifier on a variable stored in the CPU-to-CLA message RAM

Hello,

In my memory map I declared the following area: 

PAGE 1:
CPU_CLA_MSGRAM : origin = 0x001500, length = 0x000080

And I assigned it the following sections:

CpuToCla1MsgRAM		: > CPU_CLA_MSGRAM,		PAGE = 1
CpuToCla1Const		: > CPU_CLA_MSGRAM,		PAGE = 1

Then in my program I put a const structure in the CpuToCla1Const section:

#pragma SET_DATA_SECTION("CpuToCla1Const")
volatile struct THRESHOLD const Threshold = {622, 3404};

My idea was to have the C runtime copy the initial values from the .cinit section to the CPU-to-CLA data RAM so I wouldn't need to do it manually.

This works fine when I'm testing it but whenever I try to start the board without any JTAG the thresholds are initialized to incorrect values. What's wrong with this approach?

Regards,

Pierre

  • By the way I've noticed section 6.5.1 of the Optimizing C Compiler user manual:

    Global objects qualified as const are placed in the .const section. The linker allocates the .const section
    from ROM or FLASH, which are typically more plentiful than RAM. The const data storage allocation rule
    has two exceptions:
    • If the keyword volatile is also specified in the definition of an object (for example, volatile const int x).
    Volatile keywords are assumed to be allocated to RAM. (The program is not allowed to modify a const
    volatile object, but something external to the program might.)
    • If the object has automatic storage (function scope).
    In both cases, the storage for the object is the same as if the const keyword were not used.


    According to this, the structure as defined in my previous message should end up in the .ebss section, right?

  • I ended up removing the const qualifier.

    I still wonder if it would be possible to have the compiler generate a .cinit entry for my volatile const structure and initialize it at runtime.

    Cheers,

    Pierre

  • Pierre,

    The CLA is a slave and having a cinit code is something that need to automatically run on boot sequence, at which time CLA is not even configured. Hence having cinit for CLA is not possible for variables in CLA writable memory.

    However if you can use CLAData RAM then if you declare variables on the C28x side to be in the CLAdata RAM they should get initialized with cinit..

  • Manish,

    I understand how the CLA works, and by the way I'm coding my CLA tasks in assembly, using a .cdecls directive to access symbols defined on the C2000 side.

    I use the CLA message RAM and I do declare the variables on the C28x side to be in the CLA message RAM. So I expected them to get initialized by _c_int00. They don't seem to be though, but if I understand correctly it's supposed to be like this with the "volatile const" qualifiers (see my quote of the documentation above).

    Regards,

    Pierre

  • Oh! you are right.. 

    sorry for the blabber..