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.

C280x cmd file - const definition in RAM

Other Parts Discussed in Thread: TMS320F2806

MEMORY
{
    PAGE 1:
        nodeIdAddress : origin = 0x3d8000, length = 0x000001
}

SECTIONS
{
    nodeIdAddress :> nodeIdAddress    PAGE = 1
}


variable definition in .c file
#pragma DATA_SECTION("nodeIdAddress")
const volatile uint16 nodeId = 121;

  • Hi,

    Are you confirming the above implementation? Do check:

    Regards,

    Gautam

  • Here are some details. The MCU I used is TMS320F2806, and I user '#define' to define a constant previously. But my colleague requires to define this value in RAM, something like the method mentioned above. His word is "the nodeId shall be a constant linked at specific data address section used only for its own, like this we can change it during the internal flash programming. ", but I am not sure about it.

    Actually I tested 2 method:

    1. Define like the method mentioned above, it works with emulator, but the value changed without emulator. As I doubted, the value might not be fixed even if defined as 'const volatile' in RAM, but I am not sure. That is the reason I want to check with expert.
    2. Define the value in RAM, and assign value during initialization process. It works well with or without emulator. But I do not think it has advantage comparing to method of '#define). The method is listed below.

     

    1.    f2806.cmd

     

    MEMORY

    {

    PAGE 0:    /* Program Memory */

               /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */

     

       nodeIdAddr  : origin = 0x008000, length = 0x000002

       RAML0       : origin = 0x008002, length = 0x00FFFE     /* on-chip RAM block L0 */

     }

     

    /* Allocate sections to memory blocks.

       Note:

             codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code

                       execution when booting to flash

             ramfuncs  user defined section to store functions that will be copied from Flash into RAM

    */

     

    SECTIONS

    {

       /* Allocate uninitalized data sections: */

       nodeIdFile          : > nodeIdAddr   PAGE = 0

    }

     2.    Variable Definition

    #pragma DATA_SECTION(ID_BOARD, "nodeIdFile")

    volatile uint32 ID_BOARD;

     3.    Reference definition

    extern volatile uint32 ID_BOARD;

     4.    Initiialization

           ID_BOARD = 100000UL;