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.

MSPM0C1104: Reading data from a specific memory location using __attribute__((section(".")));

Part Number: MSPM0C1104


Tool/software:

Hi Team,

I am just trying to read data  form a specific memory location using this API unsigned int var __attribute__((section(".test"))); . I am following these steps, but I am unable to read the data. Could you please anyone help me regarding this ASAP.

Step 1: device_linker.cmd

Step 2: device_linker.cmd

Step 3: startup_file

Step 4:main.c

Step 5: Memory browser

  • Hello santhosh,

    If you enter into debug mode and set a breakpoint, you will find that the var has been changed to 0x7

    But the code __asm( "  .global _c_int00 \n  "b  c_int00"); will initialize the variables and then jump to main function. I give an initial value of var in my code such as 0x3800, so when you continue to step in debug mode and set breakpoint, you will find the var are set to the initial value

    So maybe you need to choose another method to achieve your purpose.

    Best Regards,

    Janz Bai

  • Hi Janz,

    Thank you so much for the reply,

    How to do read a data from a specific memory using #pragma, Could you please help me with this

  • Hello santhosh,

    If you want to read the data from a specific memory such as Flash or SRAM, you can refer to the method mentioned in this figure. You can directly use a pointer to implement your purpose.

    Best Regards,

    Janz Bai

  • Hi Janz,

    if I want to achieve through #pragma it is possible. Could you please help me how to implement it

  • Hello Santhosh, 

    I don't recommend you using the #pragma SET_DATA_SECTION because when I use it in CCS and I got this warning: 

     We recommend to use the unsigned int var __attribute__((section(".test"))).

    And I don't why the method of using pointer can't achieve your purpose that reading a data from a specific memory. It seems that you want to configurate a specific address for a variable, don't let compiler configurate an address automatically. Can you tell me what's your core purpose or core requirement?

    Best Regards,

    Janz Bai

  • Hello Janz,

    Sorry for late reply, thank you so much for the reply

    If I want to access the stack's start and end, how do I do that?

    My requirement is to store some values between the stack's start and end locations. The values should be permanent. What should I do?

  • Hello Santhosh,

    1). Stack is a part of SARM which is the bottom of SRAM. If you want to store data in stack directly, you can try to use the pointer which I have mentioned before.

    2). But why you want to store a permanent value in stack directly? Stack is used to store the data such as local variables and return addresses, etc. If you store an unrelated data, it may affect the usage of stack.

    3). Why don't you choose another region of SRAM to store the data?

    Best Regards,

    Janz Bai