John Bowker

Reprogramming flash on MC9S08QE parts

Discussion created by John Bowker on Jul 14, 2009
Latest reply on Jul 15, 2009 by John Bowker

I'm developing a bootloader and running into a problem reprogramming the flash on devices that use PPAGE.  I'm testing on a MC9S08QE128 part.  I can successfully program pages 4 through 7; however, attempts to program pages 0, 1, 2, or 3 result in "random" processor crashes.


Note that the same exact code is used to program pages 4-7 as 0-3. It appears that it is the programming cycle that causes the issue.  If I don't call the program routine, I can erase all of pages 0-3.  If in the program routine I force PPAGE to 4, the programming works (but, of course, at address 0x10000 instead of 0x00000).


The actual erase and program routines are executing in RAM.  I've verified that PPAGE is always programmed correctly (I divide the address by 16KB).


I tried specifically testing each 16KB block from 0 through 3 (rather than trying to program each in order).  This resulted in the same failures; the failures are hard to debug because the part typically resets and the debugger loses control.   


My bootloader starts at address 0xF400 and checks that it is not attempted to overwrite itself.


I'm not sure where else to look - thoughts and suggestions appreciated.