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/MSP430FR5989:引用链接器文件中的内存段起始地址和长度

Guru**** 2250060 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/tools/code-composer-studio-group/ccs/f/code-composer-studio-forum/575281/ccs-msp430fr5989-referencing-memory-section-start-address-and-length-from-linker-file

部件号:MSP430FR5989

工具/软件:Code Composer Studio

大家好,

我正在尝试找出在代码中引用链接器文件中定义的内存段的起始地址和长度的最佳方法。  

我已经找到了一种方法来完成这项工作,但这似乎有点古怪,我想知道是否有一种更干净的方法来完成这项工作。

例如,我的链接程序文件中将包含以下内容:

#define test_address_LOC				0x1.5万
#define test_address_LEN				0x1000

test_address							= test_address_LOC;

内存
{
test_section: origin = test_address_LOC,length = test_address_LEN
}

sections
{
.testSection		:{}> test_section type=NOINIT
} 

然后在代码中定义  

extern volatile unsigned long test_address;

并使用test_address作为源站指针(与编译器映射注册地址的方式非常相似)。

虽然这项工作已经完成,但有没有一种更干净的方法可以在不需要使用变量的情况下执行此操作(在这种情况下,我只需访问节的起始地址和长度,而无需在链接程序文件的两个位置定义它), 或者,我是否可以将test_address的值分配给test_section的来源?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    以下内容可能会让您有一个想法:
    e2e.ti.com/.../39.4636万
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    这怎么样?  请将这些行...

    Christopher Carl 说:
    #define test_address_LOC 0x1.5万
    #define test_address_LEN 0x1000

    头文件中的...。  #在C代码和链接程序命令文件中都包含该标题。  然后更改...

    extern volatile unsigned long test_address;

    像这样的东西...

    volatile unsigned long *特殊指针= test_address_loc; 

    那么您不需要变量test_address。

    更改主题。  这是一件小事,但我想我要指出一下。  这...

    Christopher Carl 说:
    测试部分:Origin = test_address_LOC,length = test_address_LEN

    ...不是一个部分,而是一个记忆范围。  因此,如果您使用名称test_memory_range而不是test_section.

    谢谢,此致,

    -George