EEPROM Varible declarations

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

EEPROM Varible declarations

2,248件の閲覧回数
Kantha
Contributor I
Hi,
How to declare variable to the specific eeprom address and initialize to specific value at the same time
 
Regards,
Kantha
 
ラベル(1)
0 件の賞賛
4 返答(返信)

616件の閲覧回数
Zeke
Contributor I
There are two ways may do this.

1.
a)declare a EEPROM point

@eeprom U8(or U16) *eeptr;

b)give a address to point

eeptr = (void*)0x880;

c)give point a value

*eeptr = 123;

2.
a) allocate a section at *.lkf file

+seg .eeprom -b0x0880 -m0x10 -n.eevalue

b) use #pragma

#pragma section @eeprom {eevalue}
@eeprom U8 EEmember1 = 0x80;
.....
.....
#pragma section {}


I hope these ways can help you.

Message Edited by Zeke on 2007-02-1401:33 AM

0 件の賞賛

616件の閲覧回数
Lundin
Senior Contributor IV
Assuming that you are using Codewarrior C compiler. Might be wise to post such info.

Make a read only segment in the .prm file at the address where you want the variable(s).

Then put your variables inside
#pragma CONST_SEG SEGMENT_NAME

And declare variables as global and constant. Set the init values as usual for constants in C.

Depending on MCU, there might be lots of other things to concider as well.
Might be wise to post which MCU you are using.
0 件の賞賛

616件の閲覧回数
Kantha
Contributor I
Hi,
I am using MC9S12DB128 and cosmic compiler
 
Regards,
Kantha
0 件の賞賛

616件の閲覧回数
Lundin
Senior Contributor IV
Ok, no idea in that case.

As a sidenote, make sure to setup INITEE if you wish to use the whole eeprom, since it is located at address 0 out of reset, and therefore half-way hidden behind the cpu registers in the memory map.
0 件の賞賛