EEPROM Varible declarations

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

EEPROM Varible declarations

2,536 Views
Kantha
Contributor I
Hi,
How to declare variable to the specific eeprom address and initialize to specific value at the same time
 
Regards,
Kantha
 
Labels (1)
0 Kudos
Reply
4 Replies

904 Views
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 Kudos
Reply

904 Views
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 Kudos
Reply

904 Views
Kantha
Contributor I
Hi,
I am using MC9S12DB128 and cosmic compiler
 
Regards,
Kantha
0 Kudos
Reply

904 Views
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 Kudos
Reply