Ok, I have done a rewrite of the flash functions and the erase call seems to work perfectly. I am having trouble with the flash writing function however. If I step through or use breakpoints to step through one byte write at a time, the memory locations are written to correctly. But if I execute the code without breakpoints, the memory locations are filled with the character (0x04). This seems like a timing issue, but I am not sure. I am using Pavel's clock setting below to set the clock correctly. Any advice would be appreciated. I have attached the code below.
-gcoakley
prog64:
LDA #$40
STA $715
prog64loop:
LDA $1825 ;check flash status register
AND #$80 ;mask for empty flag
BEQ prog64loop
LDHX $700 ;load source address
LDA 0,x
AIX #1
STHX $700 ;store new source address+1
LDHX $705 ;load destination address
STA 0,x
AIX #1
STHX $705 ;store new destination address+1
LDA #$25 ;burst program command
STA $1826 ;write command
LDA #$80 ;mask to initiate command
STA $1825 ;register command
LDA $715 ;load loop counter
DECA ;decrement counter
STA $715 ;save counter
CMP #$0
BNE prog64loop
prog64chk:
LDA $1825 ;check flash status register
LSLA
BPL prog64chk ;loop if FCCF = 0
RTS