@modifier for addressing

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

@modifier for addressing

跳至解决方案
949 次查看
rahulkrishna
Contributor IV

i have question about absolute addressing using @

For example if i write a code with some address 0xE08456. I am assuming ppage = 0xE0 and local address 0x8456.

const data@0xE08456 = 10; Now my doubt is how compiler knows that the address 0xE08456 is logical address and not global address. Also the controller gives 16 bits then how it incorporates the address 0xE08456 which is more than 16 bits. Is it the correct way of declaring?

标签 (1)
1 解答
884 次查看
RadekS
NXP Employee
NXP Employee

Hi rahul,

Unfortunately, I didn’t found a way how to convince linker for accepting global addresses by @ modifier yet.

So, I suppose that the linker expects only logical addresses.

However placing by global addresses is still possible and we could use #pragmas.

I used S12XEP100 and modified prm file:

1.    I rewrote addresses to global format. For example:

PAGE_C0      = READ_ONLY  DATA_FAR IBCC_FAR  0x700000'G TO 0x703FFF'G;

2.    I commented out PAGE_C0 from DEFAULT_ROM. For example:

DEFAULT_ROM      INTO          PAGE_FE,  … , PAGE_C1; //, PAGE_C0;

3.    I created user segment. For example:

MY_GLOBAL_FLASH  INTO  PAGE_C0;

4.    I do not reference my constant, therefore, I placed their name into entries. For example:

ENTRIES /* keep the following unreferenced variables */

  my_const

END

I defined my constant in main.c file:

#pragma CONST_SEG MY_GLOBAL_FLASH

volatile const unsigned char my_const = 0xAA;

#pragma CONST_SEG DEFAULT

Note: Since we used global addresses, we are not limited by pages and this approach could be simply used for variables/constants which are bigger than the single page size.

Note: we could additionally use pragma modifiers for driving access to constant/variables in our user segment. For example:

#pragma CONST_SEG  __GPAGE_SEG  MY_GLOBAL_FLASH


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

1 回复
885 次查看
RadekS
NXP Employee
NXP Employee

Hi rahul,

Unfortunately, I didn’t found a way how to convince linker for accepting global addresses by @ modifier yet.

So, I suppose that the linker expects only logical addresses.

However placing by global addresses is still possible and we could use #pragmas.

I used S12XEP100 and modified prm file:

1.    I rewrote addresses to global format. For example:

PAGE_C0      = READ_ONLY  DATA_FAR IBCC_FAR  0x700000'G TO 0x703FFF'G;

2.    I commented out PAGE_C0 from DEFAULT_ROM. For example:

DEFAULT_ROM      INTO          PAGE_FE,  … , PAGE_C1; //, PAGE_C0;

3.    I created user segment. For example:

MY_GLOBAL_FLASH  INTO  PAGE_C0;

4.    I do not reference my constant, therefore, I placed their name into entries. For example:

ENTRIES /* keep the following unreferenced variables */

  my_const

END

I defined my constant in main.c file:

#pragma CONST_SEG MY_GLOBAL_FLASH

volatile const unsigned char my_const = 0xAA;

#pragma CONST_SEG DEFAULT

Note: Since we used global addresses, we are not limited by pages and this approach could be simply used for variables/constants which are bigger than the single page size.

Note: we could additionally use pragma modifiers for driving access to constant/variables in our user segment. For example:

#pragma CONST_SEG  __GPAGE_SEG  MY_GLOBAL_FLASH


I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------