Actually, there are several things wrong here. Immediately after you are sending the page erase command, you are sending the program command - but the Flash module is not yet ready. You need to poll the FCCF bit in the FSTAT register to see when the module is ready for another command.
Also, you say you are writing an 0xFF to address 0x5000 in Flash. When Flash is blank, it reads 0xFF, so in order to test it, you should be writing anything except 0xFF in order to see if it's working.
Another thing, you only did a page erase, not a mass erase, so you need to run the blank check command as part of the security measure before you can run the program command. I think this is an extra step to make sure runaway code doesn't write over the Flash.
I highly recommend you read the Flash section of the datasheet a few times to become more acquainted with it. I've never worked with this particular device and I only scanned the datasheet for things that jumped out at me and I could still be missing something.
Thanks for the Help,
Although I have tried all possible values for FCDIV and I still get the same warning message and I know for a fact that my BUS clock is 4Mhz. So im still thinking that is my problem. I tried going through with your suggestions and I am still not getting anything to write to flash. I still think it is my Frequency Clock command which is not allowing the value to be written. Unles something else Is wrong
Ok, I have the board hooked up to my computer and I am running through it attempting to Flash. I am noticing that no matter what I do the FCDIV register is setup with a value of CB (giving me a Flash Clock way too Low) Upon reboot I am not able to write to this register to set the flash clock!!
Also my code is giving me a FACCERR whenever i set a value to ptr
int *ptr;
ptr = (char*) 0x5000;
FCDIV = 0x19;
*ptr = 0x88; //Trying to Write a Value to 0x500 Gives me ACCERR in FSTAT
FCMD = 0x40; //Erase Page
FSTAT_FCBEF = 1; //Send Command
*ptr = 0x88; //Trying to Write a Value to 0x500 Gives me ACCERR in FSTAT
FCMD = 0x20; //Byte Program
What Is going wrong...Why cant I write to FCDIV or where would the reset value be coming from. Need input thanks guys..and girls
FSTAT_FCBEF = 1; //Send Command
Hi,
Take a look at this thread.
http://forums.freescale.com/freescale/board/message?board.id=8BITCOMM&message.id=1066
Regards Peg
Hi Yodabam,
Take a look at AN2496.
It is for trimming the ICG but at the end of this process they write the trim value to FLASH which is the bit that may assist you.
BR Peg