hi, i'm trying to save some data on flash with a 9s12e64 freescale MCU, following instruction on application notes and examples i did the following steps
1)set FCLKDIV to have the flash clock in the right range
2)do an ordinary write,data does'nt matter, in the sector that i want erase
3)put an erase command($40) in the FCMD register
3)then clear CBEIF bit in FSTAT by LDAA #$80 followed by STAA FSTAT then i check the bit with a BITA instructtion ,then branching if the bit results still set
at this point the CBEIF bit remains high
can anyone show me where my error is?thank you!
Diego
Didn't find your answer? Ask the community — no account required.
Y
Yuriy K.
Did you execute this code from RAM? You can not execute from FLASH and program it.
WBR, Yuriy.
"Resistance is futile"
B
blisca
erase
Yes i did it,i copied the code in RAM,anyway thanks Yuriy
Y
Yuriy K.
Did you unsecure the FLASH memory before trying to program/erase?
okthanks to you now something changes in flash , but i can't understand why when i erase the sector with 0x40 in FCMD and sending 80 to FSTAT i have the entire blocks 0x4000 to 0x8000 and
0xC000 to 0xFFFF filled with strange values: 10 and 4F,can you help me again
i do the erasing performing an ordinary write at 0x5200,or 0xC200,expecting that only the sector containing the address that i choose would be erased can you or someone help me again ,please?
B
blisca
ok,your hints helped me a lot,the last problem was due to a trivial reason,i deleted erroneously a row in my code so i did'nt program the FCLKDIV register (LDAA #$00101001 was not followed by STAA FCLKDIV),now it looks working
thanks thanks thanks Yuriy!!
Y
Yuriy K.
No idea. Never seen anything like that. IT is worth to double check FCLKDIV calculations.
ok,thanks to you now my program looks being able to write data in the FLASH,i profit of your courtesy for other 2 questions:
I am using the 9s12E64 MCU having 64KB of memory; it looks that with 16bits i could address linearly the whole memory so ,why the need of the PPAGE block?Compatibility with 8 bit devices?
In my case i used the upper block(starting from $C000) for the code and i used the FLASH starting from $ 4000 for variables to be stored,hopin that i not did a bad choice. i read in the Application notes and examples that one has to erase the whole sector prior of writing a byte,and the sector should be 512 bytes wide; why it happens that 1024 bytes are erased?
thank you for the n-th time!
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.