Saving variables to eeprom - mc9s12c32

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

Saving variables to eeprom - mc9s12c32

1,342 次查看
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
标签 (1)
0 项奖励
2 回复数

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

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