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