James Peverill

FLASH erase code problem

Discussion created by James Peverill on Apr 24, 2007
Latest reply on Jul 16, 2009 by kef
 I am using the MC9S12NE64 microcontroller and trying to write code to allow my device to reflash itself over ethernet.  For the actual flash writing portion of the code I am basically just using the code from AN2720, but it doesn't seem to be working properly.  I can erase and write to sectors that are already blank, but an attempt to erase a sector that already contains data gets an ACCERR.  All protection is turned off (and besides it seems that protection problems would cause a PVIOL instead of ACCERR).

 I am using the BDM to monitor the operation, but I am careful not to put any breakpoints in the flashing portion of the code so I don't believe this would cause an issue.  After I started having problems I moved all the flashing code to a sandbox application that just consists of the flashing code (ie no ISR's or any other code), but this didn't improve things.

 Any ideas?  I read through AN2400 (HCS12 NVM guidelines) and I can't figure out which of the 12 invalid FLASH operations could be causing my ACCERR.  Any help would be greatly appreciated.