Absolute addressing for EEPROM variables in MC9S12

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

Absolute addressing for EEPROM variables in MC9S12

1,889 次查看
HenryL
Contributor III
I am using a cosmic compiler. EEPROM variable declared using @eeprom and are automatically allocated by the compiler. I want more control over what exact address within the eeprom space that a particular variable is to be allocated. Is this possible?
标签 (1)
0 项奖励
回复
1 回复

716 次查看
Pedro_
Contributor III
Hi Henry,
I believe that the best thing to do is to declare several eeprom sections and linking objects containing the eeprom variables in those sections. This will let you not only fine tune the .eeprom section but also use .feeprom section and any D-flash.
For example, imagine that you have partitioned your D-flash so 2 sectors are used as dflash and the rest as EEE.
Your linker script could be:
 
+seg .feeprom -ds10 -b0x100000 -o0x800 -m0x100 -n.dflash1  # 1 block of dflash
dflash1.obj
+seg .feeprom -ds10 -b0x100100 -o0x900 -m0x100 -n.dflash2  # 1 block of dflash
dflash2.obj
 
+seg .feeprom -ds10 -b0x13F800 -o0x800 -m0x400 -n.fareee   # 1k of paged eee
fareee.obj
 
+seg .eeprom -b0x13FC00 -o0xC00 -m0x300 .nneareee1 # 0.75k non paged eee
data1.obj
+seg .eeprom -b0x13FF00 -o0xF00 -m0x100 .nnearee2   # 0.25k non paged eee
data2.obj
 
Attention should be paid to the correspondance of the -b global address and the -o for Local address.
The -m is very useful to detect when you are going out of boundary with the segments. (have a read to the linker document to understand better)
 
Your object files should contain the Only eeprom data structures. For example
- Paged :
dflash1.c
 @far @eeprom myVar
 
- Non paged
data1.c
 @eeprom myOtherVar
 
I hope it helps
Pedro
 
 

 

0 项奖励
回复