D-Flash writing

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

D-Flash writing

2,461件の閲覧回数
chris_up2u
Contributor I
hi guys, i'm now working on mc9s12xep100 chip, there's a 32k D-Flash in global memory, addressed from 0x10_0000 to 0x10_7FFF. I want now write data to the D-Flash through the EPAGE Register. Should i first partition D-Flash, erase sectors and then write to buffer RAM EEE? The data written to buffer RAM will be backed up to D-Flash?

By the way, i can only read the FSTAT Register but not write it, so i can't start command write sequence and neither launch command. Is anywhere else another FSTAT that can be written? Can anybody help? Thx a lot!
ラベル(1)
0 件の賞賛
3 返答(返信)

689件の閲覧回数
Steve
NXP Employee
NXP Employee
Have a look at AN3473 for a good introduction to using this feature. That should answer your programming question as well. AN3490 is also available as an architectural description if you want to do something more arcane with the memory.
0 件の賞賛

689件の閲覧回数
chris_up2u
Contributor I

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.

Message Edited by chris_up2u on 2009-03-13 01:47 PM
0 件の賞賛

689件の閲覧回数
jsmcortina
Contributor III

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

0 件の賞賛