hi steve, thanks for your advice. I have already read that note, and have seen the sample program. According to that program, FSTAT Register can be written using a equal, but it just can't be written.
By the way, I'm not using Code Warrior. And FSTAT is addressed to 0x00_0106 in global address.
So you are trying to write D-flash - rather than use the EEPROM feature?
To program D-flash you can't just write to the EEPROM window, you have to use the d-flash programming sequence (as below)
Here's a C segment to erase a D-flash 256 byte sector and then write some data to it. What initially tripped me up is FSTAT bit 7 is cleared by writing 1 to it to initiate a flash command.
// This will erase the sector at 0x10_0100
asm("sei");
if ((FSTAT & 0x30) != 0) {
FSTAT |= 0x30; // clear ACCERR or FPVIOL if set
}
FCCOBIX = 0;
FCCOBHI = 0x12; // erase D-flash sector command
FCCOBLO = 0x10; // global address of all D-flash
FCCOBIX = 1;
FCCOB = 0x100; // address within sector
FSTAT = 0x80; // initiate flash command (datasheet very confusing)
asm("cli");
//now write a phrase to D-flash
asm ("sei");
FCCOBIX = 0;
FCCOBHI = 0x11; // prog D-flash
FCCOBLO = 0x10; // global addr
FCCOBIX = 1;
FCCOB = 0x0100; //global addr - within an erased sectot
FCCOBIX = 2;
FCCOB = word_to_prog_1;
//optional additional words
FCCOBIX = 3;
FCCOB = word_to_prog_2;
FCCOBIX = 4;
FCCOB = word_to_prog_3;
FCCOBIX = 5;
FCCOB = word_to_prog_4;
FSTAT = 0x80; // initiate flash command
asm("cli");
Hope that helps.
James