EEPROM Varible declarations

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

EEPROM Varible declarations

2,244 次查看
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 回复数

612 次查看
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 项奖励

612 次查看
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 项奖励

612 次查看
Kantha
Contributor I
Hi,
I am using MC9S12DB128 and cosmic compiler
 
Regards,
Kantha
0 项奖励

612 次查看
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 项奖励