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?
Solved! Go to Solution.
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!
-----------------------------------------------------------------------------------------------------------------------
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!
-----------------------------------------------------------------------------------------------------------------------