Kurt Liebezite

Can't erase 9S12C32 flash

Discussion created by Kurt Liebezite on May 1, 2006
Latest reply on May 1, 2006 by Alban Rampon

I've got a handful of prototypes that I'm having trouble with (well, actually, all of my prototypes, not just a handful out of a larger group). The major problem is this: at a seemingly random point in the cycles of assemble-program-debug I will lose the ability to erase the flash and program new code into a device. I use the P&E Micro PKG12Z set of tools; our project is written in assembly, and I'm using the P&E USB Multilink to connect to the BDM port. The error shows up when I do a blank check after an erase within PROG12Z: the erase does not report an error, but the blank check does. Once a device reports this failure to erase, I can't do any further erasure or programming.

Some random facts about the situation in the hopes that this will stimulate someone's memory:
-- We're using a 4 MHz crystal, and once our application code gets going it multiplies this up to 24 MHz (in a 25 MHz part), using SYNR=5 and REFDV=0.
-- I've set FCLKDIV to 19, which I believe causes the flash oscillator to run at 4000000/(19+1)=200 kHz.
-- We initialize location FF0D to 02 in the download image, which should mean that FPROT comes up with FF (unprotected). Later, after we examine a jumper to determine if a firmware update is requested, we write once to FPROT with the value $DA, which should protect the lower 2k and upper 16k of our flash image.
-- Location FF0F has 02 in the download image, which should initialize FSEC to unsecured state.
-- Running P&E's Usecure 12 tells me that FSEC=02 at the start, it does something, then FSEC=02 at the end, try talking to it. I can talk to it afterwards, but erasing still fails as described above.
-- The prototypes may have been run with FCLKDIV set to 18 for a while, but I don't think that flash was erased or programmed from within the firmware on more than one or two of the four.

Thanks for any help or suggestions you may have.