Saving variables to eeprom - mc9s12c32

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

Saving variables to eeprom - mc9s12c32

1,333 Views
Shugie14
Contributor I

I have the hsc12mc9s12c32 and am trying to save a variable to eeprom (or flash) in case of power outage. I have seen some forum posts looking for the same thing, but no one seems to be able to point to a good tutorial. I have read the manual, but cannot find FDATA or FADDR registers anywhere in the c definitions in codewarrior. The application notes (especially flash.c) seem to be trying to do what I want, but it looks like they are just using a pointer to point to the memory block they want. This causes my program to die and me to have to reprogram the circuit. Can anyone point to a good place to look because I'm just getting more questions than answers. Saving a variable should be simple I would think.

 

 

 

 

 

Added p/n to subject.

Message Edited by NLFSJ on 2009-04-09 09:34 AM
Labels (1)
0 Kudos
2 Replies

332 Views
jsmcortina
Contributor III

Take a look at AN2548. This is Freescale's serial monitor code, but includes flash erasing, writing and "DoOnStack" which you could re-use in your application.

 

James

0 Kudos

332 Views
kef
Specialist I

First of all use search box at the bottom of this page.

 

FADDR and FDATA registers are of no use in normal chip modes

 

Most probably your program dies because flash is not readable while being programmed, and program routine should run from RAM. Also interrupts should be disabled while programming, because vectors also are sitting in flash and CPU won't read them properly while flash is being programmed.

0 Kudos