Microchip
直播中

王树林

7年用户 1666经验值
私信 关注
[问答]

如何将数据结构加载到HEF中?

在我的程序中,我有一个保存配置值的结构。我需要一些方法来控制这个结构放在哪里,就像现在编译器决定放在哪里一样。然后,我想把这个结构读入ram,改变一些值,然后写回去。也许非常相似……我还想把变量指向0x000—0x01FF区域中的某个位置。我使用该区域作为引导加载程序,我希望运行的程序知道引导加载程序的版本。这个引导加载程序是用ASM制作的,所以我知道值在哪里。我可以从FLASH读出来,这很管用。但是最好能定义一个指向这个值的变量。我想把它用作:uint8_t BootoaderVersion;有没有办法让编译器知道在哪里(0x01f0)查找这个值?我对XC8编译器很陌生,所以我正在为一些事情而奋斗。有什么好的参考资料吗?

以上来自于百度翻译


      以下为原文

    In my program i have a structure that holds configuration values.
i use 'const MyConfig Config;'
The MyConfig is a structure with 64 bytes of data which i want to put in the HEF using the HEX file that is created by the compiler. I need some way of controlling where this structure is placed as now it is just wherever the compiler decides to.
Afterwards i want to read this structure into ram, change some values and write it back.

Maybe very similar... i also want to point a variable to a location somewhere in the 0x0000-0x01ff area. I use that area for a bootloader and i would like the running program to know the version of the bootloader. This bootloader is made with ASM so i know exactly where the value is. I could read it from flash, and that works. But it would be nicer to be able to define a variable that points to this value.
I would like to use it as:
uint8_t BootoaderVersion;
Is there a way to let the compiler know where (0x01f0) to look for this value?

I am pretty new to the XC8 compiler so i am struggling with some things. Is there a good reference somewhere available?

回帖(2)

陈晨

2019-7-11 10:11:37
你可以用这个方法把你的数据放在HEF中。确保你的数据是航空页大小的倍数,这样编译器就不会把数据和你的数据一起放进去。如果您只想读取ITUTIN Tyt const *ByTeToCult;ByTePosie= 0x01F0;修正的附加const

以上来自于百度翻译


      以下为原文

    const uint8_t BootoaderVersion @ 0x01F0
You can use this method to put you data in HEF. Make sure you your data is in multiples of the airways page size so that the compiler doesn't put data with yours.
If you just want to read it
uint_t const *bytePointer;
bytePointer = 0x01F0;

Corrected added const
举报

陈鲜孰

2019-7-11 10:29:16
用户引导部分5.5.4绝对变量。后缀定义为@ AddiSsCistMyCONFIG CONFIG @ 0x1F80= {…在PIC10/12/16上,编译器希望所有的const变量都在Flash中,并由ReTLW表组成。所以你的版本号必须存储为一个RILLW。如果不是,它会在访问时崩溃。

以上来自于百度翻译


      以下为原文

    User Guide section 5.5.4 Absolute Variables.
Postfix the definition with @ address
 
const MyConfig Config @ 0x1F80 = { .... };
On PIC10/12/16, the compiler expects all const variables to be in FLASH and to consist of a RETLW table. so your version number must be stored as a RETLW. If it isn't it will crash when accessed.
 
举报

更多回帖

发帖
×
20
完善资料,
赚取积分