Sorry for re-animating this old topic, but I am facing similar problems with EzPort for MCF52259 chip.
All commands works fine, but PP. Sector Erase works on loaded chip, but second attempt to erase same sector returns WEF=1 flag in RSR. Page Program always returns WEF=1. Chip clock is 48MHz. I figured WCR value =0x4C should produce FCLK=153kHz which is within specified range of 150 to 200kHz.
State of RSR before executing PP command is 0x22. Any help would be greatly appreciated.
I am almost done with Windows based application for EzPort. Application may use both LPT port or USB FTDI chip to program ColdFire chips over EzPort. If any interest I may post this design for public usage after my problem with PP is resolved.
Here is a little bit more description what is going on with my application. I found that issuing PP command on loaded chip before SE or BE, returns WEF=0 flag. However nothing being written and flash content is exactly the same as before PP command being issued. After BE same PP with same data bytes returns WEF=1 and FLASH remains in erased state. Is anyone had similar issue? Obviously, since SE and BE commands work just fine, my WCR value is correct.
As far as I remember in my case the problem was when I erased entire flash memory, reseted the controller and then attemped to program. And the programm failed (as I understood) because after chip-erase flash protection bits are set. And these bits are taken into account only when controller starts up. That is why if you program immediately after erase your write operation would success. Take a look at chapter 17 "ColdFire Flash Module" (CFMPROT-CFM Protection Register)
For programm/verify I use the following algorithm:
0. Verify your "spi" clock sppen confirms the controller specification.
1. EnableEzPort.
2. WriteConfig - to configire Fclk.
3. CheckStatus.
4. BulkErase or SectorErase if you shall programm.
BulkErase: WriteEnable, CheckStatus, CMD_BE, WaitForOperationDone, CheckStatus(WEP,WIP)
if (ok) WriteEnable, UpdateConfig(Fclk)
SectorErase: CheckStatus(WEN), CMD_SE, WaitForOperationDone, CheckStatus(WEP,WIP)
!!! don't use SectorErase for blank(filled with 0xFF) sectors.
5. Programm or verify.
6. DisableEzPort.
I hope this will help you.
And ther is an appeal to motorola engeneers to describe the use of EzPort programming mechanism more detailed.
I got it working. My bad. Thanks for all your help. I will post my design as soon as I finalize my code.
Thanks for you reply. Following your advice I got through my problem with chip lock up condition after erase cycle. As you mentioned key was to to stay in EzProg mode after bulk erase (I wonder why this not mentioned in the chip's manual!). But I still can't achieve data retention. Chip stays blank after PP was executed.
I wonder if my prescaler data is right. Manual is a bit vague on the description.
Here is how I calculate the value: Chip clock is 48MHz, so I need 8 divider on.
Accounting that flash controller divide its clock by 2 it gives my 48/(2*8)=3 MHz. Highest recommended FCLK=200kHz, so final divider value would be 3/0.2=15. Taking it all together I got Configuration Register value &B01001111. Is my calculation correct? Currently I am running at very conservative SPI clock 1MHz. Should it match FCLK?
At this point I am trying to execute simplest possible operation - writing 0 to address 0.
Here is my string for PP:
&H02,00,00,00,00,00,00,00 (PP command, 24 bit address 0, 4byte data=0).
Do I missing anything? I was reading some discussions about mystical "backdoor" addressing for EzProg writes. It doesn't make any sense to me because read operation works with straight addressing.
OK, here is my promised design for EZPort PC programmer. It supposed to run on Windows XP. It works both USB or LPT (multiple port addresses). I haven't test installer on blank PC yet. So let me know if there is any problem with components. I included parallel port driver in installation package, but left FTDI drivers outside. You will need to install them prior running my installer for programming application. I made skeleton help for EzPort hookup it's also attached to this message.
// 1. Boot-up from reset with EZPORT enabled.
// 2. Check reset value of SR (FS should be set)
// 3. Set WEN bit and write to configuration register
// 4. Once WIP goes low, check CRL is set
// 5. Set WEN and issue Bulk Erase command.
// 6. Poll SR until WIP goes low and ensure WEF is not set. Check value of FS.
// 7. Issue Reset Chip command.