Hallo Besucher, der Thread wurde 1,6k mal aufgerufen und enthält 2 Antworten

letzter Beitrag von tlr am

Erasing sectors on the DTV

  • Hi TLR (or anybody else who can help me with that) :)


    I want to erase a sector on the dtv rom.


    I looked into the atmel doc how to programm a sector, and check it again how I did that in my flash program (with helps from tlr's routines).
    and I wondered why the code on the dtv is doing:


    lda #aa
    sta $4aaa
    lda #55
    sta $5554
    lda #a0
    sta $4aaa


    while the atmel doc is saying something like (on side 13):


    aa into 555
    55 into aaa
    a0 into 555


    anyway ...


    I need the commands to erase a sector... e.g. sector 1d0000 - 1dffff


    ...what do I have to do?


    lda #aa
    sta $4aaa
    lda #55
    sta $5554
    lda #80
    sta $4aaa
    lda #aa
    sta $4aaa
    lda #55
    sta $5554

    ?????


    lda #30


    ????

  • hmmm.... seems like I am getting it by myself (although a verification by somebody else would be nice)


    lda #aa
    sta $4aaa
    lda #55
    sta $5554
    lda #80
    sta $4aaa
    lda #aa
    sta $4aaa
    lda #55
    sta $5554



    and then I have to write the #30 anywhere into the sector to be erased...


    -> so, e.g. setting segment 4000-7fff to $1d0000
    (with: 32 dd a9 74 32 00)


    and then lda #30; sta $4000


    hmmm... and then? is the sector erased??
    how long does this take? any verify needed?


  • Yes, in bank $00.


    Zitat

    and then I have to write the #30 anywhere into the sector to be erased...


    -> so, e.g. setting segment 4000-7fff to $1d0000
    (with: 32 dd a9 74 32 00)


    and then lda #30; sta $4000


    Correct.


    Zitat

    hmmm... and then? is the sector erased??
    how long does this take? any verify needed?


    Yes. It takes 400 ms, see below.


    You should check the status by one of the methods described on pages 10 and 11.
    The details are shown in the table on page 12.
    I suggest you use the polling algorithm.


    Basically you just read the first address of the sector, and check bits 7, 5 and 3. If bit 7 turns '1', you are done.
    If any of bits 5 and 3 turn 1 while bit 7 is still 0 you have an error.


    If you want to try the toggle algorithm you must make sure no one but you reads the flash.
    You must disable character fetches from rom (and run no rom code), and more importantly you must set the dma source address to a ram location. If not, the dma controller will do dummy fetches from flash each 1 MHz cycle and interfere with your code.


    To check the status after a byte-program, you check if bit 7 is inverted, and check bits 5 and 3 like above above.
    Programming odd bytes on the 47BV will report total failure, but work anyway (!).
    You need to escape this error condition before continuing. I don't remember exactly how I did this in the flasher, but it involves the exit sequence (i.e write $f0).


    References are to the AT49BV161T datasheet.
    In the (non public) AT47BV161T the parameters I list below are the same unless noted.


    Program word/byte:
    Typical=20 us, maximum=200 us. (tBP, page 22)
    (byte programming is not supported on the AT47BV161T, but can be worked around)


    Sector erase:
    Typical=300 ms, maximum=400 ms. (tSEC, page 22)


    Chip erase:
    Maximum=12 seconds. (tEC, page 22)


    However, any of these may fail for a number of reasons (timeout, sector protected),
    so you should normally check the status after each operation.


    Datasheet: here