Page 1 of 1

Programming Flash Memory

Posted: Tue Feb 28, 2006 11:35 am
by Ruud
Hallo allemaal,

I'm not sure if this subject is 'programming' or 'hardware'. I equped my Commodore 1541-II drive with a AT29C256. What I'm looking for is some sources how to program it while still in the drive. Having the datasheets I do it myself but I'm quite sure somebody did this before and inventing the wheel twice is a bit of waist of time IMHO.

Any helpers with sources or an URL?
Thank you very much !!!

Posted: Thu Mar 02, 2006 2:47 am
by Memblers
Here's the code I wrote for use with AM29F040, let me know if it's any good for the chip you're using.

Code: Select all

byte_program:
          stx temp2
          ldx #$AA
          stx $8555
          ldx #$55
          stx $82AA
          ldx #$A0
          stx $8555
          sta (ptr),y    ;(ptr),y
          sta temp_lo

@program_wait:
          lda (ptr),y
          sta count_lo
          lda (ptr),y
          sta count_hi
          and #%01000000
          sta temp3
          lda count_lo
          and #%01000000
          cmp temp3
          beq @program_done
          lda count_hi
          and #%00100000
          and count_lo
          beq @program_wait
          lda (ptr),y
          sta count_lo
          lda (ptr),y
          sta count_hi
          and #%01000000
          sta temp3
          lda count_lo
          and #%01000000
          cmp temp3
          beq @program_done
          lda #$F0
          sta (ptr),y
          ldx temp2
          rts

@program_done:
;              beep
                ldx temp2
                rts

Code: Select all

sector_erase:
        lda #$AA
        ldy #$55
        ldx #$80

        sta $8555
        sty $82AA
        stx $8555
        sta $8555
        sty $82AA
        lda #$30
        sta $8000
:
        lda $8000
        cmp #$FF
        bne :-

        rts

Code: Select all

autoselect_mode:
        lda #$F0
        sta $8000       ; reset command

        lda #$AA        ; unlock command
        sta $8555
        lda #$55
        sta $82AA

        lda #$90        ; auto-select command
        sta $8555

        lda $8000       ; mfg. id
        sta temp1
        lda $8001       ; device id
        sta temp2

        lda #$F0
        sta $8000       ; reset

        lda temp1
        cmp #1
        bne @xx
        pointer mfg_amd,addr_lo
        jmp mfg_end
@xx:
        cmp #$20
        bne @zz
        pointer mfg_st,addr_lo
        jmp mfg_end
@zz:
        pointer mfg_none,addr_lo
mfg_end:
        lda temp2
        cmp #$A4
        bne @aa
        pointer dev_040,addr_lo2
        jmp dev_end
@aa:
        cmp #$E2
        bne @ba
        pointer dev_040st,addr_lo2
        jmp dev_end
@ba:
        cmp #$20
        bne @bb
        pointer dev_010,addr_lo2
        jmp dev_end
@bb:
        pointer dev_unk,addr_lo2
dev_end:
        rts

msg_maker:      .byte LF,"Flash maker; ",0
mfg_none:       .asciiz "your mom!!"
mfg_amd:        .asciiz "AMD"
mfg_st:         .asciiz "ST"
msg_dev:        .byte LF,"Part #; ",0
dev_040:        .asciiz "Am29F040"
dev_040st:      .asciiz "M29F040B"
dev_010:        .asciiz "29F010"
dev_unk:       .asciiz "Unknown"

Posted: Fri Mar 03, 2006 11:10 am
by Ruud
Memblers wrote:
Here's the code I wrote for use with AM29F040, let me know if it's any good for the chip you're using.
Thank you very much!