Marc Paquette

CodeWarrior 8- & 16-bit tools: 9S12C32 Flash sector erase and data storage

Discussion created by Marc Paquette Employee on Jan 27, 2006
To help you find solutions to problems that have already been solved, we have posted this message. It contains an entire topic ported from a separate forum. The original message and all replies are in this single message.
 
Posted: Jul 09, 2004 - 12:19 AM   
 
Hi
 
I would like a store a DWORD variable in the 9S12C32 chip as a nonvolatile data. I have used the IntFlash bean however when writing to the address:-
 
/* Write number to address 0xE000 */
Data = IFsh1_SetByteFlash(0x3E4000,55);
/* Read contents of internal FLASH array on address
0xE000 and write it to variable Data */
IFsh1_GetByteFlash(0x3E4001,&Data);
 
The first line always results in OUT_OF_RANGE (or an error code of 2), I have declared the appropriate flash sector in the prm file too as follows:-
 
SECTIONS
/* List of all sections specified on the "Build options" tab */
RAM = READ_WRITE 0x00003800 TO 0x00003FFF;
ROM_C000 = READ_ONLY 0x0000C000 TO 0x0000FF7F;
ROM_4200 = READ_ONLY 0x00004200 TO 0x00007FFF;
ROM_4000 = READ_ONLY 0x00004000 TO 0x000041FF;
 
Any idea Whats wrong? why am I not able to read and write data to the flash area? Alternatively is there any example code on how to write to flash?
 
Cheers
Jameel
 
 
Posted: Jul 11, 2004 - 11:06 AM   
 
Hi Jameel,
I'm fairly new to CodeWarrior & the P/Expert, but I think you'll find that you have to address all of the flash between the ranges of 0x8000 & 0xBFFF:
So for the 4000 range that you want, you'd use:
 
Data = IFsh1_SetByteFlash(0x3D8000,55);
 
I hope I'm right 
 
Cheers
Greg

Outcomes