Ed Taylor

problems programming e128 flash

Discussion created by Ed Taylor on Nov 4, 2007
Latest reply on Nov 19, 2007 by Ed Taylor
hello:
 
i wrote some code to program the flash memory @0x4000. when i run the sector erase code ithe program counter goes to 0x1050 causing an illegal breakpoint. i have commented out the write to FSTAT (and subsequent read) and the routine runs out of ram and returns to the main loop. where have i gine wrong?
 
 
thanks in advance.
 
 
ed
 

FlashParameters
  movw #RamOperatingVariables,FlashDataStart     ;area in ram
  movw #FlashOperatingVariables,FlashStart           ;0x4000
  movw #EndFlashVariables,FlashEnd
 

MoveFlashCodeToRam
  ldx #RamFlashRoutine   ;ram area for flash programmer code
  ldy #FlashCode   ;start of flash program
MoveMoreCode ldaa 1,y+
  staa 1,x+
  cpy #FlashCodeEnd   ;move to ram
  blo MoveMoreCode
  jsr RamFlashRoutine
  rts  
  
FlashCode      
  
  ldy FlashDataStart
  ldx FlashStart
  std 0,x    ;write any word to start of flash
  movb #EraseFlashSector,FCMD  ;
; bset FSTAT,#FSTAT_CBEIF  ;clear the cbeif flag to start program
; brclr FSTAT,#FSTAT_CBEIF,*  ;wait for the command buffer to empty
  rts

Outcomes