AnsweredAssumed Answered

9s12xdp512 flash sector erase is erratic

Question asked by Ed Taylor on Jun 11, 2009
Latest reply on Jun 11, 2009 by Ed Taylor

hello again:

 

i'm using some tried and true code (that works on an 9s12e128) to erase sectors in the xdp512. it was working and then started to hang at the exit of the routine where the code waits for the last command to complete. the code is loaded into and runs from ram. the fclk settings are from the book (16mhz xtal and 40mhz bus). i'm setting ppage to $fd and using an address of $8000 for the window.  the sector does get erased, but the command flag does not set. what have i done wrong here?

 

 

 

EraseSector     sei        
  brset FCLKDIV,#mFCLKDIV_FDIVLD,CheckFSTAT
  movb #%01001010,FCLKDIV   ;divider clock 190 khz
CheckFSTAT brclr FSTAT,#mFSTAT_CBEIF,*
  brclr FSTAT,#mFSTAT_ACCERR+mFSTAT_PVIOL,WriteDummy
  movb #mFSTAT_ACCERR+mFSTAT_PVIOL,FSTAT
WriteDummy ldx FlashStart
  std 0,x    ;write any word to start of flash
  movb #EraseFlashSector,FCMD  ;
  movb #mFSTAT_CBEIF,FSTAT  ;clear the cbeif flag to start program
   brclr FSTAT,#mFSTAT_CCIF,*  ;wait for the command buffer to empty
  cli
  rts
EraseSectorEnd

 

 

 

 

thanks!!

 

ed

Outcomes