EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Writing to EEPROM: Basics needed

Started by Roth Markus October 14, 2004
Gents

For a certain application it would be nice if I could write to the EEPROM at
run time. I have never been writing to the EEPROM, so my knowledge for this
special feature is zero.

What I am looking for is a short briefing on what I need to do that. E.g.
are there functions in C available for writing to the EEPROM? I don't think
it is so easy as some ATMEL uC do it: Direct writing to the EEPROM in almost
the same way you use RAM.

I have to know how much work this makes to be able to make a decision on how
we continue. Thanks, Markus




Hi Markus,

It's all in the Motorola application notes and datasheets. With
the 9S12 family just remember that the EEROM (which is really a
Sectored flash) needs to be written to on 16 bit boundaries. (Or
was it 32?) Can't remember off the top of my head. It means if
you want to change a byte you have to read the entire sector,
modify the individual byte and then write the sector back.

But for reading. You can use pointers. Eg. Var = *ptr; where
ptr points to EEROM.

John Dammeyer
Wireless CAN with the CANRF module now available.
http://www.autoartisans.com/products
Automation Artisans Inc.
Ph. 1 250 544 4950 > -----Original Message-----
> From: Roth Markus [mailto:]

> Sent: Wednesday, October 13, 2004 11:41 PM
> To: '
> Subject: [68HC12] Writing to EEPROM: Basics needed >
> Gents
>
> For a certain application it would be nice if I could write
> to the EEPROM at run time. I have never been writing to the
> EEPROM, so my knowledge for this special feature is zero.
>
> What I am looking for is a short briefing on what I need to
> do that. E.g. are there functions in C available for writing
> to the EEPROM? I don't think it is so easy as some ATMEL uC
> do it: Direct writing to the EEPROM in almost the same way
> you use RAM.
>
> I have to know how much work this makes to be able to make a
> decision on how we continue. > Thanks, Markus > ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> $9.95 domain names from Yahoo!. Register anything.
> http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/dN_tlB/TM
> --------------------------
> ------~- > Yahoo! Groups Links >
>




Hallo Markus,

for the 912DG128A I wrote EEPROM routine in C. I don't know which HC12 you use, so I don't know if my routine works for you.
If you want, I can send you my routine offline.

--
Patrick Gempeler <>
ProEda AG Datenmanagement <http://www.proeda.ch/>
Bollstr. 32, CH-3076 Worb
Tel +41 31 838 45 00, Fax +41 31 838 45 40
----- Original Message -----
From: Roth Markus
To: '
Sent: Thursday, October 14, 2004 8:41 AM
Subject: *****SPAM***** [68HC12] Writing to EEPROM: Basics needed Gents

For a certain application it would be nice if I could write to the EEPROM at
run time. I have never been writing to the EEPROM, so my knowledge for this
special feature is zero.

What I am looking for is a short briefing on what I need to do that. E.g.
are there functions in C available for writing to the EEPROM? I don't think
it is so easy as some ATMEL uC do it: Direct writing to the EEPROM in almost
the same way you use RAM.

I have to know how much work this makes to be able to make a decision on how
we continue. Thanks, Markus

------
Yahoo! Groups Links

a.. To


Hello, Markus.

I've just upload C functions which allow to write in E2Prom for 9s12dp256.
I tested that functions with ICC12 C compiler ImageCraft, and it's OK.

I asked Freescale for the initialisation of ECLKDIV.
Their respond is included in zip file. Thank you to Freescale support ! May be you know you have to erase/write by sectors of 4 bytes...
That functions allow to write anywhere in the E2Prom, and, if it's
necessary, read the datas present to mix with the new datas. It's difficult
to explain that in english.
I means for example if you want to write a char in address 0x0503,
- I first read from 0x0500 and I save datas in temporary variables
- I erase the all sector (4 bytes)
- I rewrite datas saved and the char I,ve to write.

I hope you'll find respond for your question.

Joel

-----Message d'origine-----
De : Roth Markus [mailto:]
Envoy: jeudi 14 octobre 2004 08:41
: '
Objet : [68HC12] Writing to EEPROM: Basics needed Gents

For a certain application it would be nice if I could write to the EEPROM at
run time. I have never been writing to the EEPROM, so my knowledge for this
special feature is zero.

What I am looking for is a short briefing on what I need to do that. E.g.
are there functions in C available for writing to the EEPROM? I don't think
it is so easy as some ATMEL uC do it: Direct writing to the EEPROM in almost
the same way you use RAM.

I have to know how much work this makes to be able to make a decision on how
we continue. Thanks, Markus ------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/dN_tlB/TM
--------------------------------~- Yahoo! Groups Links


Gentlemen

Thank you for your very quick response times / your answers / your codes.
Patrick, maybe I will come back to your offer when things will become
concrete, I'll keep it in my mind.

BTW we use the D60.

Regards, Markus


Roth Markus <> wrote:

[...]

> What I am looking for is a short briefing on what I need to do that. E.g.
> are there functions in C available for writing to the EEPROM? I don't think

not in ANSI C, but as a compiler extension. For example Cosmic
supports EEPROM "variables".

Keep in mind that this usually results in non-portable code.

> it is so easy as some ATMEL uC do it: Direct writing to the EEPROM in almost
> the same way you use RAM.

depends on your compiler - with Cosmic it looks like variable access.
Nevertheless you should be aware of the consequences: long execution
time, and likely deadlock when using concurrently (from interrupt
routines). People might prefer explicit (visible) calls to EEPROM
write routines.

BTW: If you want code snippets, you have to say _exactly_ which
derivative you are using. Joel's code is valid only for S12
derivatives with specific mapping (and could be made much more
compact). There are also differences between 912D60 and 912D60A!

Oliver
--
Oliver Betz, Muenchen


Oliver

Thanks for your answer.
We use Metrowerks HiCross / SmartLinker and C++.
Derivate is D60A. I have never read something like EEPROM-'Variable' like access in the
metrowerks documentation.

Rgds, Markus

> -----Original Message-----
> From: Oliver Betz [mailto:]
> Sent: Thursday, October 14, 2004 11:43 AM
> To:
> Subject: Re: [68HC12] Writing to EEPROM: Basics needed >
> Roth Markus <> wrote:
>
> [...]
>
> > What I am looking for is a short briefing on what I need to
> do that. E.g.
> > are there functions in C available for writing to the
> EEPROM? I don't think
>
> not in ANSI C, but as a compiler extension. For example Cosmic
> supports EEPROM "variables".
>
> Keep in mind that this usually results in non-portable code.
>
> > it is so easy as some ATMEL uC do it: Direct writing to the
> EEPROM in almost
> > the same way you use RAM.
>
> depends on your compiler - with Cosmic it looks like variable access.
> Nevertheless you should be aware of the consequences: long execution
> time, and likely deadlock when using concurrently (from interrupt
> routines). People might prefer explicit (visible) calls to EEPROM
> write routines.
>
> BTW: If you want code snippets, you have to say _exactly_ which
> derivative you are using. Joel's code is valid only for S12
> derivatives with specific mapping (and could be made much more
> compact). There are also differences between 912D60 and 912D60A!
>
> Oliver
> --
> Oliver Betz, Muenchen >
> ------------------------ Yahoo! Groups Sponsor
> --------------------~-->
> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
> Now with Pop-Up Blocker. Get it for free!
> http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/dN_tlB/TM
> --------------------------
> ------~- > Yahoo! Groups Links >
>




The 2024 Embedded Online Conference